Skip to content

Commit

Permalink
Absolute artifact paths relative to implicit repo
Browse files Browse the repository at this point in the history
Closes #141
  • Loading branch information
tliron committed Apr 2, 2024
1 parent 36fe346 commit 6fbd39c
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 64 deletions.
Binary file modified executables/puccini-clout/default.pgo
Binary file not shown.
Binary file modified executables/puccini-csar/default.pgo
Binary file not shown.
Binary file modified executables/puccini-tosca/default.pgo
Binary file not shown.
21 changes: 10 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ require (
github.com/segmentio/ksuid v1.0.4
github.com/spf13/cobra v1.8.0
github.com/tliron/commonjs-goja v0.2.4
github.com/tliron/commonlog v0.2.16
github.com/tliron/exturl v0.4.3
github.com/tliron/go-ard v0.2.16
github.com/tliron/go-transcribe v0.3.4
github.com/tliron/kutil v0.3.23
github.com/tliron/commonlog v0.2.17
github.com/tliron/exturl v0.4.4
github.com/tliron/go-ard v0.2.17
github.com/tliron/go-transcribe v0.3.5
github.com/tliron/kutil v0.3.24
github.com/tliron/yamlkeys v1.3.6
github.com/vmihailenco/msgpack/v5 v5.4.1
)
Expand All @@ -23,7 +23,6 @@ require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/beevik/etree v1.3.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
Expand All @@ -39,18 +38,18 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-git/v5 v5.10.0 // indirect
github.com/go-git/go-git/v5 v5.11.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/goccy/go-yaml v1.11.2 // indirect
github.com/goccy/go-yaml v1.11.3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-containerregistry v0.16.1 // indirect
github.com/google/go-containerregistry v0.19.1 // indirect
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/kortschak/utter v1.5.0 // indirect
github.com/kortschak/utter v1.6.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -67,7 +66,7 @@ require (
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sirupsen/logrus v1.9.1 // indirect
github.com/skeema/knownhosts v1.2.0 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vbatts/tar-split v0.11.3 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand Down
47 changes: 22 additions & 25 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
Expand Down Expand Up @@ -66,18 +64,18 @@ github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
github.com/go-git/go-git/v5 v5.10.0 h1:F0x3xXrAWmhwtzoCokU4IMPcBdncG+HAAqi9FcOOjbQ=
github.com/go-git/go-git/v5 v5.10.0/go.mod h1:1FOZ/pQnqw24ghP2n7cunVl0ON55BsjPYvhWHvZGhoo=
github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4=
github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY=
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
github.com/goccy/go-yaml v1.11.2 h1:joq77SxuyIs9zzxEjgyLBugMQ9NEgTWxXfz2wVqwAaQ=
github.com/goccy/go-yaml v1.11.2/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU=
github.com/goccy/go-yaml v1.11.3 h1:B3W9IdWbvrUu2OYQGwvU1nZtvMQJPBKgBUuweJjLj6I=
github.com/goccy/go-yaml v1.11.3/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-containerregistry v0.16.1 h1:rUEt426sR6nyrL3gt+18ibRcvYpKYdpsa5ZW7MA08dQ=
github.com/google/go-containerregistry v0.16.1/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ=
github.com/google/go-containerregistry v0.19.1 h1:yMQ62Al6/V0Z7CqIrrS1iYoA5/oQCm88DeNujc7C1KY=
github.com/google/go-containerregistry v0.19.1/go.mod h1:YCMFNQeeXeLF+dnhhWkqDItx/JSkH01j1Kis4PsjzFI=
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE2YxKWtnnQls6rQjjW5oV7qg2U=
github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg=
github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f h1:7LYC+Yfkj3CTRcShK0KOL/w6iTiKyqqBA9a41Wnggw8=
Expand All @@ -95,8 +93,8 @@ github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLA
github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/kortschak/utter v1.5.0 h1:1vHGHPZmJ6zU5XbfllIAG3eQBoHT97ePrZJ+pT3RoiQ=
github.com/kortschak/utter v1.5.0/go.mod h1:vSmSjbyrlKjjsL71193LmzBOKgwePk9DH6uFaWHIInc=
github.com/kortschak/utter v1.6.0 h1:h3hC7i9z+8Hn/PZNZ2S4Eq7ZCTLWF0CMdTFJgzRF9TA=
github.com/kortschak/utter v1.6.0/go.mod h1:vSmSjbyrlKjjsL71193LmzBOKgwePk9DH6uFaWHIInc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
Expand All @@ -108,8 +106,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
Expand Down Expand Up @@ -153,8 +149,8 @@ github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.1 h1:Ou41VVR3nMWWmTiEUnj0OlsgOSCUFgsPAOl6jRIcVtQ=
github.com/sirupsen/logrus v1.9.1/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM=
github.com/skeema/knownhosts v1.2.0/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo=
github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ=
github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
Expand All @@ -167,20 +163,21 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tliron/commonjs-goja v0.2.4 h1:nUH0bbw1TYw0wQN7ckGGFMowsLfZ9tdlKd7aJNg/gDI=
github.com/tliron/commonjs-goja v0.2.4/go.mod h1:E3gLRcfHp04i9lVUoRhNBkolqIflZ+Erilx+yifKzgQ=
github.com/tliron/commonlog v0.2.16 h1:rDLWLKQI4wAQVYp2GvJKqIyVGYTIl0myuP0lAbFfbfo=
github.com/tliron/commonlog v0.2.16/go.mod h1:p9p8LhdDgnOi9+GnF9tYKc8K61xOVr1reV+kpkSU7Cw=
github.com/tliron/exturl v0.4.3 h1:BdRjKdnlumesqwrWdtWOjP+4ytkETk3qfshPaOUaz7g=
github.com/tliron/exturl v0.4.3/go.mod h1:odoBxRKyJ/nEGjqK+AcZy6R7wKhRcVFhnqvmjgACKf0=
github.com/tliron/go-ard v0.2.16 h1:IqS5bSq1xEQSO5oE+FWarMOFdg1idKSjpksETqBM9Cc=
github.com/tliron/go-ard v0.2.16/go.mod h1:LjHmKVlDvh8mSksijtEihMULBb3/Xh8fILBknHUaXyQ=
github.com/tliron/go-transcribe v0.3.4 h1:gC6LcYPzK9vMWJaJUz5dP30OIkgbL/u+P1Sj232zXaw=
github.com/tliron/go-transcribe v0.3.4/go.mod h1:KGNTIkslQcMmQAq36Ofef6xQjMMNOv+owvrOMtW55NI=
github.com/tliron/kutil v0.3.23 h1:c8x/tOF1wxD0zzy7agSnk/x6MW/wAY4Nxeu2Yi198sg=
github.com/tliron/kutil v0.3.23/go.mod h1:2iSIhOnOe1reqczZQy6TauVHhItsq6xRLV2rVBvodpk=
github.com/tliron/commonlog v0.2.17 h1:GFVvzDZbNLkuQfT45IZeWkrR5AyqiX7Du8pWAtFuPTY=
github.com/tliron/commonlog v0.2.17/go.mod h1:J2Hb63/mMjYmkDzd7E+VL9wCHT6NFNSzV/IOjJWMJqc=
github.com/tliron/exturl v0.4.4 h1:zsyfNRdswIrdJJsvS3g6h8NnrMb/rIBX1Ulevb18a40=
github.com/tliron/exturl v0.4.4/go.mod h1:3qhlToI3jc6+kVtVkf7lCaVzJgGH0DGWS6TUxe0tX0U=
github.com/tliron/go-ard v0.2.17 h1:cNZEXmoPe4/UiJwcQqAqCJ3FB635jviEEfv0ox64HoQ=
github.com/tliron/go-ard v0.2.17/go.mod h1:6cfX45C0wOMXeirtKlheG/cidBpeOErkzbI4dRhTUIc=
github.com/tliron/go-transcribe v0.3.5 h1:8b7aQY9XOGi8Ex9KK78YE5CkO3SpnyecfOk8JzDrm1w=
github.com/tliron/go-transcribe v0.3.5/go.mod h1:2zb1ZWrlYtv18QXgi3fA6xIHtfPqPlnI4lUz9Exz8cc=
github.com/tliron/kutil v0.3.24 h1:LvaqizF4htpEef9tC0B//sqtvQzEjDu69A4a1HrY+ko=
github.com/tliron/kutil v0.3.24/go.mod h1:2iSIhOnOe1reqczZQy6TauVHhItsq6xRLV2rVBvodpk=
github.com/tliron/yamlkeys v1.3.6 h1:PPV4q7flMqIvmSUSsEZuns7Qt3VIMxkhBj+6KTRvI9c=
github.com/tliron/yamlkeys v1.3.6/go.mod h1:K/uKQwMke5a9h6YW/Sj9pcp66vU3lRP97OrOjo/ELoU=
github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8=
Expand Down
Binary file modified library/default.pgo
Binary file not shown.
4 changes: 3 additions & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ be `~/go/bin/puccini-tosca`, etc.
You might find it convenient to have `~/go/bin` on your search path. For Bash, add this to your
`~/.bashrc` file:

export PATH="~/go/bin:$PATH"
export PATH=~/go/bin:$PATH

The Go compiler will only compile changed files. Also, it's a very fast compiler. So, generally you
should not be concerned about this step in your toolchain.
Expand All @@ -37,6 +37,8 @@ introduced in Go 1.11. See the files `go.mod` and `go.sum`.
Installs bash completion scripts for the current user, for the current build of Puccini. This allows
you to press TAB to complete commands starting with `puccini-tosca`, `puccini-clout`, etc.

scripts/install-bash-completion -r

[embed](embed)
--------------

Expand Down
2 changes: 1 addition & 1 deletion scripts/_env
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export PATH=$GOPATH/bin:$ROOT:$PATH

export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java}

ANSIBLE_VERSION=9.3.0
ANSIBLE_VERSION=9.4.0
4 changes: 3 additions & 1 deletion scripts/install-bash-completion
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ c puccini-tosca
c puccini-clout
c puccini-csar

reset
if [ "$1" == -r ]; then
reset
fi
2 changes: 1 addition & 1 deletion tosca/csar/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func ReadMetaFromURL(context contextpkg.Context, csarUrl exturl.URL, format stri
format = csarUrl.Format()
}

if url, err := NewURL(csarUrl, format, TOSCA_META_PATH); err == nil {
if url, _, err := NewURL(csarUrl, format, TOSCA_META_PATH); err == nil {
if reader, err := url.Open(context); err == nil {
reader = util.NewContextualReadCloser(context, reader)
defer commonlog.CallAndLogWarning(reader.Close, "csar.ReadMetaFromURL", log)
Expand Down
2 changes: 1 addition & 1 deletion tosca/csar/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func GetRootPaths(context contextpkg.Context, csarUrl exturl.URL, format string)
format = csarUrl.Format()
}

url, err := NewURL(csarUrl, format, "")
url, _, err := NewURL(csarUrl, format, "")
if err != nil {
return nil, err
}
Expand Down
20 changes: 10 additions & 10 deletions tosca/csar/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ import (
"github.com/tliron/exturl"
)

func NewURL(csarUrl exturl.URL, format string, path string) (exturl.URL, error) {
func NewURL(csarUrl exturl.URL, format string, path string) (exturl.URL, exturl.URL, error) {
if format == "" {
format = csarUrl.Format()
}

if exturl.IsValidTarballArchiveFormat(format) {
return exturl.NewTarballURL(path, csarUrl, format), nil
return exturl.NewTarballURL(path, csarUrl, format), exturl.NewTarballURL("", csarUrl, format), nil
}

switch format {
case "zip", "csar":
return exturl.NewZipURL(path, csarUrl), nil
return exturl.NewZipURL(path, csarUrl), exturl.NewZipURL("", csarUrl), nil
default:
return nil, fmt.Errorf("unsupported CSAR archive format: %q", format)
return nil, nil, fmt.Errorf("unsupported CSAR archive format: %q", format)
}
}

func GetDefaultServiceTemplateURL(context contextpkg.Context, csarUrl exturl.URL, format string) (exturl.URL, error) {
func GetDefaultServiceTemplateURL(context contextpkg.Context, csarUrl exturl.URL, format string) (exturl.URL, exturl.URL, error) {
return GetServiceTemplateURL(context, csarUrl, format, "")
}

func GetServiceTemplateURL(context contextpkg.Context, csarUrl exturl.URL, format string, serviceTemplateName string) (exturl.URL, error) {
func GetServiceTemplateURL(context contextpkg.Context, csarUrl exturl.URL, format string, serviceTemplateName string) (exturl.URL, exturl.URL, error) {
if format == "" {
format = csarUrl.Format()
}
Expand All @@ -38,10 +38,10 @@ func GetServiceTemplateURL(context contextpkg.Context, csarUrl exturl.URL, forma
if err != nil {
if exturl.IsNotFound(err) {
if meta, err = NewMetaFor(context, csarUrl, format); err != nil {
return nil, err
return nil, nil, err
}
} else {
return nil, err
return nil, nil, err
}
}

Expand All @@ -57,7 +57,7 @@ func GetServiceTemplateURL(context contextpkg.Context, csarUrl exturl.URL, forma
if path, err := GetRootPath(context, csarUrl, format); err == nil {
return NewURL(csarUrl, format, path)
} else {
return nil, err
return nil, nil, err
}
} else {
// Alternative entry points
Expand All @@ -77,5 +77,5 @@ func GetServiceTemplateURL(context contextpkg.Context, csarUrl exturl.URL, forma
}
}

return nil, fmt.Errorf("CSAR does not have service template %q: %s", serviceTemplateName, csarUrl.String())
return nil, nil, fmt.Errorf("CSAR does not have service template %q: %s", serviceTemplateName, csarUrl.String())
}
20 changes: 11 additions & 9 deletions tosca/grammars/tosca_v2_0/artifact-definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tosca_v2_0

import (
contextpkg "context"
"path"
"strings"

"github.com/tliron/exturl"
Expand Down Expand Up @@ -74,20 +75,21 @@ func (self *ArtifactDefinition) GetURL(context contextpkg.Context) exturl.URL {
}

if self.url == nil {
if self.Repository != nil {
if (self.Context.RepositoryURL != nil) && path.IsAbs(*self.File) {
// Absolute paths are relative to the implicit repository
path := (*self.File)[1:]
self.url = self.Context.RepositoryURL.Relative(path)
} else if self.Repository != nil {
if url := self.Repository.GetURL(); url != nil {
self.url = url.Relative(*self.File)
}
} else {
base := self.Context.URL.Base()
bases := []exturl.URL{base}
var err error
if self.url, err = base.Context().NewValidAnyOrFileURL(context, *self.File, bases); err != nil {
// Avoid reporting more than once
if !self.urlProblemReported {
self.Context.ReportError(err)
self.urlProblemReported = true
}
if url, err := base.Context().NewValidAnyOrFileURL(context, *self.File, []exturl.URL{base}); err == nil {
self.url = url
} else if !self.urlProblemReported { // avoid reporting more than once
self.Context.ReportError(err)
self.urlProblemReported = true
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions tosca/grammars/tosca_v2_0/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ func (self *Artifact) Normalize(normalNodeTemplate *normal.NodeTemplate) *normal
if self.File != nil {
normalArtifact.Filename = filepath.Base(*self.File)
}
url := self.GetURL(contextpkg.TODO())
if url != nil {
if url := self.GetURL(contextpkg.TODO()); url != nil {
normalArtifact.SourcePath = url.String()
}
if self.DeployPath != nil {
Expand Down
6 changes: 4 additions & 2 deletions tosca/parser/phase1-read.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ func (self *Context) read(context contextpkg.Context, promise util.Promise, pars

// TODO: allow override of CSAR format
if format := parsingContext.URL.Format(); csar.IsValidFormat(format) {
var err error
if parsingContext.URL, err = csar.GetServiceTemplateURL(context, parsingContext.URL, format, serviceTemplateName); err != nil {
if url, repositoryUrl, err := csar.GetServiceTemplateURL(context, parsingContext.URL, format, serviceTemplateName); err == nil {
parsingContext.URL = url
parsingContext.RepositoryURL = repositoryUrl
} else {
parsingContext.ReportError(err)
file := NewEmptyFile(parsingContext, container, nameTransformer)
self.AddFile(file)
Expand Down
Loading

0 comments on commit 6fbd39c

Please sign in to comment.