From 5237910fe450bcf68d6d3a87f675050a1474a285 Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Tue, 1 Oct 2024 18:12:48 +0200 Subject: [PATCH 1/9] move tests --- .github/workflows/test.yml | 4 ++-- {helm/examples/go => tests}/.gitattributes | 0 {helm/examples/go => tests}/.gitignore | 0 {helm/examples/go => tests}/dagger.json | 2 +- {helm/examples/go => tests}/go.mod | 0 {helm/examples/go => tests}/go.sum | 0 {helm/examples/go => tests}/main.go | 0 {helm/examples/go => tests}/testdata/mychart/.helmignore | 0 {helm/examples/go => tests}/testdata/mychart/Chart.yaml | 0 .../go => tests}/testdata/mychart/templates/NOTES.txt | 0 .../go => tests}/testdata/mychart/templates/_helpers.tpl | 0 .../go => tests}/testdata/mychart/templates/deployment.yaml | 0 .../examples/go => tests}/testdata/mychart/templates/hpa.yaml | 0 .../go => tests}/testdata/mychart/templates/ingress.yaml | 0 .../go => tests}/testdata/mychart/templates/service.yaml | 0 .../testdata/mychart/templates/serviceaccount.yaml | 0 .../testdata/mychart/templates/tests/test-connection.yaml | 0 .../go => tests}/testdata/mychart/tests/deployment_test.yaml | 0 {helm/examples/go => tests}/testdata/mychart/values.yaml | 0 19 files changed, 3 insertions(+), 3 deletions(-) rename {helm/examples/go => tests}/.gitattributes (100%) rename {helm/examples/go => tests}/.gitignore (100%) rename {helm/examples/go => tests}/dagger.json (83%) rename {helm/examples/go => tests}/go.mod (100%) rename {helm/examples/go => tests}/go.sum (100%) rename {helm/examples/go => tests}/main.go (100%) rename {helm/examples/go => tests}/testdata/mychart/.helmignore (100%) rename {helm/examples/go => tests}/testdata/mychart/Chart.yaml (100%) rename {helm/examples/go => tests}/testdata/mychart/templates/NOTES.txt (100%) rename {helm/examples/go => tests}/testdata/mychart/templates/_helpers.tpl (100%) rename {helm/examples/go => tests}/testdata/mychart/templates/deployment.yaml (100%) rename {helm/examples/go => tests}/testdata/mychart/templates/hpa.yaml (100%) rename {helm/examples/go => tests}/testdata/mychart/templates/ingress.yaml (100%) rename {helm/examples/go => tests}/testdata/mychart/templates/service.yaml (100%) rename {helm/examples/go => tests}/testdata/mychart/templates/serviceaccount.yaml (100%) rename {helm/examples/go => tests}/testdata/mychart/templates/tests/test-connection.yaml (100%) rename {helm/examples/go => tests}/testdata/mychart/tests/deployment_test.yaml (100%) rename {helm/examples/go => tests}/testdata/mychart/values.yaml (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 288e9aa..f7ffb79 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: - name: Display module functions run: dagger functions -m helm/ - name: Run module tests - run: dagger -m helm/examples/go call all + run: dagger -m tests/ call all - name: Run module integration tests env: TEST_HELM_REGISTRY_URL: ${{ secrets.TEST_HELM_REGISTRY_URL }} @@ -26,7 +26,7 @@ jobs: TEST_HELM_REGISTRY_HELM_USER: ${{ secrets.TEST_HELM_REGISTRY_HELM_USER }} TEST_HELM_REGISTRY_HELM_PASSWORD: ${{ secrets.TEST_HELM_REGISTRY_HELM_PASSWORD }} run: | - dagger -m helm/examples/go \ + dagger -m tests/ \ call helm-packagepush \ --registry ${TEST_HELM_REGISTRY_URL} \ --repository ${TEST_HELM_REGISTRY_REPOSITORY} \ diff --git a/helm/examples/go/.gitattributes b/tests/.gitattributes similarity index 100% rename from helm/examples/go/.gitattributes rename to tests/.gitattributes diff --git a/helm/examples/go/.gitignore b/tests/.gitignore similarity index 100% rename from helm/examples/go/.gitignore rename to tests/.gitignore diff --git a/helm/examples/go/dagger.json b/tests/dagger.json similarity index 83% rename from helm/examples/go/dagger.json rename to tests/dagger.json index 689cdfd..2e2cf12 100644 --- a/helm/examples/go/dagger.json +++ b/tests/dagger.json @@ -4,7 +4,7 @@ "dependencies": [ { "name": "helm", - "source": "../.." + "source": "../helm/" } ], "source": ".", diff --git a/helm/examples/go/go.mod b/tests/go.mod similarity index 100% rename from helm/examples/go/go.mod rename to tests/go.mod diff --git a/helm/examples/go/go.sum b/tests/go.sum similarity index 100% rename from helm/examples/go/go.sum rename to tests/go.sum diff --git a/helm/examples/go/main.go b/tests/main.go similarity index 100% rename from helm/examples/go/main.go rename to tests/main.go diff --git a/helm/examples/go/testdata/mychart/.helmignore b/tests/testdata/mychart/.helmignore similarity index 100% rename from helm/examples/go/testdata/mychart/.helmignore rename to tests/testdata/mychart/.helmignore diff --git a/helm/examples/go/testdata/mychart/Chart.yaml b/tests/testdata/mychart/Chart.yaml similarity index 100% rename from helm/examples/go/testdata/mychart/Chart.yaml rename to tests/testdata/mychart/Chart.yaml diff --git a/helm/examples/go/testdata/mychart/templates/NOTES.txt b/tests/testdata/mychart/templates/NOTES.txt similarity index 100% rename from helm/examples/go/testdata/mychart/templates/NOTES.txt rename to tests/testdata/mychart/templates/NOTES.txt diff --git a/helm/examples/go/testdata/mychart/templates/_helpers.tpl b/tests/testdata/mychart/templates/_helpers.tpl similarity index 100% rename from helm/examples/go/testdata/mychart/templates/_helpers.tpl rename to tests/testdata/mychart/templates/_helpers.tpl diff --git a/helm/examples/go/testdata/mychart/templates/deployment.yaml b/tests/testdata/mychart/templates/deployment.yaml similarity index 100% rename from helm/examples/go/testdata/mychart/templates/deployment.yaml rename to tests/testdata/mychart/templates/deployment.yaml diff --git a/helm/examples/go/testdata/mychart/templates/hpa.yaml b/tests/testdata/mychart/templates/hpa.yaml similarity index 100% rename from helm/examples/go/testdata/mychart/templates/hpa.yaml rename to tests/testdata/mychart/templates/hpa.yaml diff --git a/helm/examples/go/testdata/mychart/templates/ingress.yaml b/tests/testdata/mychart/templates/ingress.yaml similarity index 100% rename from helm/examples/go/testdata/mychart/templates/ingress.yaml rename to tests/testdata/mychart/templates/ingress.yaml diff --git a/helm/examples/go/testdata/mychart/templates/service.yaml b/tests/testdata/mychart/templates/service.yaml similarity index 100% rename from helm/examples/go/testdata/mychart/templates/service.yaml rename to tests/testdata/mychart/templates/service.yaml diff --git a/helm/examples/go/testdata/mychart/templates/serviceaccount.yaml b/tests/testdata/mychart/templates/serviceaccount.yaml similarity index 100% rename from helm/examples/go/testdata/mychart/templates/serviceaccount.yaml rename to tests/testdata/mychart/templates/serviceaccount.yaml diff --git a/helm/examples/go/testdata/mychart/templates/tests/test-connection.yaml b/tests/testdata/mychart/templates/tests/test-connection.yaml similarity index 100% rename from helm/examples/go/testdata/mychart/templates/tests/test-connection.yaml rename to tests/testdata/mychart/templates/tests/test-connection.yaml diff --git a/helm/examples/go/testdata/mychart/tests/deployment_test.yaml b/tests/testdata/mychart/tests/deployment_test.yaml similarity index 100% rename from helm/examples/go/testdata/mychart/tests/deployment_test.yaml rename to tests/testdata/mychart/tests/deployment_test.yaml diff --git a/helm/examples/go/testdata/mychart/values.yaml b/tests/testdata/mychart/values.yaml similarity index 100% rename from helm/examples/go/testdata/mychart/values.yaml rename to tests/testdata/mychart/values.yaml From 1b0e6fb9680e92e637dad9d26f87dbe1c88eb2ca Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Tue, 1 Oct 2024 18:14:29 +0200 Subject: [PATCH 2/9] init go example module --- helm/examples/go/.gitattributes | 4 ++ helm/examples/go/.gitignore | 4 ++ helm/examples/go/dagger.json | 5 +++ helm/examples/go/go.mod | 47 ++++++++++++++++++++ helm/examples/go/go.sum | 77 +++++++++++++++++++++++++++++++++ helm/examples/go/main.go | 37 ++++++++++++++++ 6 files changed, 174 insertions(+) create mode 100644 helm/examples/go/.gitattributes create mode 100644 helm/examples/go/.gitignore create mode 100644 helm/examples/go/dagger.json create mode 100644 helm/examples/go/go.mod create mode 100644 helm/examples/go/go.sum create mode 100644 helm/examples/go/main.go diff --git a/helm/examples/go/.gitattributes b/helm/examples/go/.gitattributes new file mode 100644 index 0000000..3a45493 --- /dev/null +++ b/helm/examples/go/.gitattributes @@ -0,0 +1,4 @@ +/dagger.gen.go linguist-generated +/internal/dagger/** linguist-generated +/internal/querybuilder/** linguist-generated +/internal/telemetry/** linguist-generated diff --git a/helm/examples/go/.gitignore b/helm/examples/go/.gitignore new file mode 100644 index 0000000..7ebabcc --- /dev/null +++ b/helm/examples/go/.gitignore @@ -0,0 +1,4 @@ +/dagger.gen.go +/internal/dagger +/internal/querybuilder +/internal/telemetry diff --git a/helm/examples/go/dagger.json b/helm/examples/go/dagger.json new file mode 100644 index 0000000..afdd13b --- /dev/null +++ b/helm/examples/go/dagger.json @@ -0,0 +1,5 @@ +{ + "name": "go", + "sdk": "go", + "engineVersion": "v0.13.3" +} diff --git a/helm/examples/go/go.mod b/helm/examples/go/go.mod new file mode 100644 index 0000000..37328e5 --- /dev/null +++ b/helm/examples/go/go.mod @@ -0,0 +1,47 @@ +module dagger/go + +go 1.23.1 + +require ( + github.com/99designs/gqlgen v0.17.49 + github.com/Khan/genqlient v0.7.0 + github.com/vektah/gqlparser/v2 v2.5.16 + go.opentelemetry.io/otel v1.27.0 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 + go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 + go.opentelemetry.io/otel/log v0.3.0 + go.opentelemetry.io/otel/sdk v1.27.0 + go.opentelemetry.io/otel/sdk/log v0.3.0 + go.opentelemetry.io/otel/trace v1.27.0 + go.opentelemetry.io/proto/otlp v1.3.1 + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa + golang.org/x/sync v0.8.0 + google.golang.org/grpc v1.65.0 +) + +require ( + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect + github.com/sosodev/duration v1.3.1 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect + go.opentelemetry.io/otel/metric v1.27.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/protobuf v1.34.2 // indirect +) + +replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 + +replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 + +replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.3.0 + +replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.3.0 diff --git a/helm/examples/go/go.sum b/helm/examples/go/go.sum new file mode 100644 index 0000000..f6bb539 --- /dev/null +++ b/helm/examples/go/go.sum @@ -0,0 +1,77 @@ +github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ= +github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0= +github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w= +github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +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/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= +github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8= +github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww= +go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= +go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88/go.mod h1:JGG8ebaMO5nXOPnvKEl+DiA4MGwFjCbjsxT1WHIEBPY= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 h1:ccBrA8nCY5mM0y5uO7FT0ze4S0TuFcWdDB2FxGMTjkI= +go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0/go.mod h1:/9pb6634zi2Lk8LYg9Q0X8Ar6jka4dkFOylBLbVQPCE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 h1:qFffATk0X+HD+f1Z8lswGiOQYKHRlzfmdJm0wEaVrFA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0/go.mod h1:MOiCmryaYtc+V0Ei+Tx9o5S1ZjA7kzLucuVuyzBZloQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY= +go.opentelemetry.io/otel/log v0.3.0 h1:kJRFkpUFYtny37NQzL386WbznUByZx186DpEMKhEGZs= +go.opentelemetry.io/otel/log v0.3.0/go.mod h1:ziCwqZr9soYDwGNbIL+6kAvQC+ANvjgG367HVcyR/ys= +go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= +go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= +go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kTWmI= +go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A= +go.opentelemetry.io/otel/sdk/log v0.3.0 h1:GEjJ8iftz2l+XO1GF2856r7yYVh74URiF9JMcAacr5U= +go.opentelemetry.io/otel/sdk/log v0.3.0/go.mod h1:BwCxtmux6ACLuys1wlbc0+vGBd+xytjmjajwqqIul2g= +go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= +go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= +go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= +go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/helm/examples/go/main.go b/helm/examples/go/main.go new file mode 100644 index 0000000..d120107 --- /dev/null +++ b/helm/examples/go/main.go @@ -0,0 +1,37 @@ +// A generated module for Go functions +// +// This module has been generated via dagger init and serves as a reference to +// basic module structure as you get started with Dagger. +// +// Two functions have been pre-created. You can modify, delete, or add to them, +// as needed. They demonstrate usage of arguments and return types using simple +// echo and grep commands. The functions can be called from the dagger CLI or +// from one of the SDKs. +// +// The first line in this comment block is a short description line and the +// rest is a long description with more detail on the module's purpose or usage, +// if appropriate. All modules should have a short description. + +package main + +import ( + "context" + "dagger/go/internal/dagger" +) + +type Go struct{} + +// Returns a container that echoes whatever string argument is provided +func (m *Go) ContainerEcho(stringArg string) *dagger.Container { + return dag.Container().From("alpine:latest").WithExec([]string{"echo", stringArg}) +} + +// Returns lines that match a pattern in the files of the provided Directory +func (m *Go) GrepDir(ctx context.Context, directoryArg *dagger.Directory, pattern string) (string, error) { + return dag.Container(). + From("alpine:latest"). + WithMountedDirectory("/mnt", directoryArg). + WithWorkdir("/mnt"). + WithExec([]string{"grep", "-R", pattern, "."}). + Stdout(ctx) +} From 0a6987e9636a3171b3bea63520fa43e03006ba98 Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Tue, 1 Oct 2024 18:49:14 +0200 Subject: [PATCH 3/9] better Version examples --- .github/workflows/test.yml | 4 +- helm/examples/go/dagger.json | 7 +++ helm/examples/go/main.go | 82 +++++++++++++++++++++--------- helm/examples/shell/HelmVersion.sh | 3 ++ 4 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 helm/examples/shell/HelmVersion.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f7ffb79..191d077 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Dagger CLI run: cd /usr/local && { curl -L https://dl.dagger.io/dagger/install.sh | sh; cd -; } - - name: Display module functions + - name: Display Helm module functions run: dagger functions -m helm/ - name: Run module tests run: dagger -m tests/ call all @@ -32,3 +32,5 @@ jobs: --repository ${TEST_HELM_REGISTRY_REPOSITORY} \ --username ${TEST_HELM_REGISTRY_HELM_USER} \ --password env:TEST_HELM_REGISTRY_HELM_PASSWORD + - name: Display go examples module functions + run: dagger -m helm/examples/go/ functions diff --git a/helm/examples/go/dagger.json b/helm/examples/go/dagger.json index afdd13b..7f5c7cb 100644 --- a/helm/examples/go/dagger.json +++ b/helm/examples/go/dagger.json @@ -1,5 +1,12 @@ { "name": "go", "sdk": "go", + "dependencies": [ + { + "name": "helm", + "source": "../.." + } + ], + "source": ".", "engineVersion": "v0.13.3" } diff --git a/helm/examples/go/main.go b/helm/examples/go/main.go index d120107..1aae420 100644 --- a/helm/examples/go/main.go +++ b/helm/examples/go/main.go @@ -1,16 +1,6 @@ -// A generated module for Go functions +// Go examples for the Helm module. // -// This module has been generated via dagger init and serves as a reference to -// basic module structure as you get started with Dagger. -// -// Two functions have been pre-created. You can modify, delete, or add to them, -// as needed. They demonstrate usage of arguments and return types using simple -// echo and grep commands. The functions can be called from the dagger CLI or -// from one of the SDKs. -// -// The first line in this comment block is a short description line and the -// rest is a long description with more detail on the module's purpose or usage, -// if appropriate. All modules should have a short description. +// This module defines the examples for the Daggerverse. package main @@ -21,17 +11,63 @@ import ( type Go struct{} -// Returns a container that echoes whatever string argument is provided -func (m *Go) ContainerEcho(stringArg string) *dagger.Container { - return dag.Container().From("alpine:latest").WithExec([]string{"echo", stringArg}) +func (h *Go) HelmPackagepush( + // method call context + ctx context.Context, + // URL of the registry + registry string, + // name of the repository + repository string, + // registry login username + username string, + // registry login password + password *dagger.Secret, +) error { + // dagger call package-push \ + // --registry registry.puzzle.ch \ + // --repository helm \ + // --username $REGISTRY_HELM_USER \ + // --password env:REGISTRY_HELM_PASSWORD \ + // --directory ./examples/testdata/mychart/ + + // directory that contains the Helm Chart + directory := dag.CurrentModule().Source().Directory("./testdata/mychart/") + _, err := dag.Helm().PackagePush(ctx, directory, registry, repository, username, password) + + if err != nil { + return err + } + + return nil +} + +func (m *Go) HelmTest( + // method call context + ctx context.Context, +) error { + args := []string{"."} + + // dagger call test --directory ./examples/testdata/mychart/ --args "." + directory := dag.CurrentModule().Source().Directory("./testdata/mychart/") + _, err := dag.Helm().Test(ctx, directory, args) + + if err != nil { + return err + } + + return nil } -// Returns lines that match a pattern in the files of the provided Directory -func (m *Go) GrepDir(ctx context.Context, directoryArg *dagger.Directory, pattern string) (string, error) { - return dag.Container(). - From("alpine:latest"). - WithMountedDirectory("/mnt", directoryArg). - WithWorkdir("/mnt"). - WithExec([]string{"grep", "-R", pattern, "."}). - Stdout(ctx) +// Example on how to call the Version method. +// +// Get and display the version of the Helm Chart located inside the directory referenced by the chart parameter. +func (m *Go) HelmVersion( + // method call context + ctx context.Context, + // directory that contains the Helm Chart, e.g. "./tests/testdata/mychart/" + chart *dagger.Directory, +) (string, error) { + return dag. + Helm(). + Version(ctx, chart) } diff --git a/helm/examples/shell/HelmVersion.sh b/helm/examples/shell/HelmVersion.sh new file mode 100644 index 0000000..e1aeca0 --- /dev/null +++ b/helm/examples/shell/HelmVersion.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +dagger call version --directory ./examples/testdata/mychart/ From 8714a0264329dd2b4b5c41d787347c04d251955f Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Thu, 31 Oct 2024 09:47:12 +0100 Subject: [PATCH 4/9] rename go examples module to Examples --- helm/examples/go/dagger.json | 4 ++-- helm/examples/go/go.mod | 15 +++++++++------ helm/examples/go/go.sum | 18 ++++++++++++------ helm/examples/go/main.go | 10 +++++----- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/helm/examples/go/dagger.json b/helm/examples/go/dagger.json index 7f5c7cb..36307d9 100644 --- a/helm/examples/go/dagger.json +++ b/helm/examples/go/dagger.json @@ -1,5 +1,5 @@ { - "name": "go", + "name": "Examples", "sdk": "go", "dependencies": [ { @@ -8,5 +8,5 @@ } ], "source": ".", - "engineVersion": "v0.13.3" + "engineVersion": "v0.13.6" } diff --git a/helm/examples/go/go.mod b/helm/examples/go/go.mod index 37328e5..e3b82f2 100644 --- a/helm/examples/go/go.mod +++ b/helm/examples/go/go.mod @@ -1,19 +1,23 @@ -module dagger/go +module dagger/examples -go 1.23.1 +go 1.23.2 require ( - github.com/99designs/gqlgen v0.17.49 + github.com/99designs/gqlgen v0.17.55 github.com/Khan/genqlient v0.7.0 - github.com/vektah/gqlparser/v2 v2.5.16 + github.com/vektah/gqlparser/v2 v2.5.17 go.opentelemetry.io/otel v1.27.0 go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 go.opentelemetry.io/otel/log v0.3.0 + go.opentelemetry.io/otel/metric v1.27.0 go.opentelemetry.io/otel/sdk v1.27.0 go.opentelemetry.io/otel/sdk/log v0.3.0 + go.opentelemetry.io/otel/sdk/metric v1.27.0 go.opentelemetry.io/otel/trace v1.27.0 go.opentelemetry.io/proto/otlp v1.3.1 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa @@ -29,9 +33,8 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect github.com/sosodev/duration v1.3.1 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect - go.opentelemetry.io/otel/metric v1.27.0 // indirect golang.org/x/net v0.29.0 // indirect - golang.org/x/sys v0.25.0 // indirect + golang.org/x/sys v0.26.0 // indirect golang.org/x/text v0.18.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect diff --git a/helm/examples/go/go.sum b/helm/examples/go/go.sum index f6bb539..c52dd24 100644 --- a/helm/examples/go/go.sum +++ b/helm/examples/go/go.sum @@ -1,5 +1,5 @@ -github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ= -github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0= +github.com/99designs/gqlgen v0.17.55 h1:3vzrNWYyzSZjGDFo68e5j9sSauLxfKvLp+6ioRokVtM= +github.com/99designs/gqlgen v0.17.55/go.mod h1:3Bq768f8hgVPGZxL8aY9MaYmbxa6llPM/qu1IGH1EJo= github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w= github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= @@ -27,14 +27,18 @@ github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8= -github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww= +github.com/vektah/gqlparser/v2 v2.5.17 h1:9At7WblLV7/36nulgekUgIaqHZWn5hxqluxrxGUhOmI= +github.com/vektah/gqlparser/v2 v2.5.17/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww= go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4= go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88/go.mod h1:JGG8ebaMO5nXOPnvKEl+DiA4MGwFjCbjsxT1WHIEBPY= go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 h1:ccBrA8nCY5mM0y5uO7FT0ze4S0TuFcWdDB2FxGMTjkI= go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0/go.mod h1:/9pb6634zi2Lk8LYg9Q0X8Ar6jka4dkFOylBLbVQPCE= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0 h1:bFgvUr3/O4PHj3VQcFEuYKvRZJX1SJDQ+11JXuSB3/w= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0/go.mod h1:xJntEd2KL6Qdg5lwp97HMLQDVeAhrYxmzFseAMDPQ8I= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 h1:CIHWikMsN3wO+wq1Tp5VGdVRTcON+DmOJSfDjXypKOc= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0/go.mod h1:TNupZ6cxqyFEpLXAZW7On+mLFL0/g0TE3unIYL91xWc= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 h1:qFffATk0X+HD+f1Z8lswGiOQYKHRlzfmdJm0wEaVrFA= @@ -49,6 +53,8 @@ go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kT go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A= go.opentelemetry.io/otel/sdk/log v0.3.0 h1:GEjJ8iftz2l+XO1GF2856r7yYVh74URiF9JMcAacr5U= go.opentelemetry.io/otel/sdk/log v0.3.0/go.mod h1:BwCxtmux6ACLuys1wlbc0+vGBd+xytjmjajwqqIul2g= +go.opentelemetry.io/otel/sdk/metric v1.27.0 h1:5uGNOlpXi+Hbo/DRoI31BSb1v+OGcpv2NemcCrOL8gI= +go.opentelemetry.io/otel/sdk/metric v1.27.0/go.mod h1:we7jJVrYN2kh3mVBlswtPU22K0SA+769l93J6bsyvqw= go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= @@ -61,8 +67,8 @@ golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= diff --git a/helm/examples/go/main.go b/helm/examples/go/main.go index 1aae420..900ad02 100644 --- a/helm/examples/go/main.go +++ b/helm/examples/go/main.go @@ -6,12 +6,12 @@ package main import ( "context" - "dagger/go/internal/dagger" + "dagger/examples/internal/dagger" ) -type Go struct{} +type Examples struct{} -func (h *Go) HelmPackagepush( +func (h *Examples) HelmPackagepush( // method call context ctx context.Context, // URL of the registry @@ -41,7 +41,7 @@ func (h *Go) HelmPackagepush( return nil } -func (m *Go) HelmTest( +func (m *Examples) HelmTest( // method call context ctx context.Context, ) error { @@ -61,7 +61,7 @@ func (m *Go) HelmTest( // Example on how to call the Version method. // // Get and display the version of the Helm Chart located inside the directory referenced by the chart parameter. -func (m *Go) HelmVersion( +func (m *Examples) HelmVersion( // method call context ctx context.Context, // directory that contains the Helm Chart, e.g. "./tests/testdata/mychart/" From a4704b07c5534e39016a4d4f1f19aacf4f7e03be Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Thu, 14 Nov 2024 20:45:58 +0100 Subject: [PATCH 5/9] nicefy version examples --- helm/examples/go/main.go | 11 ++--------- helm/examples/shell/HelmVersion.sh | 3 --- helm/examples/shell/examples.sh | 11 +++++++++++ helm/main.go | 4 ++-- tests/main.go | 12 ------------ 5 files changed, 15 insertions(+), 26 deletions(-) delete mode 100644 helm/examples/shell/HelmVersion.sh create mode 100755 helm/examples/shell/examples.sh diff --git a/helm/examples/go/main.go b/helm/examples/go/main.go index 900ad02..1302a40 100644 --- a/helm/examples/go/main.go +++ b/helm/examples/go/main.go @@ -23,13 +23,6 @@ func (h *Examples) HelmPackagepush( // registry login password password *dagger.Secret, ) error { - // dagger call package-push \ - // --registry registry.puzzle.ch \ - // --repository helm \ - // --username $REGISTRY_HELM_USER \ - // --password env:REGISTRY_HELM_PASSWORD \ - // --directory ./examples/testdata/mychart/ - // directory that contains the Helm Chart directory := dag.CurrentModule().Source().Directory("./testdata/mychart/") _, err := dag.Helm().PackagePush(ctx, directory, registry, repository, username, password) @@ -60,11 +53,11 @@ func (m *Examples) HelmTest( // Example on how to call the Version method. // -// Get and display the version of the Helm Chart located inside the directory referenced by the chart parameter. +// Get and display the version of the Helm Chart located inside the directory referenced by the directory parameter. func (m *Examples) HelmVersion( // method call context ctx context.Context, - // directory that contains the Helm Chart, e.g. "./tests/testdata/mychart/" + // directory that contains the Helm Chart, e.g. "./helm/examples/testdata/mychart/" chart *dagger.Directory, ) (string, error) { return dag. diff --git a/helm/examples/shell/HelmVersion.sh b/helm/examples/shell/HelmVersion.sh deleted file mode 100644 index e1aeca0..0000000 --- a/helm/examples/shell/HelmVersion.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -dagger call version --directory ./examples/testdata/mychart/ diff --git a/helm/examples/shell/examples.sh b/helm/examples/shell/examples.sh new file mode 100755 index 0000000..17c1f62 --- /dev/null +++ b/helm/examples/shell/examples.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +################################################# +# Example on how to call the Version method. +# Get and display the version of the Helm Chart located inside the directory referenced by the directory parameter. +################################################# +function helm_version() { + dagger -m helm/ \ + call version \ + --directory ./helm/examples/testdata/mychart/ # directory that contains the Helm Chart +} diff --git a/helm/main.go b/helm/main.go index 69c2558..9532292 100644 --- a/helm/main.go +++ b/helm/main.go @@ -42,7 +42,7 @@ func (p PushOpts) getRepoFqdn() string { // Get and display the version of the Helm Chart located inside the given directory. // -// Example usage: dagger call version --directory ./examples/testdata/mychart/ +// Example usage: dagger call version -directory ./helm/examples/testdata/mychart/ func (h *Helm) Version( // method call context ctx context.Context, @@ -158,7 +158,7 @@ func (h *Helm) PackagePush( // Provide the helm chart directory with pointing to it with the `--directory` flag. // Add the directory location with `"."` as `--args` parameter to tell helm unittest where to find the helm chart with the tests. // -// Example usage: dagger call test --directory ./examples/testdata/mychart/ --args "." +// Example usage: dagger call test --directory ./helm/examples/testdata/mychart/ --args "." func (h *Helm) Test( // method call context ctx context.Context, diff --git a/tests/main.go b/tests/main.go index 5c3e81c..05adefc 100644 --- a/tests/main.go +++ b/tests/main.go @@ -1,4 +1,3 @@ - package main import ( @@ -26,8 +25,6 @@ func (m *Go) HelmVersion( ctx context.Context, ) error { const expected = "0.1.1" - - // dagger call version --directory ./examples/testdata/mychart/ directory := dag.CurrentModule().Source().Directory("./testdata/mychart/") version, err := dag.Helm().Version(ctx, directory) @@ -54,13 +51,6 @@ func (h *Go) HelmPackagepush( // registry login password password *dagger.Secret, ) error { - // dagger call package-push \ - // --registry registry.puzzle.ch \ - // --repository helm \ - // --username $REGISTRY_HELM_USER \ - // --password env:REGISTRY_HELM_PASSWORD \ - // --directory ./examples/testdata/mychart/ - // directory that contains the Helm Chart directory := dag.CurrentModule().Source().Directory("./testdata/mychart/") _, err := dag.Helm().PackagePush(ctx, directory, registry, repository, username, password) @@ -77,8 +67,6 @@ func (m *Go) HelmTest( ctx context.Context, ) error { args := []string{"."} - - // dagger call test --directory ./examples/testdata/mychart/ --args "." directory := dag.CurrentModule().Source().Directory("./testdata/mychart/") _, err := dag.Helm().Test(ctx, directory, args) From ceb0766b9d9f7342ab4c5daee3e68c562f7c3dc6 Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Thu, 14 Nov 2024 21:33:16 +0100 Subject: [PATCH 6/9] nicefy test examples --- helm/examples/go/main.go | 30 +++++++++++++++++------------- helm/examples/shell/examples.sh | 24 +++++++++++++++++++++++- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/helm/examples/go/main.go b/helm/examples/go/main.go index 1302a40..b719e2d 100644 --- a/helm/examples/go/main.go +++ b/helm/examples/go/main.go @@ -34,26 +34,30 @@ func (h *Examples) HelmPackagepush( return nil } -func (m *Examples) HelmTest( +// Example on how to call the Test method. +// +// Run the unit tests for the Helm Chart located inside the directory referenced by the directory parameter. +// Add the directory location with `"."` as `--args` parameter to tell helm unittest where to find the tests inside the passed directory. +// +// Return: The Helm unit test output as string. +func (h *Examples) HelmTest( // method call context ctx context.Context, -) error { - args := []string{"."} - - // dagger call test --directory ./examples/testdata/mychart/ --args "." - directory := dag.CurrentModule().Source().Directory("./testdata/mychart/") - _, err := dag.Helm().Test(ctx, directory, args) - - if err != nil { - return err - } - - return nil + // directory that contains the Helm Chart, e.g. "./helm/examples/testdata/mychart/" + directory *dagger.Directory, + // Helm Unittest arguments, e.g. "." to reference the Helm Chart root directory inside the passed directory. + args []string, +) (string, error) { + return dag. + Helm(). + Test(ctx, directory, args) } // Example on how to call the Version method. // // Get and display the version of the Helm Chart located inside the directory referenced by the directory parameter. +// +// Return: The Helm Chart version as string. func (m *Examples) HelmVersion( // method call context ctx context.Context, diff --git a/helm/examples/shell/examples.sh b/helm/examples/shell/examples.sh index 17c1f62..4dd69ac 100755 --- a/helm/examples/shell/examples.sh +++ b/helm/examples/shell/examples.sh @@ -1,11 +1,33 @@ #!/bin/sh +################################################# +# Example on how to call the Test method. +# Run the unit tests for the Helm Chart located inside the directory referenced by the directory parameter. +# Add the directory location with `"."` as `--args` parameter to tell helm unittest where to find the tests inside the passed directory. +# ARGUMENTS: +# directory: directory that contains the Helm Chart +# args: arguments for the helm test command +# RETURN: +# The Helm unit test output as string. +################################################# +function helm_test() { + dagger -m helm/ \ + call test \ + --directory ./helm/examples/testdata/mychart/ \ + --args "." +} + + ################################################# # Example on how to call the Version method. # Get and display the version of the Helm Chart located inside the directory referenced by the directory parameter. +# ARGUMENTS: +# directory: directory that contains the Helm Chart +# RETURN: +# The Helm Chart version as string. ################################################# function helm_version() { dagger -m helm/ \ call version \ - --directory ./helm/examples/testdata/mychart/ # directory that contains the Helm Chart + --directory ./helm/examples/testdata/mychart/ } From bef933f8557492e80d2309d1e5065bc7b8e17a6d Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Thu, 14 Nov 2024 21:58:27 +0100 Subject: [PATCH 7/9] nicefy package push examples --- helm/examples/go/main.go | 21 +++++++++++---------- helm/examples/shell/examples.sh | 24 +++++++++++++++++++++++- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/helm/examples/go/main.go b/helm/examples/go/main.go index b719e2d..f517097 100644 --- a/helm/examples/go/main.go +++ b/helm/examples/go/main.go @@ -11,9 +11,16 @@ import ( type Examples struct{} + +// Example on how to call the PackagePush method. +// Packages and pushes a Helm chart to a specified OCI-compatible registry with authentication. +// +// Return: true if the chart was successfully pushed, or false if the chart already exists, with error handling for push failures. func (h *Examples) HelmPackagepush( // method call context ctx context.Context, + // directory that contains the Helm Chart + directory *dagger.Directory, // URL of the registry registry string, // name of the repository @@ -22,16 +29,10 @@ func (h *Examples) HelmPackagepush( username string, // registry login password password *dagger.Secret, -) error { - // directory that contains the Helm Chart - directory := dag.CurrentModule().Source().Directory("./testdata/mychart/") - _, err := dag.Helm().PackagePush(ctx, directory, registry, repository, username, password) - - if err != nil { - return err - } - - return nil +) (bool, error) { + return dag. + Helm(). + PackagePush(ctx, directory, registry, repository, username, password) } // Example on how to call the Test method. diff --git a/helm/examples/shell/examples.sh b/helm/examples/shell/examples.sh index 4dd69ac..ff5d879 100755 --- a/helm/examples/shell/examples.sh +++ b/helm/examples/shell/examples.sh @@ -1,5 +1,28 @@ #!/bin/sh +################################################# +# Example on how to call the PackagePush method. +# Packages and pushes a Helm chart to a specified OCI-compatible registry with authentication. +# ARGUMENTS: +# directory: directory that contains the Helm Chart +# registry: URL of the registry +# repository: name of the repository +# username: registry login username +# password: registry login password as a Dagger Secret +# RETURN: +# true if the chart was successfully pushed, or false if the chart already exists, with error handling for push failures. +################################################# +function helm_packagepush() { + dagger -m helm/ \ + call package-push \ + --directory ./helm/examples/testdata/mychart/ \ + --registry registry.puzzle.ch \ + --repository helm \ + --username registry-helm-user \ + --password env:REGISTRY_HELM_PASSWORD \ + --directory ./examples/testdata/mychart/ +} + ################################################# # Example on how to call the Test method. # Run the unit tests for the Helm Chart located inside the directory referenced by the directory parameter. @@ -17,7 +40,6 @@ function helm_test() { --args "." } - ################################################# # Example on how to call the Version method. # Get and display the version of the Helm Chart located inside the directory referenced by the directory parameter. From 3311831a6f8c3e26a0cb20853eea7a909feadaf4 Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Thu, 14 Nov 2024 22:05:57 +0100 Subject: [PATCH 8/9] test shell examples --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 191d077..65ef226 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,3 +34,8 @@ jobs: --password env:TEST_HELM_REGISTRY_HELM_PASSWORD - name: Display go examples module functions run: dagger -m helm/examples/go/ functions + - name: Test shell examples + run: | + source helm/examples/shell/examples.sh + helm_test + helm_version From 2ac39b630a5674754dcd8606a1a1cb805132f125 Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Thu, 14 Nov 2024 22:14:53 +0100 Subject: [PATCH 9/9] fix example --- helm/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/main.go b/helm/main.go index 9532292..a3263a0 100644 --- a/helm/main.go +++ b/helm/main.go @@ -42,7 +42,7 @@ func (p PushOpts) getRepoFqdn() string { // Get and display the version of the Helm Chart located inside the given directory. // -// Example usage: dagger call version -directory ./helm/examples/testdata/mychart/ +// Example usage: dagger call version --directory ./helm/examples/testdata/mychart/ func (h *Helm) Version( // method call context ctx context.Context,