From afd6526d3c8f93a3aafea4e8047758268b66b959 Mon Sep 17 00:00:00 2001 From: Nandor Magyar Date: Fri, 19 Apr 2024 17:40:27 +0200 Subject: [PATCH] chore(agent): use new docker types, go upgrade (#963) --- .github/workflows/builder_image_golang.yaml | 2 +- .github/workflows/product_builder.yaml | 14 +- .golangci.yml | 12 +- go.mod | 47 ++- go.sum | 113 +++-- golang/Makefile | 10 +- golang/api/v1/deploy.go | 214 +++------- golang/internal/config/config.go | 40 +- golang/internal/config/jwt_test.go | 2 +- golang/internal/dogger/dogger.go | 9 +- golang/internal/grpc/grpc.go | 21 +- golang/internal/helper/docker/container.go | 11 +- .../internal/helper/docker/container_test.go | 6 +- golang/internal/helper/image/image.go | 28 +- golang/internal/mapper/grpc.go | 18 +- golang/internal/mapper/grpc_test.go | 29 +- .../runtime/container/container_test.go | 31 +- golang/internal/util/array.go | 2 +- golang/internal/util/dotnet.go | 2 +- .../builder/container/container_builder.go | 72 ++-- .../container_builder_integration_test.go | 43 +- .../pkg/builder/container/docker_container.go | 2 +- golang/pkg/builder/container/exec_builder.go | 6 +- golang/pkg/builder/container/logger_test.go | 3 +- golang/pkg/builder/container/types.go | 69 +--- golang/pkg/builder/container/types_test.go | 56 --- golang/pkg/cli/config_file.go | 76 ++-- golang/pkg/cli/container_defaults.go | 25 +- golang/pkg/crane/config/config.go | 19 +- golang/pkg/crane/k8s/configmap.go | 3 +- golang/pkg/crane/k8s/delete_facade.go | 2 +- golang/pkg/crane/k8s/deploy_facade.go | 12 +- golang/pkg/crane/k8s/deployment.go | 18 +- golang/pkg/crane/k8s/ingress.go | 24 +- golang/pkg/crane/k8s/log.go | 5 +- golang/pkg/crane/k8s/namespace.go | 3 +- golang/pkg/crane/k8s/pvc.go | 2 +- golang/pkg/crane/k8s/secret.go | 2 +- golang/pkg/crane/k8s/service.go | 8 +- golang/pkg/crane/k8s/volume_helper.go | 2 +- golang/pkg/dagent/config/config.go | 23 +- golang/pkg/dagent/config/secret_test.go | 1 + golang/pkg/dagent/update/update.go | 26 +- golang/pkg/dagent/update/update_test.go | 17 +- golang/pkg/dagent/utils/container.go | 13 +- golang/pkg/dagent/utils/docker.go | 32 +- golang/pkg/dagent/utils/dockerhelper.go | 4 +- golang/pkg/dagent/utils/dockerhelper_test.go | 387 +++++++++--------- golang/pkg/dagent/utils/import_container.go | 4 +- golang/pkg/dagent/utils/init_container.go | 2 +- images/builder-golang/Dockerfile | 2 +- 51 files changed, 729 insertions(+), 845 deletions(-) delete mode 100644 golang/pkg/builder/container/types_test.go diff --git a/.github/workflows/builder_image_golang.yaml b/.github/workflows/builder_image_golang.yaml index 6471e5c6ac..ab29738382 100644 --- a/.github/workflows/builder_image_golang.yaml +++ b/.github/workflows/builder_image_golang.yaml @@ -12,7 +12,7 @@ permissions: env: GITHUB_REGISTRY: ghcr.io BUILDER_IMAGE_NAME: dyrector-io/dyrectorio/builder-images/golang - VERSION: 2 + VERSION: 3 jobs: build: runs-on: ubuntu-22.04 diff --git a/.github/workflows/product_builder.yaml b/.github/workflows/product_builder.yaml index 984193757b..59288134f1 100644 --- a/.github/workflows/product_builder.yaml +++ b/.github/workflows/product_builder.yaml @@ -52,7 +52,7 @@ jobs: runs-on: ubuntu-22.04 container: # yamlfmt resides here because alpine doesn't provide yamlfmt package - image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:2 + image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:3 steps: - name: Checkout uses: actions/checkout@v3 @@ -115,7 +115,7 @@ jobs: runs-on: ubuntu-22.04 needs: gather_changes container: - image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:2 + image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:3 defaults: run: working-directory: ${{ env.GOLANG_WORKING_DIRECTORY }} @@ -139,7 +139,7 @@ jobs: runs-on: ubuntu-22.04 needs: gather_changes container: - image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:2 + image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:3 defaults: run: working-directory: ${{ env.GOLANG_WORKING_DIRECTORY }} @@ -163,7 +163,7 @@ jobs: runs-on: ubuntu-22.04 needs: gather_changes container: - image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:2 + image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:3 defaults: run: working-directory: ${{ env.GOLANG_WORKING_DIRECTORY }} @@ -197,7 +197,7 @@ jobs: runs-on: ubuntu-22.04 needs: gather_changes container: - image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:2 + image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:3 defaults: run: working-directory: ${{ env.GOLANG_WORKING_DIRECTORY }} @@ -258,7 +258,7 @@ jobs: - go_integration - gather_changes container: - image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:2 + image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:3 defaults: run: working-directory: ${{ env.GOLANG_WORKING_DIRECTORY }} @@ -661,7 +661,7 @@ jobs: packages: write runs-on: ubuntu-22.04 container: - image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:2 + image: ghcr.io/dyrector-io/dyrectorio/builder-images/golang:3 defaults: run: working-directory: ${{ env.GOLANG_WORKING_DIRECTORY }} diff --git a/.golangci.yml b/.golangci.yml index 86b58953e9..55100744af 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,5 @@ run: timeout: 5m - skip-dirs: - - internal/cache linters-settings: depguard: rules: @@ -19,8 +17,6 @@ linters-settings: funlen: lines: 100 statements: 50 - gci: - local-prefixes: github.com/golangci/golangci-lint goconst: min-len: 2 min-occurrences: 2 @@ -50,22 +46,18 @@ linters-settings: - condition - return govet: - check-shadowing: true + enable-all: true lll: line-length: 140 - maligned: - suggest-new: true misspell: locale: US nolintlint: - allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space) allow-unused: false # report any unused nolint directives require-explanation: false # don't require an explanation for nolint directives require-specific: false # don't require nolint directives to be specific about which linter is being skipped tenv: all: true staticcheck: - go: "1.18" checks: - all linters: @@ -123,3 +115,5 @@ issues: - path: _test\.go linters: - gomnd + exclude-dirs: + - internal/cache diff --git a/go.mod b/go.mod index 2c176cdd7f..51485011ac 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/dyrector-io/dyrectorio -go 1.20 +go 1.21 require ( github.com/ProtonMail/gopenpgp/v2 v2.7.1 @@ -10,12 +10,12 @@ require ( github.com/ilyakaznacheev/cleanenv v1.4.2 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.29.1 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.9.0 github.com/thanhpk/randstr v1.0.5 github.com/urfave/cli/v2 v2.25.1 golang.org/x/exp v0.0.0-20230420155640-133eef4313cb - golang.org/x/net v0.17.0 - google.golang.org/grpc v1.56.3 + golang.org/x/net v0.23.0 + google.golang.org/grpc v1.63.0 google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.27.1 @@ -25,23 +25,35 @@ require ( require ( github.com/docker/distribution v2.8.2+incompatible - github.com/docker/docker v24.0.9+incompatible + github.com/docker/docker v26.0.2+incompatible github.com/docker/go-connections v0.4.0 github.com/google/go-containerregistry v0.15.1 - golang.org/x/sync v0.1.0 + golang.org/x/sync v0.6.0 ) require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect + github.com/containerd/log v0.1.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect - github.com/docker/cli v23.0.5+incompatible // indirect + github.com/distribution/reference v0.6.0 // indirect + github.com/docker/cli v26.0.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.7.0 // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/klauspost/compress v1.16.5 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/vbatts/tar-split v0.11.3 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 // indirect + go.opentelemetry.io/otel v1.25.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 // indirect + go.opentelemetry.io/otel/metric v1.25.0 // indirect + go.opentelemetry.io/otel/sdk v1.25.0 // indirect + go.opentelemetry.io/otel/trace v1.25.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect ) require ( @@ -63,14 +75,14 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/emicklei/go-restful/v3 v3.10.2 // indirect - github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/logr v1.4.1 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic v0.6.9 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 @@ -94,16 +106,15 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - golang.org/x/crypto v0.17.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/mod v0.10.0 // indirect - golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/term v0.15.0 // indirect + golang.org/x/oauth2 v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.8.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/appengine v1.6.8 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gotest.tools/v3 v3.4.0 // indirect diff --git a/go.sum b/go.sum index eb24d0c830..f83e114075 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,8 @@ github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx2 github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b h1:6+ZFm0flnudZzdSE0JxlhR2hKnGPcNB35BjQf4RYQDY= github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M= +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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -34,6 +36,8 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k= github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -41,15 +45,18 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHH github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/docker/cli v23.0.5+incompatible h1:ufWmAOuD3Vmr7JP2G5K3cyuNC4YZWiAsuDEvFVVDafE= -github.com/docker/cli v23.0.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/cli v26.0.2+incompatible h1:4C4U8ZqrlNDe/R1U1zFFX+YsCFiVUicJqo4WVdInJas= +github.com/docker/cli v26.0.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= -github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v26.0.2+incompatible h1:yGVmKUFGgcxA6PXWAokO0sQL22BrQ67cgVjko8tGdXE= +github.com/docker/docker v26.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -66,11 +73,17 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= +github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/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/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= @@ -78,6 +91,7 @@ github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -85,6 +99,7 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91 github.com/go-playground/validator/v10 v10.12.0 h1:E4gtWgxWxp8YSxExrQFv5BpCahla0PVF2oTTEYaWQGI= github.com/go-playground/validator/v10 v10.12.0/go.mod h1:hCAPuzYvKdP33pxWa+2+6AIKXEKqjIUyqsNCtbsSJrA= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -93,7 +108,6 @@ github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -106,8 +120,8 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -116,18 +130,22 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +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.15.1 h1:RsJ9NbfxYWF8Wl4VmvkpN3zYATwuvlPq2j20zmcs63E= github.com/google/go-containerregistry v0.15.1/go.mod h1:wWK+LnOv4jXMM23IT/F1wdYftGWGr47Is8CG+pmHK1Q= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +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 v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= @@ -150,6 +168,7 @@ github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -167,6 +186,8 @@ github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp9 github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -179,7 +200,9 @@ github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7P github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk= +github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo= github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= +github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc3 h1:fzg1mXZFj8YdPeNkRXMg+zb88BFV0Ys52cJydRwBkb8= @@ -195,13 +218,15 @@ github.com/prometheus-operator/prometheus-operator/pkg/client v0.64.0/go.mod h1: github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -215,8 +240,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ 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/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +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/thanhpk/randstr v1.0.5 h1:AdFhPTLzdJsoAfaRk7tG/zBhXjpy2VRBWdFM5r3CsZ8= github.com/thanhpk/randstr v1.0.5/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U= github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8= @@ -232,14 +258,30 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsr github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 h1:cEPbyTSEHlQR89XVlyo78gqluF8Y3oMeBkXGWzQsfXY= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0/go.mod h1:DKdbWcT4GH1D0Y3Sqt/PFXt2naRKDWtU+eE6oLdFNA8= +go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k= +go.opentelemetry.io/otel v1.25.0/go.mod h1:Wa2ds5NOXEMkCmUou1WA7ZBfLTHWIsp034OVD7AO+Vg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0 h1:dT33yIHtmsqpixFsSQPwNeY5drM9wTcoL8h0FWF4oGM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.25.0/go.mod h1:h95q0LBGh7hlAC08X2DhSeyIG02YQ0UyioTCVAqRPmc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 h1:Mbi5PKN7u322woPa85d7ebZ+SOvEoPvoiBu+ryHWgfA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0/go.mod h1:e7ciERRhZaOZXVjx5MiL8TK5+Xv7G5Gv5PA2ZDEJdL8= +go.opentelemetry.io/otel/metric v1.25.0 h1:LUKbS7ArpFL/I2jJHdJcqMGxkRdxpPHE0VU/D4NuEwA= +go.opentelemetry.io/otel/metric v1.25.0/go.mod h1:rkDLUSd2lC5lq2dFNrX9LGAbINP5B7WBkC78RXCpH5s= +go.opentelemetry.io/otel/sdk v1.25.0 h1:PDryEJPC8YJZQSyLY5eqLeafHtG+X7FWnf3aXMtxbqo= +go.opentelemetry.io/otel/sdk v1.25.0/go.mod h1:oFgzCM2zdsxKzz6zwpTZYLLQsFwc+K0daArPdIhuxkw= +go.opentelemetry.io/otel/trace v1.25.0 h1:tqukZGLwQYRIFtSQM2u2+yfMVTgGVeqRLPUYx1Dq6RM= +go.opentelemetry.io/otel/trace v1.25.0/go.mod h1:hCCs70XM/ljO+BeQkyFnbK28SBIJ/Emuha+ccrCRT7I= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= +go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230420155640-133eef4313cb h1:rhjz/8Mbfa8xROFiH+MQphmAmgqRM0bOMnytznhWEXk= golang.org/x/exp v0.0.0-20230420155640-133eef4313cb/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= @@ -258,7 +300,6 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= @@ -269,12 +310,12 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= -golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= +golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -282,8 +323,9 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -307,20 +349,20 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= @@ -346,15 +388,18 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= @@ -362,8 +407,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= +google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/golang/Makefile b/golang/Makefile index ac219b41c5..589bc1ad07 100644 --- a/golang/Makefile +++ b/golang/Makefile @@ -16,11 +16,11 @@ LDFLAGS := -ldflags "-X '${PACKAGE}/internal/version.BuildTimestamp=${BUILD_TIME # default tag is latest for building image_version ?= latest -GOAIR=v1.45.0 -GOSEC=v2.17.0 -GOLANGCI=v1.54.2 -GOFUMPT=v0.5.0 -YAMLFMT=v0.9.0 +GOAIR=v1.51.0 +GOSEC=v2.19.0 +GOLANGCI=v1.57.2 +GOFUMPT=v0.6.0 +YAMLFMT=v0.11.0 # support for: linux darwin windows GOOS?=linux diff --git a/golang/api/v1/deploy.go b/golang/api/v1/deploy.go index 2b444ff5b9..68c8bd61bc 100644 --- a/golang/api/v1/deploy.go +++ b/golang/api/v1/deploy.go @@ -21,15 +21,15 @@ import ( ) type DeployImageRequest struct { - RequestID string `json:"RequestId" binding:"required"` RegistryAuth *imageHelper.RegistryAuth `json:"RegistryAuth,omitempty"` - InstanceConfig InstanceConfig `json:"InstanceConfig" binding:"required"` - ContainerConfig ContainerConfig `json:"ContainerConfig" binding:"required"` - RuntimeConfig Base64JSONBytes `json:"RuntimeConfig,omitempty"` Registry *string `json:"Registry,omitempty"` + RequestID string `json:"RequestId" binding:"required"` ImageName string `json:"ImageName" binding:"required"` Tag string `json:"Tag" binding:"required"` Issuer string `json:"Issuer"` + InstanceConfig InstanceConfig `json:"InstanceConfig" binding:"required"` + RuntimeConfig Base64JSONBytes `json:"RuntimeConfig,omitempty"` + ContainerConfig ContainerConfig `json:"ContainerConfig" binding:"required"` } type VersionData struct { Version string `json:"version" binding:"required"` @@ -55,12 +55,12 @@ func (d *DeployImageRequest) Strings(appConfig *config.CommonConfiguration) []st } type DeployImageResponse struct { - Started bool `json:"started"` - Error string `json:"error"` RequestID *string `json:"requestId"` ImageName *string `json:"imageName"` + Error string `json:"error"` Tag string `json:"tag"` Logs []string `json:"logs"` + Started bool `json:"started"` } type DeployVersionResponse []DeployImageResponse @@ -68,22 +68,14 @@ type DeployVersionResponse []DeployImageResponse type Base64JSONBytes []byte type InstanceConfig struct { - // prefix of the container, identifies namespace - ContainerPreName string `json:"containerPreName" binding:"required"` - // not-in-use - MountPath string `json:"mountPath"` - // name of the instance eg. configmaps - Name string `json:"name"` - // variables for instance; configmaps: name-common, name must be defined - Environment map[string]string `json:"environment,omitempty"` - // not-in-use/unimplemented; registry is taken from containerConfig - Registry string `json:"registry"` - // not-in-use/unimplemented; git repository prefix - RepositoryPreName string `json:"repositoryPreName"` - // namespace global envs + Environment map[string]string `json:"environment,omitempty"` SharedEnvironment map[string]string `json:"sharedEnvironment,omitempty"` - // use preexisting namespaced envs - UseSharedEnvs bool `json:"useSharedEnvs" validate:"excluded_with=SharedEnvironment"` + ContainerPreName string `json:"containerPreName" binding:"required"` + MountPath string `json:"mountPath"` + Name string `json:"name"` + Registry string `json:"registry"` + RepositoryPreName string `json:"repositoryPreName"` + UseSharedEnvs bool `json:"useSharedEnvs" validate:"excluded_with=SharedEnvironment"` } func (i *InstanceConfig) Strings() []string { @@ -105,10 +97,10 @@ const ( ) type HealthCheckConfig struct { - Port uint16 `json:"Port"` LivenessProbe *Probe `json:"livenessProbe"` ReadinessProbe *Probe `json:"readinessProbe"` StartupProbe *Probe `json:"startupProbe"` + Port uint16 `json:"Port"` } type Resources struct { @@ -140,119 +132,54 @@ const ( ) type ExpectedState struct { - State ContainerState `json:"state"` Timeout *int32 `json:"timeout"` ExitCode *int32 `json:"exitCode"` + State ContainerState `json:"state"` } type ContainerConfig struct { - // ContainerPreName identifies namespace to be used - ContainerPreName string `json:"containerPreName"` - // name of the container used for service, configmap names, various component names - Container string `json:"container" binding:"required"` - // portbinding list contains external/interal ports - Ports []builder.PortBinding `json:"port" binding:"dive"` - // Port ranges to be exposed ! no native range support in k8s - PortRanges []builder.PortRangeBinding `json:"portRanges" binding:"dive"` - // mount list, if a name starts with @ it can be used by multiple components eg @data|/target/mount/path - Mounts []string `json:"mount"` - // volumes - Volumes []Volume `json:"volumes,omitempty" binding:"dive"` - // environment variables list - Environment map[string]string `json:"environment"` - // Secrets - Secrets map[string]string `json:"secrets,omitempty"` - // the type of the runtime text provided eg. dotnet-appsettings - RuntimeConfigType RuntimeConfigType `json:"runtimeConfigType"` - // create an ingress object or not - Expose bool `json:"expose"` - // use nginx tls configuration - ExposeTLS bool `json:"exposeTls"` - - /* - // proposal: all components need to match this - - // Domain name, if defined `.` otherwise `..` - // If RootDomain is empty it's omitted - RoutingDomain string `json:"routingDomain"` - // Set endpoint upload limit, default value is: 1m - // for docker hosts, this is needs to be bytes: 1000000 ~1m - RoutingUploadLimit string `json:"routingUploadLimit"` - */ - - // ingress prefix before hostname, `containerName.containerPrefix.` by default, this replaces both before root - IngressName string `json:"ingressName"` - // ingress hostname, env value used by default, can be overridden here - IngressHost string `json:"ingressHost"` - // ingress path for path based routing - IngressPath string `json:"ingressPath"` - // ingress path for path based routing - IngressStripPath bool `json:"ingressPathStrip"` - // ingress port to target - IngressPort uint16 `json:"ingressPort"` - // for docker hosts, this is needs to be bytes: 1000000 ~1m - IngressUploadLimit string `json:"ingressUploadLimit"` - // if put together with another instances consume their shared configs eg. -common config map, generated from here - Shared bool `json:"shared"` - // config container is spawned as an initcontainer copying files to a shared volume - ConfigContainer *ConfigContainer `json:"configContainer,omitempty"` - // import container uses rclone to copy over files before container startup - ImportContainer *ImportContainer `json:"importContainer,omitempty"` - // standard initContainers - InitContainers []InitContainer `json:"initContainers,omitempty" binding:"dive"` - // container UID - User *int64 `json:"user"` - // the initial command of a container have mixed terms - // docker --> k8s: entrypoint => command, cmd => args - // we use the k8s term here - // command is the active process of the container - Command []string `json:"command"` - // args are added to the command - Args []string `json:"args"` - // if we need to spawn a pseudo-terminal - TTY bool `json:"tty"` - // working directory of the container or pod - WorkingDirectory string `json:"workingDirectory"` - - // dagent only - // docker log config https://docs.docker.com/config/containers/logging/configure/ - LogConfig *container.LogConfig `json:"logConfig"` - RestartPolicy builder.RestartPolicyName `json:"restartPolicy"` - // bridge(container, default) host, none or network name - NetworkMode string `json:"networkMode"` - // extra networks - Networks []string `json:"networks"` - // docker only labels - DockerLabels map[string]string `json:"dockerLabels"` - - // k8s-only-section - // Deployments strategy, on deployment how to restart underlying pods - // Values: Recreate (all-at-once), RollingUpdate(one-by-one only if succeeds) - DeploymentStrategy string `json:"deploymentStrategy"` - // health check configuration - HealthCheckConfig HealthCheckConfig `json:"healthCheck"` - // custom header configuration - CustomHeaders []string `json:"customHeaders,omitempty"` - // resource management - ResourceConfig ResourceConfig `json:"resourceConfig"` - // add proxy and cors headers - ProxyHeaders bool `json:"proxyHeaders"` - // Expose service using external IP - // also sets the externalTrafficPolcy to "local" - UseLoadBalancer bool `json:"useLoadBalancer"` - // ExtraLBAnnotations, this is legacy - // Annotations.Service does the same, keeping it for compat - // lots of cloud provider specific configs can be put into annotations - // they vary enough to have it exposed like this - ExtraLBAnnotations map[string]string `json:"extraLBAnnotations,omitempty"` - // Annotations - Annotations Markers `json:"annotations"` - // k8s labels - Labels Markers `json:"labels"` - // Metrics - Metrics *Metrics `json:"metrics,omitempty"` - // Expected state - ExpectedState *ExpectedState `json:"expectedState,omitempty"` + HealthCheckConfig HealthCheckConfig `json:"healthCheck"` + Labels Markers `json:"labels"` + Annotations Markers `json:"annotations"` + ConfigContainer *ConfigContainer `json:"configContainer,omitempty"` + ImportContainer *ImportContainer `json:"importContainer,omitempty"` + ExpectedState *ExpectedState `json:"expectedState,omitempty"` + Environment map[string]string `json:"environment"` + Secrets map[string]string `json:"secrets,omitempty"` + LogConfig *container.LogConfig `json:"logConfig"` + ExtraLBAnnotations map[string]string `json:"extraLBAnnotations,omitempty"` + User *int64 `json:"user"` + Metrics *Metrics `json:"metrics,omitempty"` + DockerLabels map[string]string `json:"dockerLabels"` + ResourceConfig ResourceConfig `json:"resourceConfig"` + IngressPath string `json:"ingressPath"` + Container string `json:"container" binding:"required"` + DeploymentStrategy string `json:"deploymentStrategy"` + IngressUploadLimit string `json:"ingressUploadLimit"` + IngressHost string `json:"ingressHost"` + WorkingDirectory string `json:"workingDirectory"` + IngressName string `json:"ingressName"` + ContainerPreName string `json:"containerPreName"` + NetworkMode string `json:"networkMode"` + RestartPolicy container.RestartPolicyMode `json:"restartPolicy"` + RuntimeConfigType RuntimeConfigType `json:"runtimeConfigType"` + InitContainers []InitContainer `json:"initContainers,omitempty" binding:"dive"` + Volumes []Volume `json:"volumes,omitempty" binding:"dive"` + Args []string `json:"args"` + Command []string `json:"command"` + Networks []string `json:"networks"` + Ports []builder.PortBinding `json:"port" binding:"dive"` + PortRanges []builder.PortRangeBinding `json:"portRanges" binding:"dive"` + CustomHeaders []string `json:"customHeaders,omitempty"` + Mounts []string `json:"mount"` + IngressPort uint16 `json:"ingressPort"` + Shared bool `json:"shared"` + UseLoadBalancer bool `json:"useLoadBalancer"` + Expose bool `json:"expose"` + ProxyHeaders bool `json:"proxyHeaders"` + ExposeTLS bool `json:"exposeTls"` + IngressStripPath bool `json:"ingressPathStrip"` + TTY bool `json:"tty"` } type Metrics struct { @@ -329,20 +256,13 @@ type ImportContainer struct { // classic initContainer, also mimicked on docker // TODO(nandor-magyar): extend docs here type InitContainer struct { - // name of the init container, they must be unique within a pod - Name string `json:"name"` - // image to use - Image string `json:"image"` - // Reference(s) to already existing volume(s) - Volumes []VolumeLink `json:"volumes"` - // command to run, expecting exit code 0 - Command []string `json:"command"` - // arguments added to the command - Args []string `json:"args"` - // use env/secrets from the parent container - UseParent bool `json:"useParent"` - // envs directly defined - Envs map[string]string `json:"envs"` + Envs map[string]string `json:"envs"` + Name string `json:"name"` + Image string `json:"image"` + Volumes []VolumeLink `json:"volumes"` + Command []string `json:"command"` + Args []string `json:"args"` + UseParent bool `json:"useParent"` } type VolumeLink struct { @@ -432,10 +352,6 @@ func (jsonConfig *Base64JSONBytes) UnmarshalJSON(b []byte) error { } cleaned := util.RemoveJSONComment(decoded) - if err != nil { - return err - } - *jsonConfig = Base64JSONBytes(cleaned) return err @@ -473,6 +389,6 @@ func SetDeploymentDefaults( } if deployImageRequest.ContainerConfig.RestartPolicy == "" { - deployImageRequest.ContainerConfig.RestartPolicy = builder.RestartUnlessStoppedRestartPolicy + deployImageRequest.ContainerConfig.RestartPolicy = container.RestartPolicyUnlessStopped } } diff --git a/golang/internal/config/config.go b/golang/internal/config/config.go index 14c0d44883..389ac319be 100644 --- a/golang/internal/config/config.go +++ b/golang/internal/config/config.go @@ -21,29 +21,27 @@ import ( // Example: ValidJWT // Link: https://github.com/ilyakaznacheev/cleanenv#custom-value-setter type CommonConfiguration struct { - DefaultLimitsCPU string `yaml:"defaultLimitsCPU" env:"DEFAULT_LIMITS_CPU" env-default:"100m"` - DefaultLimitsMemory string `yaml:"defaultLimitsMemory" env:"DEFAULT_LIMITS_MEMORY" env-default:"128Mi"` - DefaultRequestsCPU string `yaml:"defaultRequestsCPU" env:"DEFAULT_REQUESTS_CPU" env-default:"50m"` - DefaultRequestMemory string `yaml:"defaultRequestMemory" env:"DEFAULT_REQUESTS_MEMORY" env-default:"64Mi"` - DefaultVolumeSize string `yaml:"defaultVolumeSize" env:"DEFAULT_VOLUME_SIZE" env-default:"1G"` - DefaultTag string `yaml:"defaultTag" env:"DEFAULT_TAG" env-default:"latest"` - DefaultTimeout time.Duration `yaml:"defaultTimeout" env:"DEFAULT_TIMEOUT" env-default:"5s"` + FallbackJwtToken *ValidJWT + JwtToken *ValidJWT + SecretPrivateKey string + DefaultRequestMemory string `yaml:"defaultRequestMemory" env:"DEFAULT_REQUESTS_MEMORY" env-default:"64Mi"` + DefaultVolumeSize string `yaml:"defaultVolumeSize" env:"DEFAULT_VOLUME_SIZE" env-default:"1G"` + DefaultTag string `yaml:"defaultTag" env:"DEFAULT_TAG" env-default:"latest"` + RootDomain string `yaml:"rootDomain" env:"ROOT_DOMAIN" env-default:""` + DefaultRequestsCPU string `yaml:"defaultRequestsCPU" env:"DEFAULT_REQUESTS_CPU" env-default:"50m"` + GrpcToken string `yaml:"grpcToken" env:"GRPC_TOKEN" env-default:""` + Name string `yaml:"name" env:"NAME" env-default:"dagent-go"` + DefaultLimitsMemory string `yaml:"defaultLimitsMemory" env:"DEFAULT_LIMITS_MEMORY" env-default:"128Mi"` + DefaultRegistry string `yaml:"registry" env:"DEFAULT_REGISTRY" env-default:"index.docker.io"` + DefaultLimitsCPU string `yaml:"defaultLimitsCPU" env:"DEFAULT_LIMITS_CPU" env-default:"100m"` + //nolint:lll + ImportContainerImage string `yaml:"importContainerImage" env:"IMPORT_CONTAINER_IMAGE" env-default:"rclone/rclone:1.57.0"` + ReadHeaderTimeout time.Duration `yaml:"readHeaderTimeout" env:"READ_HEADER_TIMEOUT" env-default:"15s"` GrpcKeepalive time.Duration `yaml:"grpcKeepalive" env:"GRPC_KEEPALIVE" env-default:"60s"` - GrpcToken string `yaml:"grpcToken" env:"GRPC_TOKEN" env-default:""` - Name string `yaml:"name" env:"NAME" env-default:"dagent-go"` - Debug bool `yaml:"debug" env:"DEBUG" env-default:"false"` - DebugUpdateAlways bool `yaml:"debugUpdateAlways" env:"DEBUG_UPDATE_ALWAYS" env-default:"false"` + DefaultTimeout time.Duration `yaml:"defaultTimeout" env:"DEFAULT_TIMEOUT" env-default:"5s"` DebugUpdateUseContainers bool `yaml:"debugUpdateUseContainers" env:"DEBUG_UPDATE_USE_CONTAINERS" env-default:"true"` - ImportContainerImage string `yaml:"importContainerImage" env:"IMPORT_CONTAINER_IMAGE" env-default:"rclone/rclone:1.57.0"` //nolint:lll - RootDomain string `yaml:"rootDomain" env:"ROOT_DOMAIN" env-default:""` - ReadHeaderTimeout time.Duration `yaml:"readHeaderTimeout" env:"READ_HEADER_TIMEOUT" env-default:"15s"` - // DefaultRegistry container registry used for container name expansion - DefaultRegistry string `yaml:"registry" env:"DEFAULT_REGISTRY" env-default:"index.docker.io"` - // gRPC token is set separately, because nested structures are not yet suppported in cleanenv - JwtToken *ValidJWT - FallbackJwtToken *ValidJWT - // injected from crane/dagent - SecretPrivateKey string + DebugUpdateAlways bool `yaml:"debugUpdateAlways" env:"DEBUG_UPDATE_ALWAYS" env-default:"false"` + Debug bool `yaml:"debug" env:"DEBUG" env-default:"false"` } const ( diff --git a/golang/internal/config/jwt_test.go b/golang/internal/config/jwt_test.go index 4854ceff0f..83e5f63fcf 100644 --- a/golang/internal/config/jwt_test.go +++ b/golang/internal/config/jwt_test.go @@ -16,9 +16,9 @@ import ( ) type jwtTest struct { + expErr error name string jwtTokenStringified string - expErr error } func (j jwtTest) run(t *testing.T) { diff --git a/golang/internal/dogger/dogger.go b/golang/internal/dogger/dogger.go index dba4386f53..ca7a6bfc83 100644 --- a/golang/internal/dogger/dogger.go +++ b/golang/internal/dogger/dogger.go @@ -33,14 +33,13 @@ type status struct { } type DeploymentLogger struct { + stream agent.Agent_DeploymentStatusClient + ctx context.Context + LogWriter + appConfig *config.CommonConfiguration deploymentID string requestID string - stream agent.Agent_DeploymentStatusClient logs []string - ctx context.Context - appConfig *config.CommonConfiguration - - LogWriter } func NewDeploymentLogger(ctx context.Context, deploymentID *string, diff --git a/golang/internal/grpc/grpc.go b/golang/internal/grpc/grpc.go index de30b5e43d..89ff2dd33c 100644 --- a/golang/internal/grpc/grpc.go +++ b/golang/internal/grpc/grpc.go @@ -40,8 +40,8 @@ type Connection struct { } type ContainerLogEvent struct { - Message string Error error + Message string } type ContainerLogReader interface { @@ -379,26 +379,21 @@ func initWithToken( } log.Info().Str("address", address).Msg("Dialing to address.") - conn, err := grpc.Dial(address, opts...) + conn, err := grpc.NewClient(address, opts...) if err != nil { - log.Panic().Stack().Err(err).Msg("Failed to dial gRPC") + return err } for { state := conn.GetState() - if state != connectivity.Ready { - log.Debug().Msgf("Waiting for state to change: %d", state) - conn.WaitForStateChange(loop.Ctx, state) - log.Debug().Msgf("State Changed to: %d", conn.GetState()) - } else { + if state == connectivity.Ready || state == connectivity.Idle { break } - } - if err != nil { - log.Error().Stack().Err(err).Msg("gRPC connection error") + log.Debug().Msgf("Waiting for state to change: %s", state.String()) + conn.WaitForStateChange(loop.Ctx, state) + log.Debug().Msgf("State Changed to: %d", conn.GetState()) } grpcConn.Conn = conn - return loop.grpcLoop(token) } @@ -498,7 +493,7 @@ func executeVersionDeployRequest( dog.SetRequestID(imageReq.RequestID) var versionData *v1.VersionData - if len(req.VersionName) > 0 { + if req.VersionName != "" { versionData = &v1.VersionData{Version: req.VersionName, ReleaseNotes: req.ReleaseNotes} } diff --git a/golang/internal/helper/docker/container.go b/golang/internal/helper/docker/container.go index 5c069ade5c..75ccb3f437 100644 --- a/golang/internal/helper/docker/container.go +++ b/golang/internal/helper/docker/container.go @@ -8,6 +8,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" "github.com/rs/zerolog/log" @@ -57,7 +58,7 @@ func deleteContainerByIDAndState(ctx context.Context, dog *dogger.DeploymentLogg dog.WriteContainerState(common.ContainerState_WAITING, state, dogger.Info, "Removing container: "+helper.FirstN(id, VisibleIDLimit)) } - if err = cli.ContainerRemove(ctx, id, types.ContainerRemoveOptions{}); err != nil { + if err = cli.ContainerRemove(ctx, id, container.RemoveOptions{}); err != nil { return fmt.Errorf("could not remove container (%s): %s", helper.FirstN(id, VisibleIDLimit), err.Error()) } @@ -108,7 +109,7 @@ func GetAllContainers(ctx context.Context) ([]types.Container, error) { log.Fatal().Err(err).Send() } - containers, err := cli.ContainerList(ctx, types.ContainerListOptions{All: true}) + containers, err := cli.ContainerList(ctx, container.ListOptions{All: true}) if err != nil { return []types.Container{}, err } @@ -173,7 +174,7 @@ func DeleteImage(ctx context.Context, imageID string) error { log.Fatal().Err(err).Send() } - _, err = cli.ImageRemove(ctx, imageID, types.ImageRemoveOptions{}) + _, err = cli.ImageRemove(ctx, imageID, image.RemoveOptions{}) return err } @@ -189,8 +190,8 @@ func checkOneContainer(containers []types.Container) (*types.Container, error) { } } -func containerListOptionsfilter(filtertype, filter string) types.ContainerListOptions { - return types.ContainerListOptions{ +func containerListOptionsfilter(filtertype, filter string) container.ListOptions { + return container.ListOptions{ All: true, Filters: filters.NewArgs( filters.KeyValuePair{ diff --git a/golang/internal/helper/docker/container_test.go b/golang/internal/helper/docker/container_test.go index 4554a4569c..ef431e0cd1 100644 --- a/golang/internal/helper/docker/container_test.go +++ b/golang/internal/helper/docker/container_test.go @@ -55,7 +55,7 @@ func (testSuite *DockerContainerHelperTestSuite) SetupSuite() { preparedContainer := containerbuilder.NewDockerBuilder(context.Background()). WithImage(nginxImage). WithName(fmt.Sprintf("%s-%s", testSuite.prefix, testSuite.containerNames[i])). - WithRestartPolicy(containerbuilder.NoRestartPolicy) + WithRestartPolicy(container.RestartPolicyDisabled) testSuite.testContainers = append(testSuite.testContainers, preparedContainer) } } @@ -79,7 +79,7 @@ func (testSuite *DockerContainerHelperTestSuite) SetupTest() { // this function executes after each test case func (testSuite *DockerContainerHelperTestSuite) TearDownTest() { containers, err := testSuite.dockerClient.ContainerList(testSuite.ctx, - types.ContainerListOptions{ + container.ListOptions{ All: true, Filters: filters.NewArgs( filters.KeyValuePair{ @@ -97,7 +97,7 @@ func (testSuite *DockerContainerHelperTestSuite) TearDownTest() { if err != nil { log.Warn().Err(err).Send() } - err = testSuite.dockerClient.ContainerRemove(testSuite.ctx, containers[i].ID, types.ContainerRemoveOptions{}) + err = testSuite.dockerClient.ContainerRemove(testSuite.ctx, containers[i].ID, container.RemoveOptions{}) if err != nil { log.Warn().Err(err).Send() } diff --git a/golang/internal/helper/image/image.go b/golang/internal/helper/image/image.go index aa0ea4af2a..a3d58c5bb2 100644 --- a/golang/internal/helper/image/image.go +++ b/golang/internal/helper/image/image.go @@ -17,8 +17,8 @@ import ( "github.com/dyrector-io/dyrectorio/protobuf/go/agent" "github.com/docker/distribution/reference" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/registry" "github.com/docker/docker/client" "github.com/docker/docker/errdefs" @@ -32,11 +32,11 @@ import ( type PullResponse struct { ID string `json:"id"` Status string `json:"status"` + Progress string `json:"progress"` ProgressDetail struct { Current int64 `json:"current"` Total int64 `json:"total"` } `json:"progressDetail"` - Progress string `json:"progress"` } type remoteCheck struct { @@ -66,9 +66,8 @@ func GetRegistryURL(reg *string, registryAuth *RegistryAuth) string { return registryAuth.URL } else if reg != nil { return *reg - } else { - return "" } + return "" } func GetRegistryURLProto(reg *string, registryAuth *agent.RegistryAuth) string { @@ -76,13 +75,12 @@ func GetRegistryURLProto(reg *string, registryAuth *agent.RegistryAuth) string { return registryAuth.Url } else if reg != nil { return *reg - } else { - return "" } + return "" } -func GetImageByReference(ctx context.Context, cli client.APIClient, ref string) (*types.ImageSummary, error) { - images, err := cli.ImageList(ctx, types.ImageListOptions{ +func GetImageByReference(ctx context.Context, cli client.APIClient, ref string) (*image.Summary, error) { + images, err := cli.ImageList(ctx, image.ListOptions{ Filters: filters.NewArgs(filters.KeyValuePair{Key: "reference", Value: ref}), }) if err != nil { @@ -105,7 +103,7 @@ func Exists( logger io.StringWriter, expandedImageName, encodedAuth string, ) (*ExistResult, error) { exists := ExistResult{} - images, err := cli.ImageList(ctx, types.ImageListOptions{ + images, err := cli.ImageList(ctx, image.ListOptions{ Filters: filters.NewArgs(filters.KeyValuePair{Key: "reference", Value: expandedImageName}), }) if err != nil { @@ -163,7 +161,7 @@ func Pull(ctx context.Context, cli client.APIClient, logger io.StringWriter, exp } } - reader, err := cli.ImagePull(ctx, expandedImageName, types.ImagePullOptions{RegistryAuth: authCreds}) + reader, err := cli.ImagePull(ctx, expandedImageName, image.PullOptions{RegistryAuth: authCreds}) if err != nil { return err } @@ -248,7 +246,7 @@ func shouldUseLocalImage(ctx context.Context, cli client.APIClient, } func pullImage(ctx context.Context, cli client.APIClient, imageName, encodedAuth string) (io.ReadCloser, error) { - options := types.ImagePullOptions{ + options := image.PullOptions{ RegistryAuth: encodedAuth, } @@ -349,8 +347,8 @@ func checkRemote(ctx context.Context, check remoteCheck) (err error) { return errDigestsMatching } -func ParseReference(image string) (reference.Reference, error) { - return reference.ParseAnyReference(strings.ToLower(image)) +func ParseReference(img string) (reference.Reference, error) { + return reference.ParseAnyReference(strings.ToLower(img)) } func ExpandImageName(imageWithTag string) (string, error) { @@ -371,8 +369,8 @@ func ExpandImageName(imageWithTag string) (string, error) { return named.String(), nil } -func ExpandImageNameWithTag(image, tag string) (string, error) { - ref, err := ParseReference(image) +func ExpandImageNameWithTag(img, tag string) (string, error) { + ref, err := ParseReference(img) if err != nil { return "", err } diff --git a/golang/internal/mapper/grpc.go b/golang/internal/mapper/grpc.go index 55898e5c63..e78d0503dc 100644 --- a/golang/internal/mapper/grpc.go +++ b/golang/internal/mapper/grpc.go @@ -159,12 +159,12 @@ func mapDagentConfig(dagent *agent.DagentContainerConfig, containerConfig *v1.Co } if dagent.RestartPolicy != nil { - containerConfig.RestartPolicy = mapRestartPolicy(dagent.RestartPolicy.String()) + containerConfig.RestartPolicy = container.RestartPolicyMode(ProtoEnumToKebabCase(dagent.RestartPolicy.String())) } if dagent.LogConfig != nil { containerConfig.LogConfig = &container.LogConfig{ - Type: strings.ToLower(strings.ReplaceAll(strings.TrimPrefix(dagent.LogConfig.Driver.String(), "DRIVER_TYPE_"), "_", "-")), + Type: ProtoEnumToKebabCase(strings.TrimPrefix(dagent.LogConfig.Driver.String(), "DRIVER_TYPE_")), Config: dagent.LogConfig.Options, } } @@ -182,6 +182,14 @@ func mapDagentConfig(dagent *agent.DagentContainerConfig, containerConfig *v1.Co } } +func ProtoEnumToKebabCase(in string) string { + res := strings.ToLower(strings.ReplaceAll(in, "_", "-")) + if strings.Contains(res, "unspecified") || strings.Contains(res, "undefined") { + return "" + } + return res +} + func mapCraneConfig(crane *agent.CraneContainerConfig, containerConfig *v1.ContainerConfig) { containerConfig.DeploymentStrategy = strcase.ToCamel(crane.DeploymentStrategy.String()) @@ -229,12 +237,6 @@ func mapCraneConfig(crane *agent.CraneContainerConfig, containerConfig *v1.Conta } } -func mapRestartPolicy(policy string) builder.RestartPolicyName { - lower := strings.ToLower(policy) - - return builder.RestartPolicyName(strings.Replace(lower, "_", "-", -1)) -} - func mapContainerState(state common.ContainerState) v1.ContainerState { switch state { case common.ContainerState_CONTAINER_STATE_UNSPECIFIED: diff --git a/golang/internal/mapper/grpc_test.go b/golang/internal/mapper/grpc_test.go index 2c21c5f9fb..271d23217b 100644 --- a/golang/internal/mapper/grpc_test.go +++ b/golang/internal/mapper/grpc_test.go @@ -30,6 +30,33 @@ func TestMapDeployImageRequest(t *testing.T) { assert.Equal(t, expected, res) } +type RestartTestCase struct { + policy *common.RestartPolicy + dockerType container.RestartPolicyMode +} + +func TestMapDeployImageRequestRestartPolicies(t *testing.T) { + req := testDeployRequest() + expected := testExpectedCommon(req) + cfg := testAppConfig() + + cases := []RestartTestCase{ + {common.RestartPolicy_NO.Enum(), container.RestartPolicyDisabled}, + {common.RestartPolicy_ON_FAILURE.Enum(), container.RestartPolicyOnFailure}, + {common.RestartPolicy_ALWAYS.Enum(), container.RestartPolicyAlways}, + {common.RestartPolicy_UNLESS_STOPPED.Enum(), container.RestartPolicyUnlessStopped}, + // should be "" to use container runtime default setting, but we enforce 'unless-stopped' + {common.RestartPolicy_UNDEFINED.Enum(), container.RestartPolicyUnlessStopped}, + {common.RestartPolicy_POLICY_UNSPECIFIED.Enum(), container.RestartPolicyUnlessStopped}, + } + for _, tC := range cases { + req.Dagent.RestartPolicy = tC.policy + expected.ContainerConfig.RestartPolicy = tC.dockerType + res := MapDeployImage(req, cfg) + assert.Equal(t, expected, res) + } +} + func testExpectedCommon(req *agent.DeployRequest) *v1.DeployImageRequest { return &v1.DeployImageRequest{ RequestID: "testID", @@ -97,7 +124,7 @@ func testExpectedCommon(req *agent.DeployRequest) *v1.DeployImageRequest { Type: "365", Config: map[string]string{"opt1": "v1", "opt2": "v2"}, }, - RestartPolicy: "always", + RestartPolicy: container.RestartPolicyAlways, Networks: []string{"n1", "n2"}, NetworkMode: "BRIDGE", CustomHeaders: []string(nil), diff --git a/golang/internal/runtime/container/container_test.go b/golang/internal/runtime/container/container_test.go index cfcaa1a88f..c985051fe2 100644 --- a/golang/internal/runtime/container/container_test.go +++ b/golang/internal/runtime/container/container_test.go @@ -15,6 +15,7 @@ import ( containerRuntime "github.com/dyrector-io/dyrectorio/golang/internal/runtime/container" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" "github.com/stretchr/testify/assert" ) @@ -22,21 +23,21 @@ import ( type mockDockerClient struct { client.APIClient version string - info *types.Info + info *system.Info } type mockErrDockerClient struct { client.APIClient } -func newMockClient(version string, info *types.Info) client.APIClient { +func newMockClient(version string, info *system.Info) client.APIClient { return &mockDockerClient{ version: version, info: info, } } -func (m mockDockerClient) Info(ctx context.Context) (types.Info, error) { +func (m mockDockerClient) Info(ctx context.Context) (system.Info, error) { return *m.info, nil } @@ -54,30 +55,30 @@ func (m mockErrDockerClient) ServerVersion(ctx context.Context) (types.Version, return types.Version{}, fmt.Errorf("expected version error") } -func (m mockErrDockerClient) Info(ctx context.Context) (types.Info, error) { - return types.Info{}, fmt.Errorf("expected info error") +func (m mockErrDockerClient) Info(ctx context.Context) (system.Info, error) { + return system.Info{}, fmt.Errorf("expected info error") } -func getDockerInfoDocker() *types.Info { - return &types.Info{ +func getDockerInfoDocker() *system.Info { + return &system.Info{ InitBinary: "docker-init", } } -func getDockerInfoPodman() *types.Info { - return &types.Info{ +func getDockerInfoPodman() *system.Info { + return &system.Info{ InitBinary: "", } } -func getDockerInfoInvalid() *types.Info { - return &types.Info{ +func getDockerInfoInvalid() *system.Info { + return &system.Info{ InitBinary: "invalidInitBinaryString", } } type VersionTestCase struct { - Info *types.Info + Info *system.Info MockClientVersion string } @@ -207,7 +208,7 @@ func getMajorMinor(f *testing.F, versionStr string) (uint16, uint16) { return uint16(major), uint16(minor) } -func fuzzVersionWithRuntime(f *testing.F, dockerInfo *types.Info, majorMin, minorMin uint16) func(t *testing.T, major, minor, patch uint16) { +func fuzzVersionWithRuntime(_ *testing.F, dockerInfo *system.Info, majorMin, minorMin uint16) func(t *testing.T, major, minor, patch uint16) { return func(t *testing.T, major, minor, patch uint16) { versionStr := fmt.Sprintf("%d.%d.%d", major, minor, patch) @@ -233,7 +234,7 @@ func FuzzVersionCheckPodman(f *testing.F) { f.Add(uint16(20), uint16(0), uint16(10)) f.Add(uint16(4), uint16(0), uint16(0)) majorMin, minorMin := getMajorMinor(f, containerRuntime.RecommendedPodmanServerVersion) - dockerInfo := &types.Info{} + dockerInfo := &system.Info{} f.Fuzz(fuzzVersionWithRuntime(f, dockerInfo, majorMin, minorMin)) } @@ -242,7 +243,7 @@ func FuzzVersionCheckDocker(f *testing.F) { f.Add(uint16(20), uint16(0), uint16(10)) f.Add(uint16(21), uint16(0), uint16(10)) f.Add(uint16(4), uint16(0), uint16(0)) - dockerInfo := &types.Info{ + dockerInfo := &system.Info{ InitBinary: "docker-init", } majorMin, minorMin := getMajorMinor(f, containerRuntime.RecommendedDockerServerVersion) diff --git a/golang/internal/util/array.go b/golang/internal/util/array.go index 3f1ea8a5eb..d9f4ea8532 100644 --- a/golang/internal/util/array.go +++ b/golang/internal/util/array.go @@ -16,7 +16,7 @@ func ContainsMatcher[T comparable](arr []T, item T, comp func(T, T) bool) bool { return false } for _, v := range arr { - if comp != nil && comp(v, item) { + if comp(v, item) { return true } } diff --git a/golang/internal/util/dotnet.go b/golang/internal/util/dotnet.go index d5dccbc330..d69ca79028 100644 --- a/golang/internal/util/dotnet.go +++ b/golang/internal/util/dotnet.go @@ -12,7 +12,7 @@ func MapAppsettingsToEnv(in *string) (map[string]string, error) { if in == nil { return map[string]string{}, errors.New("Nil input") } - if in != nil && *in == "" { + if *in == "" { return map[string]string{}, errors.New("Empty input") } envList := map[string]string{} diff --git a/golang/pkg/builder/container/container_builder.go b/golang/pkg/builder/container/container_builder.go index f915c287b3..47a5396a3e 100644 --- a/golang/pkg/builder/container/container_builder.go +++ b/golang/pkg/builder/container/container_builder.go @@ -43,7 +43,7 @@ type Builder interface { WithLogConfig(config *container.LogConfig) Builder WithRegistryAuth(auth *imageHelper.RegistryAuth) Builder WithAutoRemove(remove bool) Builder - WithRestartPolicy(policy RestartPolicyName) Builder + WithRestartPolicy(policy container.RestartPolicyMode) Builder WithEntrypoint(cmd []string) Builder WithCmd(cmd []string) Builder WithShell(shell []string) Builder @@ -63,39 +63,39 @@ type Builder interface { } type DockerContainerBuilder struct { - ctx context.Context + logger dogger.LogWriter client client.APIClient - containerID *string + ctx context.Context + logConfig *container.LogConfig networkMap map[string]string - networkAliases []string + labels map[string]string + pullDisplayFn imageHelper.PullDisplayFn + containerID *string + user *int64 + workingDirectory string containerName string imageWithTag string - envList []string - labels map[string]string - logConfig *container.LogConfig - portList []PortBinding - portRanges []PortRangeBinding - mountList []mount.Mount + registryAuth string networkMode string + restartPolicy container.RestartPolicyMode networks []string - registryAuth string - remove bool - withoutConflict bool - restartPolicy RestartPolicyName + hooksPostStart []LifecycleFunc + hooksPreStart []LifecycleFunc + hooksPreCreate []LifecycleFunc entrypoint []string cmd []string shell []string - tty bool - user *int64 - imagePriority imageHelper.PullPriority - pullDisplayFn imageHelper.PullDisplayFn - logger dogger.LogWriter - workingDirectory string - extraHosts []string - hooksPreCreate []LifecycleFunc hooksPostCreate []LifecycleFunc - hooksPreStart []LifecycleFunc - hooksPostStart []LifecycleFunc + mountList []mount.Mount + portRanges []PortRangeBinding + portList []PortBinding + envList []string + networkAliases []string + extraHosts []string + imagePriority imageHelper.PullPriority + tty bool + withoutConflict bool + remove bool } // A shorthand function for creating a new DockerContainerBuilder and calling WithClient. @@ -208,7 +208,7 @@ func (dc *DockerContainerBuilder) WithRegistryAuth(auth *imageHelper.RegistryAut } // Sets the restart policy of the container. -func (dc *DockerContainerBuilder) WithRestartPolicy(policy RestartPolicyName) Builder { +func (dc *DockerContainerBuilder) WithRestartPolicy(policy container.RestartPolicyMode) Builder { dc.restartPolicy = policy return dc } @@ -306,12 +306,6 @@ func (dc *DockerContainerBuilder) WithPostStartHooks(hooks ...LifecycleFunc) Bui } func builderToDockerConfig(dc *DockerContainerBuilder) (hostConfig *container.HostConfig, containerConfig *container.Config, err error) { - hostConfig = &container.HostConfig{} - containerConfig = &container.Config{} - if dc.containerName != "" { - containerConfig.Hostname = dc.containerName - } - portListNat := portListToNatBinding(dc.portRanges, dc.portList) exposedPortSet := getPortSet(dc.portRanges, dc.portList) hostConfig = &container.HostConfig{ @@ -332,6 +326,9 @@ func builderToDockerConfig(dc *DockerContainerBuilder) (hostConfig *container.Ho Shell: dc.shell, WorkingDir: dc.workingDirectory, } + if dc.containerName != "" { + containerConfig.Hostname = dc.containerName + } if dc.user != nil { containerConfig.User = fmt.Sprint(*dc.user) @@ -341,8 +338,13 @@ func builderToDockerConfig(dc *DockerContainerBuilder) (hostConfig *container.Ho hostConfig.LogConfig = *dc.logConfig } - policy := container.RestartPolicy{} - policy.Name = string(dc.restartPolicy) + policy := container.RestartPolicy{ + Name: dc.restartPolicy, + } + err = container.ValidateRestartPolicy(policy) + if err != nil { + return nil, nil, errors.Join(err, fmt.Errorf("builder: invalid restart policy")) + } hostConfig.RestartPolicy = policy if dc.networkMode != "" { @@ -392,7 +394,7 @@ func (dc *DockerContainerBuilder) Create() (Container, error) { if err != nil { dc.logError(fmt.Sprintln("Container create failed: ", err)) } - containers, err := dc.client.ContainerList(dc.ctx, types.ContainerListOptions{ + containers, err := dc.client.ContainerList(dc.ctx, container.ListOptions{ All: true, Filters: filters.NewArgs(filters.KeyValuePair{Key: "id", Value: containerCreateResp.ID}), }) @@ -435,7 +437,7 @@ func (dc *DockerContainerBuilder) CreateAndStartWaitUntilExit() (Container, *Wai return cont, res, err } - logReader, err := dc.client.ContainerLogs(dc.ctx, *cont.GetContainerID(), types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true}) + logReader, err := dc.client.ContainerLogs(dc.ctx, *cont.GetContainerID(), container.LogsOptions{ShowStdout: true, ShowStderr: true}) if err != nil { return cont, res, err } diff --git a/golang/pkg/builder/container/container_builder_integration_test.go b/golang/pkg/builder/container/container_builder_integration_test.go index 336309a197..7d1f67f49e 100644 --- a/golang/pkg/builder/container/container_builder_integration_test.go +++ b/golang/pkg/builder/container/container_builder_integration_test.go @@ -10,7 +10,7 @@ import ( "time" "github.com/AlekSi/pointer" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" "github.com/docker/go-connections/nat" @@ -28,6 +28,9 @@ func baseBuilder(ctx context.Context) containerbuilder.Builder { } func containerCleanup(container containerbuilder.Container) { + if container == nil { + return + } ctx := context.Background() if container.GetContainerID() != nil { dockerHelper.DeleteContainerByID(ctx, nil, *container.GetContainerID()) @@ -70,6 +73,18 @@ func TestNameWithBuilder(t *testing.T) { assert.NoError(t, err) } +func TestRestartNegative(t *testing.T) { + var _ containerbuilder.Builder = (*containerbuilder.DockerContainerBuilder)(nil) + + builder := containerbuilder.NewDockerBuilder(context.Background()). + WithImage("ghcr.io/dyrector-io/mirror/nginx:mainline-alpine"). + WithRestartPolicy(container.RestartPolicyMode("invalid")) + + cont, err := builder.CreateAndStart() + defer containerCleanup(cont) + assert.Error(t, err, "error is thrown for invalid restart policy") +} + func TestEnvPortsLabelsRestartPolicySettings(t *testing.T) { cont, err := containerbuilder.NewDockerBuilder(context.Background()). WithName("test02"). @@ -92,7 +107,7 @@ func TestEnvPortsLabelsRestartPolicySettings(t *testing.T) { "LABEL1": "TEST", "LABEL2": "1234", }). - WithRestartPolicy(containerbuilder.AlwaysRestartPolicy). + WithRestartPolicy(container.RestartPolicyAlways). WithImage("ghcr.io/dyrector-io/mirror/nginx:mainline-alpine"). CreateAndStart() @@ -103,25 +118,25 @@ func TestEnvPortsLabelsRestartPolicySettings(t *testing.T) { panic(err) } - container, err := cli.ContainerInspect(context.Background(), *cont.GetContainerID()) + containerResp, err := cli.ContainerInspect(context.Background(), *cont.GetContainerID()) assert.Nil(t, err) - assert.Equal(t, "/test02", container.Name) + assert.Equal(t, "/test02", containerResp.Name) - assert.Contains(t, container.Config.Env, "A=B") - assert.Contains(t, container.Config.Env, "E_N_V=123") + assert.Contains(t, containerResp.Config.Env, "A=B") + assert.Contains(t, containerResp.Config.Env, "E_N_V=123") - assertPortBinding(t, container.HostConfig.PortBindings, "1234", "2345") + assertPortBinding(t, containerResp.HostConfig.PortBindings, "1234", "2345") for testPort := 0; testPort < 10; testPort++ { - assertPortBinding(t, container.HostConfig.PortBindings, fmt.Sprint(10+testPort), fmt.Sprint(30+testPort)) + assertPortBinding(t, containerResp.HostConfig.PortBindings, fmt.Sprint(10+testPort), fmt.Sprint(30+testPort)) } - assert.Contains(t, container.Config.Labels, "LABEL1") - assert.Equal(t, container.Config.Labels["LABEL1"], "TEST") - assert.Contains(t, container.Config.Labels, "LABEL2") - assert.Equal(t, container.Config.Labels["LABEL2"], "1234") + assert.Contains(t, containerResp.Config.Labels, "LABEL1") + assert.Equal(t, containerResp.Config.Labels["LABEL1"], "TEST") + assert.Contains(t, containerResp.Config.Labels, "LABEL2") + assert.Equal(t, containerResp.Config.Labels["LABEL2"], "1234") - assert.Equal(t, container.HostConfig.RestartPolicy.Name, string(containerbuilder.AlwaysRestartPolicy)) + assert.Equal(t, string(containerResp.HostConfig.RestartPolicy.Name), string(container.RestartPolicyAlways)) } func TestLogging(t *testing.T) { @@ -240,7 +255,7 @@ func TestConflict(t *testing.T) { t.Fatal(err) } - list, err := cli.ContainerList(context.Background(), types.ContainerListOptions{ + list, err := cli.ContainerList(context.Background(), container.ListOptions{ All: true, Filters: filters.NewArgs(filters.KeyValuePair{Key: "id", Value: *cont2.GetContainerID()}), }) diff --git a/golang/pkg/builder/container/docker_container.go b/golang/pkg/builder/container/docker_container.go index 02bb10800c..7afa397fab 100644 --- a/golang/pkg/builder/container/docker_container.go +++ b/golang/pkg/builder/container/docker_container.go @@ -69,7 +69,7 @@ func (d DockerContainer) Start(ctx context.Context, cli client.APIClient) error return hookError } - err := cli.ContainerStart(ctx, d.container.ID, types.ContainerStartOptions{}) + err := cli.ContainerStart(ctx, d.container.ID, container.StartOptions{}) if err != nil { return err } diff --git a/golang/pkg/builder/container/exec_builder.go b/golang/pkg/builder/container/exec_builder.go index e4258ec49e..f3229bcd8a 100644 --- a/golang/pkg/builder/container/exec_builder.go +++ b/golang/pkg/builder/container/exec_builder.go @@ -32,12 +32,12 @@ type ExecBuilder interface { type DockerExecBuilder struct { ctx context.Context - client *client.Client + logger *dogger.LogWriter containerID *string user *int64 + client *client.Client workingDir string cmd []string - logger *dogger.LogWriter tty bool detach bool attachStdin bool @@ -175,9 +175,9 @@ func (de *DockerExecBuilder) Create() (Exec, error) { type Exec struct { ctx context.Context + execStartCheck types.ExecStartCheck client *client.Client ExecID string - execStartCheck types.ExecStartCheck } func (e Exec) Start() error { diff --git a/golang/pkg/builder/container/logger_test.go b/golang/pkg/builder/container/logger_test.go index e2083eb61a..d3cd2cc390 100644 --- a/golang/pkg/builder/container/logger_test.go +++ b/golang/pkg/builder/container/logger_test.go @@ -7,10 +7,9 @@ import ( ) type TestLogger struct { + dogger.LogWriter test *testing.T gotMessage bool - - dogger.LogWriter } func (testLogger *TestLogger) WriteInfo(s ...string) { diff --git a/golang/pkg/builder/container/types.go b/golang/pkg/builder/container/types.go index 20cbaac6e2..e7f5680003 100644 --- a/golang/pkg/builder/container/types.go +++ b/golang/pkg/builder/container/types.go @@ -2,7 +2,6 @@ package container import ( "context" - "encoding/json" "fmt" "github.com/AlekSi/pointer" @@ -40,74 +39,12 @@ type PortRangeBinding struct { External PortRange `json:"external" binding:"required"` } -// RestartPolicyName defines the restart policy used by a container. -type RestartPolicyName string - -const ( - EmptyRestartPolicy RestartPolicyName = "" - AlwaysRestartPolicy RestartPolicyName = "always" - RestartUnlessStoppedRestartPolicy RestartPolicyName = "unless-stopped" - NoRestartPolicy RestartPolicyName = "no" - OnFailureRestartPolicy RestartPolicyName = "on-failure" -) - -// RestartPolicyUnmarshalInvalidError represents custom error regarding restart policy -type RestartPolicyUnmarshalInvalidError struct{} - -func (e *RestartPolicyUnmarshalInvalidError) Error() string { - return "restart policy invalid value provided" -} - -// policyToString static mapping enum type into the docker supported string values -var policyToString = map[RestartPolicyName]string{ - EmptyRestartPolicy: "unless-stopped", - RestartUnlessStoppedRestartPolicy: "unless-stopped", - NoRestartPolicy: "no", - AlwaysRestartPolicy: "always", - OnFailureRestartPolicy: "on-failure", -} - -// policyToID static mapping string values eg. from JSON into enums -var policyToID = map[string]RestartPolicyName{ - "": RestartUnlessStoppedRestartPolicy, - "unless-stopped": RestartUnlessStoppedRestartPolicy, - "no": NoRestartPolicy, - "always": AlwaysRestartPolicy, - "on-failure": OnFailureRestartPolicy, -} - -// custom enum marshal JSON interface implementation -func (policy RestartPolicyName) MarshalJSON() ([]byte, error) { - str, ok := policyToString[policy] - if !ok { - return nil, &RestartPolicyUnmarshalInvalidError{} - } - return []byte(fmt.Sprintf(`%q`, str)), nil -} - -// custom enum unmarshal JSON interface implementation -func (policy *RestartPolicyName) UnmarshalJSON(b []byte) error { - var j string - err := json.Unmarshal(b, &j) - if err != nil { - return err - } - - if _, ok := policyToID[j]; ok { - *policy = policyToID[j] - } else { - *policy = RestartPolicyName("") - err = &RestartPolicyUnmarshalInvalidError{} - } - return err -} - type ParentContainer struct { + Logger *dogger.LogWriter + *types.Container Name string MountList []mount.Mount Environment []string - Logger *dogger.LogWriter - *types.Container } // Hook function which can be used to add custom logic before and after events of the lifecycle of a container. @@ -116,6 +53,6 @@ type LifecycleFunc func(ctx context.Context, client client.APIClient, cont Paren // WaitResult with the status code from the container type WaitResult struct { - StatusCode int64 Logs []string + StatusCode int64 } diff --git a/golang/pkg/builder/container/types_test.go b/golang/pkg/builder/container/types_test.go deleted file mode 100644 index f417a28445..0000000000 --- a/golang/pkg/builder/container/types_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package container_test - -import ( - "encoding/json" - "fmt" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/dyrector-io/dyrectorio/golang/pkg/builder/container" -) - -func TestRestartPolicyNameMarshal(t *testing.T) { - testPolicies := map[container.RestartPolicyName]string{ - container.EmptyRestartPolicy: "unless-stopped", - container.RestartUnlessStoppedRestartPolicy: "unless-stopped", - container.NoRestartPolicy: "no", - container.AlwaysRestartPolicy: "always", - container.OnFailureRestartPolicy: "on-failure", - } - - for key, value := range testPolicies { - text, err := json.Marshal(key) - - expectedResult := fmt.Sprintf("%q", value) - - assert.Nil(t, err) - assert.Equal(t, expectedResult, string(text)) - } -} - -func TestRestartPolicyNameUnmarshal(t *testing.T) { - testPolicies := map[string]container.RestartPolicyName{ - "": container.RestartUnlessStoppedRestartPolicy, - "unless-stopped": container.RestartUnlessStoppedRestartPolicy, - "no": container.NoRestartPolicy, - "always": container.AlwaysRestartPolicy, - "on-failure": container.OnFailureRestartPolicy, - } - - for key, value := range testPolicies { - var parsed container.RestartPolicyName - jsonValue := fmt.Sprintf("%q", key) - err := json.Unmarshal([]byte(jsonValue), &parsed) - - assert.Nil(t, err) - assert.Equal(t, value, parsed) - } -} - -func TestRestartPolicyNameUnmarshalError(t *testing.T) { - var parsed container.RestartPolicyName - err := json.Unmarshal([]byte("\"not-valid-policy-name\""), &parsed) - - assert.ErrorIs(t, err, &container.RestartPolicyUnmarshalInvalidError{}) -} diff --git a/golang/pkg/cli/config_file.go b/golang/pkg/cli/config_file.go index 7438f5714c..129b89109d 100644 --- a/golang/pkg/cli/config_file.go +++ b/golang/pkg/cli/config_file.go @@ -25,29 +25,28 @@ import ( // State itself exists per-execution, settingsFile is persisted // freedesktop spec folders used by default, $XDG_CONFIG_HOME type State struct { - Ctx context.Context - SettingsFile SettingsFile + Ctx context.Context + *Containers InternalHostDomain string EnvFile []string - *Containers + SettingsFile SettingsFile } // ArgsFlags are commandline arguments type ArgsFlags struct { - SettingsWrite bool - SettingsExists bool - SettingsFilePath string - Command string - ImageTag string - Prefix string - CruxDisabled bool - CruxUIDisabled bool - LocalAgent bool - PreferLocalImages bool - EnvFile string - // pipeline mode - FullyContainerized bool + EnvFile string Network string + SettingsFilePath string + Command string + ImageTag string + Prefix string + CruxDisabled bool + CruxUIDisabled bool + LocalAgent bool + PreferLocalImages bool + SettingsWrite bool + FullyContainerized bool + SettingsExists bool Silent bool } @@ -68,8 +67,8 @@ type Containers struct { type ContainerSettings struct { Image string Name string - Disabled bool CruxAddr string + Disabled bool } // SettingsFile will be read/written as this struct @@ -83,32 +82,32 @@ type SettingsFile struct { // Options are "globals" for the SettingsFile struct type Options struct { - TimeZone string `yaml:"timezone" env-default:"UTC"` - CruxAgentGrpcPort uint `yaml:"crux-agentgrpc-port" env-default:"5000"` - CruxHTTPPort uint `yaml:"crux-http-port" env-default:"1848"` - CruxUIPort uint `yaml:"crux-ui-port" env-default:"3000"` + KratosPostgresUser string `yaml:"kratosPostgresUser" env-default:"kratos"` + KratosPostgresPassword string `yaml:"kratosPostgresPassword"` + TraefikDockerSocket string `yaml:"traefikDockerSocket" env-default:"/var/run/docker.sock"` + MailFromName string `yaml:"mailFromName" env-default:"dyrector.io - Platform"` CruxSecret string `yaml:"crux-secret"` CruxEncryptionKey string `yaml:"crux-encryption-key"` - CruxPostgresPort uint `yaml:"cruxPostgresPort" env-default:"5432"` + KratosSecret string `yaml:"kratosSecret"` CruxPostgresDB string `yaml:"cruxPostgresDB" env-default:"crux"` CruxPostgresUser string `yaml:"cruxPostgresUser" env-default:"crux"` CruxPostgresPassword string `yaml:"cruxPostgresPassword"` + TimeZone string `yaml:"timezone" env-default:"UTC"` + KratosPostgresDB string `yaml:"kratosPostgresDB" env-default:"kratos"` + MailFromEmail string `yaml:"mailFromEmail" env-default:"noreply@example.com"` TraefikWebPort uint `yaml:"traefikWebPort" env-default:"8000"` - TraefikUIPort uint `yaml:"traefikUIPort" env-default:"8080"` - TraefikDockerSocket string `yaml:"traefikDockerSocket" env-default:"/var/run/docker.sock"` - TraefikIsDockerSocketNamedPipe bool `yaml:"traefikIsDockerSocketNamedPipe" env-default:"false"` - KratosAdminPort uint `yaml:"kratosAdminPort" env-default:"4434"` + CruxUIPort uint `yaml:"crux-ui-port" env-default:"3000"` KratosPublicPort uint `yaml:"kratosPublicPort" env-default:"4433"` KratosPostgresPort uint `yaml:"kratosPostgresPort" env-default:"5433"` - KratosPostgresDB string `yaml:"kratosPostgresDB" env-default:"kratos"` - KratosPostgresUser string `yaml:"kratosPostgresUser" env-default:"kratos"` - KratosPostgresPassword string `yaml:"kratosPostgresPassword"` - KratosSecret string `yaml:"kratosSecret"` - MailSlurperSMTPPort uint `yaml:"mailSlurperSMTPPort" env-default:"1025"` + TraefikUIPort uint `yaml:"traefikUIPort" env-default:"8080"` + CruxHTTPPort uint `yaml:"crux-http-port" env-default:"1848"` + CruxAgentGrpcPort uint `yaml:"crux-agentgrpc-port" env-default:"5000"` MailSlurperUIPort uint `yaml:"mailSlurperUIPort" env-default:"4436"` + MailSlurperSMTPPort uint `yaml:"mailSlurperSMTPPort" env-default:"1025"` + CruxPostgresPort uint `yaml:"cruxPostgresPort" env-default:"5432"` MailSlurperAPIPort uint `yaml:"mailSlurperAPIPort" env-default:"4437"` - MailFromName string `yaml:"mailFromName" env-default:"dyrector.io - Platform"` - MailFromEmail string `yaml:"mailFromEmail" env-default:"noreply@example.com"` + KratosAdminPort uint `yaml:"kratosAdminPort" env-default:"4434"` + TraefikIsDockerSocketNamedPipe bool `yaml:"traefikIsDockerSocketNamedPipe" env-default:"false"` } const ( @@ -131,14 +130,15 @@ const ( func SettingsExists(settingsPath string) bool { settingsFilePath := SettingsFileLocation(settingsPath) - if _, err := os.Stat(settingsFilePath); err == nil { + _, err := os.Stat(settingsFilePath) + if err == nil { return true - } else if errors.Is(err, os.ErrNotExist) { - return false - } else { - log.Fatal().Err(err).Stack().Send() + } + if errors.Is(err, os.ErrNotExist) { return false } + log.Fatal().Err(err).Stack().Send() + return false } // SettingsFileLocation is assembling the location of the settings file diff --git a/golang/pkg/cli/container_defaults.go b/golang/pkg/cli/container_defaults.go index 6ade00bc83..5dac3f72b4 100644 --- a/golang/pkg/cli/container_defaults.go +++ b/golang/pkg/cli/container_defaults.go @@ -13,6 +13,7 @@ import ( "time" "github.com/AlekSi/pointer" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/client" "github.com/rs/zerolog/log" @@ -62,7 +63,7 @@ func GetCrux(state *State, args *ArgsFlags) containerbuilder.Builder { crux := baseContainer(state.Ctx, args). WithImage(fmt.Sprintf("%s:%s", state.Crux.Image, state.SettingsFile.Version)). WithName(state.Containers.Crux.Name). - WithRestartPolicy(containerbuilder.AlwaysRestartPolicy). + WithRestartPolicy(container.RestartPolicyAlways). WithEnv(getCruxEnvs(state, args)). WithNetworks([]string{state.SettingsFile.Network}). WithNetworkAliases(state.Containers.Crux.Name). @@ -110,8 +111,8 @@ func getCruxInitContainer(state *State, args *ArgsFlags) containerbuilder.Lifecy fmt.Sprintf("ENCRYPTION_SECRET_KEY=%s", state.SettingsFile.CruxEncryptionKey), }, state.EnvFile...) - return func(ctx context.Context, client client.APIClient, - parentCont containerbuilder.ParentContainer, + return func(ctx context.Context, _ client.APIClient, + _ containerbuilder.ParentContainer, ) error { cruxMigrate := baseContainer(ctx, args). WithImage(fmt.Sprintf("%s:%s", state.Crux.Image, state.SettingsFile.Version)). @@ -213,7 +214,7 @@ func GetCruxUI(state *State, args *ArgsFlags) containerbuilder.Builder { cruxUI := baseContainer(state.Ctx, args). WithImage(fmt.Sprintf("%s:%s", state.CruxUI.Image, state.SettingsFile.Version)). WithName(state.Containers.CruxUI.Name). - WithRestartPolicy(containerbuilder.AlwaysRestartPolicy). + WithRestartPolicy(container.RestartPolicyAlways). WithEnv(envs). WithNetworks([]string{state.SettingsFile.Network}). WithNetworkAliases(state.Containers.CruxUI.Name). @@ -281,7 +282,7 @@ func GetTraefik(state *State, args *ArgsFlags) containerbuilder.Builder { traefik := baseContainer(state.Ctx, args). WithImage("docker.io/library/traefik:v2.9"). WithName(state.Containers.Traefik.Name). - WithRestartPolicy(containerbuilder.AlwaysRestartPolicy). + WithRestartPolicy(container.RestartPolicyAlways). WithNetworks([]string{state.SettingsFile.Network}). WithNetworkAliases(state.Containers.Traefik.Name). WithMountPoints([]mount.Mount{{ @@ -296,7 +297,7 @@ func GetTraefik(state *State, args *ArgsFlags) containerbuilder.Builder { label.DyrectorioOrg + label.ContainerPrefix: args.Prefix, label.DyrectorioOrg + label.ServiceCategory: label.GetHiddenServiceCategory("internal"), }). - WithPostStartHooks(func(ctx context.Context, client client.APIClient, + WithPostStartHooks(func(ctx context.Context, _ client.APIClient, cont containerbuilder.ParentContainer, ) error { return CopyTraefikConfiguration( @@ -311,8 +312,8 @@ func GetTraefik(state *State, args *ArgsFlags) containerbuilder.Builder { if args.FullyContainerized { traefikHost := state.Containers.Traefik.Name traefik. - WithPostStartHooks(func(ctx context.Context, client client.APIClient, - cont containerbuilder.ParentContainer, + WithPostStartHooks(func(ctx context.Context, _ client.APIClient, + _ containerbuilder.ParentContainer, ) error { addr := fmt.Sprintf("http://%s:%d/api/status", traefikHost, state.SettingsFile.TraefikWebPort) return healthProbe(ctx, addr) @@ -338,7 +339,7 @@ func GetKratos(state *State, args *ArgsFlags) containerbuilder.Builder { kratos := baseContainer(state.Ctx, args). WithImage(fmt.Sprintf("%s:%s", state.Kratos.Image, state.SettingsFile.Version)). WithName(state.Containers.Kratos.Name). - WithRestartPolicy(containerbuilder.AlwaysRestartPolicy). + WithRestartPolicy(container.RestartPolicyAlways). WithEnv(getKratosEnvs(state)). WithNetworks([]string{state.SettingsFile.Network}). WithNetworkAliases(state.Containers.Kratos.Name). @@ -385,7 +386,7 @@ func getKratosInitContainer(state *State, args *ArgsFlags) containerbuilder.Life state.SettingsFile.KratosPostgresDB), }, state.EnvFile...) - return func(ctx context.Context, client client.APIClient, parentCont containerbuilder.ParentContainer) error { + return func(_ context.Context, _ client.APIClient, _ containerbuilder.ParentContainer) error { kratosMigrate := baseContainer(state.Ctx, args). WithImage(fmt.Sprintf("%s:%s", state.Kratos.Image, state.SettingsFile.Version)). WithName(state.Containers.KratosMigrate.Name). @@ -452,7 +453,7 @@ func GetMailSlurper(state *State, args *ArgsFlags) containerbuilder.Builder { mailslurper := baseContainer(state.Ctx, args). WithImage(mailSlurperImage). WithName(state.Containers.MailSlurper.Name). - WithRestartPolicy(containerbuilder.AlwaysRestartPolicy). + WithRestartPolicy(container.RestartPolicyAlways). WithNetworks([]string{state.SettingsFile.Network}). WithNetworkAliases(state.Containers.MailSlurper.Name). WithLabels(map[string]string{ @@ -563,7 +564,7 @@ func getBasePostgres(state *State, args *ArgsFlags) containerbuilder.Builder { basePostgres := baseContainer(state.Ctx, args). WithImage(postgresImage). WithNetworks([]string{state.SettingsFile.Network}). - WithRestartPolicy(containerbuilder.AlwaysRestartPolicy) + WithRestartPolicy(container.RestartPolicyAlways) return basePostgres } diff --git a/golang/pkg/crane/config/config.go b/golang/pkg/crane/config/config.go index 5bb1f98e0f..cf1c5fc8b8 100644 --- a/golang/pkg/crane/config/config.go +++ b/golang/pkg/crane/config/config.go @@ -8,17 +8,16 @@ import ( // Crane(kubernetes)-specific configuration options type Configuration struct { + FieldManagerName string `yaml:"fieldManagerName" env:"FIELD_MANAGER_NAME" env-default:"crane-dyrector-io"` + KeyIssuer string `yaml:"keyIssuer" env:"KEY_ISSUER" env-default:"co.dyrector.io/issuer"` + KubeConfig string `yaml:"kubeConfig" env:"KUBECONFIG" env-default:""` + OwnDeployment string `yaml:"ownDeployment" env:"CRANE_DEPLOYMENT_NAME"` + OwnNamespace string `yaml:"ownNamespace" env:"CRANE_DEPLOYMENT_NAMESPACE"` + SecretName string `yaml:"secretName" env:"SECRET_NAME" env-default:"dyrectorio-secret"` + Namespace string `yaml:"namespace" env:"SECRET_NAMESPACE" env-default:"dyrectorio"` config.CommonConfiguration - CraneInCluster bool `yaml:"craneInCluster" env:"CRANE_IN_CLUSTER" env-default:"false"` DefaultKubeTimeout time.Duration `yaml:"defaultKubeTimeout" env:"DEFAULT_KUBE_TIMEOUT" env-default:"2m"` - FieldManagerName string `yaml:"fieldManagerName" env:"FIELD_MANAGER_NAME" env-default:"crane-dyrector-io"` - ForceOnConflicts bool `yaml:"forceOnConflicts" env:"FORCE_ON_CONFLICTS" env-default:"true"` - KeyIssuer string `yaml:"keyIssuer" env:"KEY_ISSUER" env-default:"co.dyrector.io/issuer"` - KubeConfig string `yaml:"kubeConfig" env:"KUBECONFIG" env-default:""` TestTimeoutDuration time.Duration `yaml:"testTimeout" env:"TEST_TIMEOUT" env-default:"15s"` - OwnDeployment string `yaml:"ownDeployment" env:"CRANE_DEPLOYMENT_NAME"` - OwnNamespace string `yaml:"ownNamespace" env:"CRANE_DEPLOYMENT_NAMESPACE"` - // for injecting SecretPrivateKey - SecretName string `yaml:"secretName" env:"SECRET_NAME" env-default:"dyrectorio-secret"` - Namespace string `yaml:"namespace" env:"SECRET_NAMESPACE" env-default:"dyrectorio"` + CraneInCluster bool `yaml:"craneInCluster" env:"CRANE_IN_CLUSTER" env-default:"false"` + ForceOnConflicts bool `yaml:"forceOnConflicts" env:"FORCE_ON_CONFLICTS" env-default:"true"` } diff --git a/golang/pkg/crane/k8s/configmap.go b/golang/pkg/crane/k8s/configmap.go index 5598543eb3..ebe49f81cb 100644 --- a/golang/pkg/crane/k8s/configmap.go +++ b/golang/pkg/crane/k8s/configmap.go @@ -17,9 +17,9 @@ import ( // facade object for configmap management type configmap struct { ctx context.Context + appConfig *config.Configuration status string avail []string - appConfig *config.Configuration } func newConfigmap(ctx context.Context, cfg *config.Configuration) *configmap { @@ -76,7 +76,6 @@ func (cm *configmap) deployConfigMapRuntime(runtimeType v1.RuntimeConfigType, na return err } err = cm.deployConfigMapData(namespace, fmt.Sprintf("%v-%v", containerName, runtimeType), envList) - if err != nil { return err } diff --git a/golang/pkg/crane/k8s/delete_facade.go b/golang/pkg/crane/k8s/delete_facade.go index dfaa715422..97e4e64953 100644 --- a/golang/pkg/crane/k8s/delete_facade.go +++ b/golang/pkg/crane/k8s/delete_facade.go @@ -15,7 +15,6 @@ import ( type DeleteFacade struct { ctx context.Context - name string deployment *Deployment namespace *Namespace service *Service @@ -23,6 +22,7 @@ type DeleteFacade struct { ingress *ingress pvc *PVC appConfig *config.Configuration + name string } func NewDeleteFacade(ctx context.Context, namespace, name string, cfg *config.Configuration) *DeleteFacade { diff --git a/golang/pkg/crane/k8s/deploy_facade.go b/golang/pkg/crane/k8s/deploy_facade.go index 7e51932967..5a922417d1 100644 --- a/golang/pkg/crane/k8s/deploy_facade.go +++ b/golang/pkg/crane/k8s/deploy_facade.go @@ -19,28 +19,28 @@ import ( type DeployFacade struct { ctx context.Context - params *DeployFacadeParams + secret *Secret client *Client - image string deployment *Deployment namespace *Namespace service *Service configmap *configmap ingress *ingress - secret *Secret + params *DeployFacadeParams pvc *PVC ServiceMonitor *ServiceMonitor appConfig *config.Configuration + image string } type DeployFacadeParams struct { Ctx context.Context - Image string - InstanceConfig v1.InstanceConfig - ContainerConfig v1.ContainerConfig RuntimeConfig *string imagePullSecrets *imageHelper.RegistryAuth + Image string Issuer string + InstanceConfig v1.InstanceConfig + ContainerConfig v1.ContainerConfig } func NewDeployFacade(params *DeployFacadeParams, cfg *config.Configuration) *DeployFacade { diff --git a/golang/pkg/crane/k8s/deployment.go b/golang/pkg/crane/k8s/deployment.go index 0aea3dabe0..235465183c 100644 --- a/golang/pkg/crane/k8s/deployment.go +++ b/golang/pkg/crane/k8s/deployment.go @@ -39,8 +39,8 @@ var ErrPodHasNoOwner = errors.New("pod has no owner") // facade object for Deployment management type Deployment struct { ctx context.Context - status string appConfig *config.Configuration + status string } func NewDeployment(ctx context.Context, cfg *config.Configuration) *Deployment { @@ -48,19 +48,19 @@ func NewDeployment(ctx context.Context, cfg *config.Configuration) *Deployment { } type DeploymentParams struct { - namespace string - image string + volumes map[string]v1.Volume + annotations map[string]string containerConfig *v1.ContainerConfig + labels map[string]string pullSecretName string - configMapsEnv []string + namespace string + image string + issuer string secrets []string - volumes map[string]v1.Volume + configMapsEnv []string portList []builder.PortBinding command []string args []string - labels map[string]string - annotations map[string]string - issuer string } func (d *Deployment) DeployDeployment(p *DeploymentParams) error { @@ -74,7 +74,7 @@ func (d *Deployment) DeployDeployment(p *DeploymentParams) error { annot := map[string]string{} - if len(p.issuer) > 0 { + if p.issuer != "" { annot[d.appConfig.KeyIssuer] = p.issuer } diff --git a/golang/pkg/crane/k8s/ingress.go b/golang/pkg/crane/k8s/ingress.go index 203c367a26..6742fc1b7f 100644 --- a/golang/pkg/crane/k8s/ingress.go +++ b/golang/pkg/crane/k8s/ingress.go @@ -23,20 +23,26 @@ import ( // facade object for ingress management type ingress struct { ctx context.Context - status string client *Client appConfig *config.Configuration + status string } type DeployIngressOptions struct { - namespace, containerName, ingressName, ingressHost, ingressPath, uploadLimit string - stripPrefix bool - port uint16 - portList []int32 - tls, proxyHeaders bool - customHeaders []string - labels map[string]string - annotations map[string]string + annotations map[string]string + labels map[string]string + containerName string + ingressName string + ingressHost string + ingressPath string + uploadLimit string + namespace string + customHeaders []string + portList []int32 + port uint16 + stripPrefix bool + proxyHeaders bool + tls bool } func newIngress(ctx context.Context, client *Client) *ingress { diff --git a/golang/pkg/crane/k8s/log.go b/golang/pkg/crane/k8s/log.go index 69b5aef5a3..d29785a7c6 100644 --- a/golang/pkg/crane/k8s/log.go +++ b/golang/pkg/crane/k8s/log.go @@ -26,11 +26,10 @@ import ( const LogBufferSize = 2048 type KubeContainerLogReader struct { + grpc.ContainerLogReader EventChannel chan grpc.ContainerLogEvent - LogStreams []io.ReadCloser ErrorGroup *errgroup.Group - - grpc.ContainerLogReader + LogStreams []io.ReadCloser } func (kubeReader *KubeContainerLogReader) Next() <-chan grpc.ContainerLogEvent { diff --git a/golang/pkg/crane/k8s/namespace.go b/golang/pkg/crane/k8s/namespace.go index 7968e0749e..ac35accb54 100644 --- a/golang/pkg/crane/k8s/namespace.go +++ b/golang/pkg/crane/k8s/namespace.go @@ -19,8 +19,8 @@ import ( type Namespace struct { ctx context.Context client *Client - name string appConfig *config.Configuration + name string } // namespace entity @@ -74,7 +74,6 @@ func (n *Namespace) DeployNamespace(name string) error { FieldManager: n.appConfig.FieldManagerName, Force: n.appConfig.ForceOnConflicts, }) - if err != nil { return err } diff --git a/golang/pkg/crane/k8s/pvc.go b/golang/pkg/crane/k8s/pvc.go index a0f2efbe08..87b82e7e0d 100644 --- a/golang/pkg/crane/k8s/pvc.go +++ b/golang/pkg/crane/k8s/pvc.go @@ -19,10 +19,10 @@ import ( type PVC struct { ctx context.Context client *Client - status string requested map[string]v1.Volume avail map[string]v1.Volume appConfig *config.Configuration + status string } func NewPVC(ctx context.Context, client *Client) *PVC { diff --git a/golang/pkg/crane/k8s/secret.go b/golang/pkg/crane/k8s/secret.go index 31ef8e455b..69db5f9a70 100644 --- a/golang/pkg/crane/k8s/secret.go +++ b/golang/pkg/crane/k8s/secret.go @@ -43,8 +43,8 @@ type DockerConfigEntry struct { type Secret struct { ctx context.Context client *Client - avail []string appConfig *config.Configuration + avail []string } func NewSecret(ctx context.Context, client *Client) *Secret { diff --git a/golang/pkg/crane/k8s/service.go b/golang/pkg/crane/k8s/service.go index aa3e696117..e8bc54d9aa 100644 --- a/golang/pkg/crane/k8s/service.go +++ b/golang/pkg/crane/k8s/service.go @@ -24,10 +24,10 @@ import ( type Service struct { ctx context.Context client *Client + appConfig *config.Configuration status string portsBound []int32 portNames []string - appConfig *config.Configuration } func NewService(ctx context.Context, client *Client) *Service { @@ -35,15 +35,15 @@ func NewService(ctx context.Context, client *Client) *Service { } type ServiceParams struct { + LBAnnotations map[string]string + labels map[string]string + annotations map[string]string namespace string name string selector string portBindings []builder.PortBinding portRanges []builder.PortRangeBinding useLB bool - LBAnnotations map[string]string - labels map[string]string - annotations map[string]string } func (s *Service) DeployService(params *ServiceParams) error { diff --git a/golang/pkg/crane/k8s/volume_helper.go b/golang/pkg/crane/k8s/volume_helper.go index 0716f9294e..f2c1a81f0c 100644 --- a/golang/pkg/crane/k8s/volume_helper.go +++ b/golang/pkg/crane/k8s/volume_helper.go @@ -20,7 +20,7 @@ func mapShortNotationToVolumeMap(volumes []string) map[string]v1.Volume { var volumeType v1.VolumeType - if len(name) > 0 { + if name != "" { switch name[0] { case '@': volumeType = v1.ReadWriteManyVolumeType diff --git a/golang/pkg/dagent/config/config.go b/golang/pkg/dagent/config/config.go index ce02cafa72..364aea7860 100644 --- a/golang/pkg/dagent/config/config.go +++ b/golang/pkg/dagent/config/config.go @@ -6,20 +6,19 @@ import ( // Dagent(docker)-specific configuration options type Configuration struct { - config.CommonConfiguration - DataMountPath string `yaml:"dataMountPath" env:"DATA_MOUNT_PATH" env-default:"/srv/dagent"` + WebhookToken string `yaml:"webhookToken" env:"WEBHOOK_TOKEN" env-default:""` + TraefikAcmeMail string `yaml:"traefikAcmeMail" env:"TRAEFIK_ACME_MAIL" env-default:""` HostDockerSockPath string `yaml:"hostDockerSockPath" env:"HOST_DOCKER_SOCK_PATH" env-default:"/var/run/docker.sock"` InternalMountPath string `yaml:"internalMountPath" env:"INTERNAL_MOUNT_PATH" env-default:"/srv/dagent"` - LogDefaultSkip uint64 `yaml:"logDefaultSkip" env:"LOG_DEFAULT_SKIP" env-default:"0"` - LogDefaultTake uint64 `yaml:"logDefaultTake" env:"LOG_DEFAULT_TAKE" env-default:"100"` - TraefikAcmeMail string `yaml:"traefikAcmeMail" env:"TRAEFIK_ACME_MAIL" env-default:""` - TraefikEnabled bool `yaml:"traefikEnabled" env:"TRAEFIK_ENABLED" env-default:"false"` - // set to "DEBUG" to access the Traefik dashboard - TraefikLogLevel string `yaml:"traefikLogLevel" env:"TRAEFIK_LOG_LEVEL" env-default:"INFO"` - TraefikTLS bool `yaml:"traefikTLS" env:"TRAEFIK_TLS" env-default:"false"` - TraefikPort uint16 `yaml:"traefikPort" env:"TRAEFIK_PORT" env-default:"80"` - TraefikTLSPort uint16 `yaml:"traefikTLSPort" env:"TRAEFIK_TLS_PORT" env-default:"443"` - WebhookToken string `yaml:"webhookToken" env:"WEBHOOK_TOKEN" env-default:""` + DataMountPath string `yaml:"dataMountPath" env:"DATA_MOUNT_PATH" env-default:"/srv/dagent"` + TraefikLogLevel string `yaml:"traefikLogLevel" env:"TRAEFIK_LOG_LEVEL" env-default:"INFO"` + config.CommonConfiguration + LogDefaultSkip uint64 `yaml:"logDefaultSkip" env:"LOG_DEFAULT_SKIP" env-default:"0"` + LogDefaultTake uint64 `yaml:"logDefaultTake" env:"LOG_DEFAULT_TAKE" env-default:"100"` + TraefikPort uint16 `yaml:"traefikPort" env:"TRAEFIK_PORT" env-default:"80"` + TraefikTLSPort uint16 `yaml:"traefikTLSPort" env:"TRAEFIK_TLS_PORT" env-default:"443"` + TraefikEnabled bool `yaml:"traefikEnabled" env:"TRAEFIK_ENABLED" env-default:"false"` + TraefikTLS bool `yaml:"traefikTLS" env:"TRAEFIK_TLS" env-default:"false"` } const filePermReadWriteOnlyByOwner = 0o600 diff --git a/golang/pkg/dagent/config/secret_test.go b/golang/pkg/dagent/config/secret_test.go index 3c24bf61cb..c9d894ce94 100644 --- a/golang/pkg/dagent/config/secret_test.go +++ b/golang/pkg/dagent/config/secret_test.go @@ -12,6 +12,7 @@ import ( "github.com/dyrector-io/dyrectorio/golang/pkg/dagent/config" ) +//nolint:gosec const ( missingKeyFile = "missing-file.key" testPrivateKey = `-----BEGIN PGP PRIVATE KEY BLOCK----- diff --git a/golang/pkg/dagent/update/update.go b/golang/pkg/dagent/update/update.go index 4a96a7bb7e..9c51dd6405 100644 --- a/golang/pkg/dagent/update/update.go +++ b/golang/pkg/dagent/update/update.go @@ -17,7 +17,7 @@ import ( "github.com/dyrector-io/dyrectorio/golang/pkg/dagent/utils" "github.com/dyrector-io/dyrectorio/protobuf/go/agent" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/client" "github.com/docker/docker/errdefs" @@ -36,11 +36,11 @@ func getUniqueContainerName(ctx context.Context, cli client.APIClient, base stri count := 0 for { - container, err := docker.GetContainerByName(ctx, cli, name) + cont, err := docker.GetContainerByName(ctx, cli, name) if err != nil { return base, err } - if container == nil { + if cont == nil { return name, nil } @@ -91,7 +91,7 @@ func createNewDAgentContainer(ctx context.Context, cli client.APIClient, oldCont builder := containerbuilder.NewDockerBuilder(ctx). WithClient(cli). WithImage(imageWithTag). - WithRestartPolicy(containerbuilder.RestartPolicyName(inspect.HostConfig.RestartPolicy.Name)). + WithRestartPolicy(inspect.HostConfig.RestartPolicy.Name). WithName(name). WithEnv(inspect.Config.Env). WithMountPoints(mounts) @@ -125,12 +125,12 @@ func GetSelfContainerName(ctx context.Context) (string, error) { return "", err } - container, err := utils.GetOwnContainer(ctx, cli) + cont, err := utils.GetOwnContainer(ctx, cli) if err != nil { return "", err } - name := container.Names[0] + name := cont.Names[0] return name, nil } @@ -146,12 +146,12 @@ func ExecuteSelfUpdate(ctx context.Context, cli client.APIClient, command *agent return nil } - container, err := utils.GetOwnContainer(ctx, cli) + cont, err := utils.GetOwnContainer(ctx, cli) if err != nil { return err } - newImage, err := image.ExpandImageNameWithTag(container.Image, tag) + newImage, err := image.ExpandImageNameWithTag(cont.Image, tag) if err != nil { return err } @@ -177,7 +177,7 @@ func ExecuteSelfUpdate(ctx context.Context, cli client.APIClient, command *agent log.Warn().Msg("Updating matching image tags") } - originalName := container.Names[0] + originalName := cont.Names[0] rename, err := getUniqueContainerName(ctx, cli, originalName+"-update") if err != nil { @@ -186,14 +186,14 @@ func ExecuteSelfUpdate(ctx context.Context, cli client.APIClient, command *agent log.Debug().Str("oldName", originalName).Str("newName", rename).Msg("Renaming DAgent container") - err = cli.ContainerRename(ctx, container.ID, rename) + err = cli.ContainerRename(ctx, cont.ID, rename) if err != nil { return err } - err = createNewDAgentContainer(ctx, cli, container.ID, originalName, newImage) + err = createNewDAgentContainer(ctx, cli, cont.ID, originalName, newImage) if err != nil { - renameErr := cli.ContainerRename(ctx, container.ID, originalName) + renameErr := cli.ContainerRename(ctx, cont.ID, originalName) if renameErr != nil { return fmt.Errorf("%s (%s)", err.Error(), renameErr.Error()) } @@ -236,7 +236,7 @@ func RemoveSelf(ctx context.Context, options grpc.UpdateOptions) error { return err } - err = cli.ContainerRemove(ctx, self.ID, types.ContainerRemoveOptions{ + err = cli.ContainerRemove(ctx, self.ID, container.RemoveOptions{ Force: true, }) if err != nil { diff --git a/golang/pkg/dagent/update/update_test.go b/golang/pkg/dagent/update/update_test.go index f49b9a0005..3cb06b3fa5 100644 --- a/golang/pkg/dagent/update/update_test.go +++ b/golang/pkg/dagent/update/update_test.go @@ -13,11 +13,12 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/network" "github.com/docker/docker/client" "github.com/docker/docker/errdefs" "github.com/dyrector-io/dyrectorio/golang/internal/grpc" - "github.com/dyrector-io/dyrectorio/golang/internal/helper/image" + imagehelper "github.com/dyrector-io/dyrectorio/golang/internal/helper/image" "github.com/dyrector-io/dyrectorio/golang/pkg/dagent/update" "github.com/dyrector-io/dyrectorio/protobuf/go/agent" v1 "github.com/opencontainers/image-spec/specs-go/v1" @@ -68,7 +69,7 @@ func NewMockClient(opts ...MockClientOpt) client.APIClient { return cli } -func (d *DockerClientMock) ContainerList(ctx context.Context, opts types.ContainerListOptions) ([]types.Container, error) { +func (d *DockerClientMock) ContainerList(ctx context.Context, opts container.ListOptions) ([]types.Container, error) { imgs := []types.Container{} if len(opts.Filters.Get("name")) > 0 && opts.Filters.Get("name")[0] == "^own-container-update$" { @@ -85,11 +86,11 @@ func (d *DockerClientMock) ContainerList(ctx context.Context, opts types.Contain return imgs, nil } -func (d *DockerClientMock) ImageList(ctx context.Context, opts types.ImageListOptions) ([]types.ImageSummary, error) { +func (d *DockerClientMock) ImageList(ctx context.Context, opts types.ImageListOptions) ([]image.Summary, error) { if d.denyImageExistence { - return []types.ImageSummary{}, nil + return []image.Summary{}, nil } - return []types.ImageSummary{ + return []image.Summary{ {}, }, nil } @@ -128,7 +129,7 @@ func (d *DockerClientMock) ContainerCreate(context.Context, *container.Config, * return container.CreateResponse{}, nil } -func (d *DockerClientMock) ContainerStart(context.Context, string, types.ContainerStartOptions) error { +func (d *DockerClientMock) ContainerStart(context.Context, string, container.StartOptions) error { return nil } @@ -136,7 +137,7 @@ type DockerClientErrMock struct { client.APIClient } -func (d *DockerClientErrMock) ContainerList(ctx context.Context, opts types.ContainerListOptions) ([]types.Container, error) { +func (d *DockerClientErrMock) ContainerList(ctx context.Context, opts container.ListOptions) ([]types.Container, error) { return []types.Container{{}}, errors.New("test error") } @@ -164,7 +165,7 @@ func TestSelfUpdateInvalid(t *testing.T) { Tag: "-----", TimeoutSeconds: 1, }, defaultUpdateOptions) - assert.ErrorIs(t, update.RewriteUpdateErrors(err), image.ErrInvalidTag) + assert.ErrorIs(t, update.RewriteUpdateErrors(err), imagehelper.ErrInvalidTag) } func TestSelfUpdateOK(t *testing.T) { diff --git a/golang/pkg/dagent/utils/container.go b/golang/pkg/dagent/utils/container.go index a0a7ad83c3..7f715de6ee 100644 --- a/golang/pkg/dagent/utils/container.go +++ b/golang/pkg/dagent/utils/container.go @@ -25,16 +25,11 @@ const ( ) type TraefikDeployRequest struct { - // LogLevel defaults to INFO LogLevel string `json:"logLevel"` - // if services exposed with certs, default: false - TLS bool `json:"TLS"` - // the email address for expiry notifications, sent by acme AcmeMail string `json:"acmeMail" binding:"required_if=TLS true"` - // HTTP port - Port uint16 `json:"port"` - // HTTPS port - TLSPort uint16 `json:"tlsPort"` + Port uint16 `json:"port"` + TLSPort uint16 `json:"tlsPort"` + TLS bool `json:"TLS"` } type UnknownContainerError struct{} @@ -109,7 +104,7 @@ func ExecTraefik(ctx context.Context, traefikDeployReq TraefikDeployRequest, cfg builder := containerbuilder.NewDockerBuilder(ctx).WithImage("index.docker.io/library/traefik:v2.8.0"). WithName("traefik"). WithMountPoints(mounts). - WithRestartPolicy(containerbuilder.AlwaysRestartPolicy). + WithRestartPolicy(container.RestartPolicyAlways). WithAutoRemove(false). WithoutConflict(). WithNetworkMode("host"). diff --git a/golang/pkg/dagent/utils/docker.go b/golang/pkg/dagent/utils/docker.go index 1a910bf338..4bd0fbedfa 100644 --- a/golang/pkg/dagent/utils/docker.go +++ b/golang/pkg/dagent/utils/docker.go @@ -33,14 +33,14 @@ import ( "github.com/dyrector-io/dyrectorio/golang/internal/logdefer" "github.com/dyrector-io/dyrectorio/golang/internal/mapper" "github.com/dyrector-io/dyrectorio/golang/internal/util" - "github.com/dyrector-io/dyrectorio/golang/pkg/builder/container" + dockerbuilder "github.com/dyrector-io/dyrectorio/golang/pkg/builder/container" "github.com/dyrector-io/dyrectorio/golang/pkg/dagent/caps" "github.com/dyrector-io/dyrectorio/golang/pkg/dagent/config" "github.com/dyrector-io/dyrectorio/protobuf/go/agent" "github.com/dyrector-io/dyrectorio/protobuf/go/common" "github.com/docker/docker/api/types" - dockerContainer "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/client" @@ -70,7 +70,7 @@ func GetContainerLogs(name string, skip, take uint) []string { const BASE = 10 tail := skip + take - options := types.ContainerLogsOptions{ + options := container.LogsOptions{ ShowStderr: true, ShowStdout: true, Tail: strconv.FormatUint(uint64(tail), BASE), @@ -82,7 +82,7 @@ func GetContainerLogs(name string, skip, take uint) []string { } defer logdefer.LogDeferredErr(logs.Close, log.Warn(), "error closing container log reader") - return container.ReadDockerLogsFromReadCloser(logs, int(skip), int(take)) + return dockerbuilder.ReadDockerLogsFromReadCloser(logs, int(skip), int(take)) } func CopyToContainer(ctx context.Context, name string, meta v1.UploadFileData, fileHeader *multipart.FileHeader) error { @@ -396,7 +396,7 @@ func DeployImage(ctx context.Context, } } - builder := container.NewDockerBuilder(ctx) + builder := dockerbuilder.NewDockerBuilder(ctx) networkMode, networks := setNetwork(deployImageRequest) labels, err := setImageLabels(expandedImageName, deployImageRequest, cfg) if err != nil { @@ -469,14 +469,14 @@ func setNetwork(deployImageRequest *v1.DeployImageRequest) (networkMode string, return networkMode, deployImageRequest.ContainerConfig.Networks } -func WithInitContainers(dc container.Builder, containerConfig *v1.ContainerConfig, +func WithInitContainers(dc dockerbuilder.Builder, containerConfig *v1.ContainerConfig, dog *dogger.DeploymentLogger, envMap map[string]string, cfg *config.Configuration, ) { - initFuncs := []container.LifecycleFunc{} + initFuncs := []dockerbuilder.LifecycleFunc{} if containerConfig.ImportContainer != nil { initFuncs = append(initFuncs, func(ctx context.Context, client client.APIClient, - parentCont container.ParentContainer, + parentCont dockerbuilder.ParentContainer, ) error { if initError := spawnImportContainer(ctx, client, parentCont.Name, parentCont.MountList, containerConfig.ImportContainer, dog, cfg); initError != nil { @@ -490,7 +490,7 @@ func WithInitContainers(dc container.Builder, containerConfig *v1.ContainerConfi if len(containerConfig.InitContainers) > 0 { initFuncs = append(initFuncs, func(ctx context.Context, client client.APIClient, - parentCont container.ParentContainer, + parentCont dockerbuilder.ParentContainer, ) error { for i := range containerConfig.InitContainers { var initContConfig *InitContainerConfig @@ -566,7 +566,7 @@ func mountStrToDocker(mountIn []string, containerPreName, containerName string, mountStr := mountIn[i] if strings.ContainsRune(mountStr, '|') { mountSplit := strings.Split(mountStr, "|") - if len(mountSplit[0]) > 0 && len(mountSplit[1]) > 0 { + if mountSplit[0] != "" && mountSplit[1] != "" { containerPath := path.Join(cfg.InternalMountPath, containerPreName, containerName, mountSplit[0]) hostPath := "" if strings.HasPrefix(mountSplit[0], "/") { @@ -593,7 +593,7 @@ func mountStrToDocker(mountIn []string, containerPreName, containerName string, func createRuntimeConfigFileOnHost(mounts []mount.Mount, containerName, containerPreName, runtimeConfig string, cfg *config.Configuration, ) ([]mount.Mount, error) { - if len(runtimeConfig) > 0 { + if runtimeConfig != "" { configDir := path.Join(cfg.InternalMountPath, containerPreName, containerName, "config") _, err := os.Stat(configDir) if os.IsNotExist(err) { @@ -713,7 +713,7 @@ func SecretList(ctx context.Context, prefix, name string) ([]string, error) { return nil, err } - containers, err := cli.ContainerList(ctx, types.ContainerListOptions{ + containers, err := cli.ContainerList(ctx, container.ListOptions{ All: true, Filters: filters.NewArgs(filters.KeyValuePair{Key: "name", Value: fmt.Sprintf("^/?%s-%s$", prefix, name)}), }) @@ -756,11 +756,11 @@ func ContainerCommand(ctx context.Context, command *common.ContainerCommandReque } if operation == common.ContainerOperation_START_CONTAINER { - err = cli.ContainerStart(ctx, cont.ID, types.ContainerStartOptions{}) + err = cli.ContainerStart(ctx, cont.ID, container.StartOptions{}) } else if operation == common.ContainerOperation_STOP_CONTAINER { - err = cli.ContainerStop(ctx, cont.ID, dockerContainer.StopOptions{}) + err = cli.ContainerStop(ctx, cont.ID, container.StopOptions{}) } else if operation == common.ContainerOperation_RESTART_CONTAINER { - err = cli.ContainerRestart(ctx, cont.ID, dockerContainer.StopOptions{}) + err = cli.ContainerRestart(ctx, cont.ID, container.StopOptions{}) } else { log.Error().Str("operation", operation.String()).Str("prefix", prefix).Str("name", name).Msg("Unknown operation") } @@ -910,7 +910,7 @@ func ContainerLog(ctx context.Context, request *agent.ContainerLogRequest) (*grp eventChannel := make(chan grpc.ContainerLogEvent) - reader, err := cli.ContainerLogs(ctx, containerID, types.ContainerLogsOptions{ + reader, err := cli.ContainerLogs(ctx, containerID, container.LogsOptions{ ShowStderr: true, ShowStdout: true, Follow: streaming, diff --git a/golang/pkg/dagent/utils/dockerhelper.go b/golang/pkg/dagent/utils/dockerhelper.go index 0cc92c1dc3..652a3a0069 100644 --- a/golang/pkg/dagent/utils/dockerhelper.go +++ b/golang/pkg/dagent/utils/dockerhelper.go @@ -31,7 +31,7 @@ func getContainerIdentifierFromEvent(event *events.Message) *common.ContainerIde name, hasValue := event.Actor.Attributes["name"] if !hasValue { return nil - } else if len(prefix) > 0 { + } else if prefix != "" { name = strings.TrimPrefix(name, prefix+"-") } @@ -76,7 +76,7 @@ func messageToStateItem(ctx context.Context, prefix string, event *events.Messag return createRemovedState(containerID), nil } - containerState := mapper.MapDockerContainerEventToContainerState(event.Action) + containerState := mapper.MapDockerContainerEventToContainerState(string(event.Action)) // Ingored events are mapped to unspecified, for example tty, exec, oom, etc. if containerState == common.ContainerState_CONTAINER_STATE_UNSPECIFIED { return nil, nil diff --git a/golang/pkg/dagent/utils/dockerhelper_test.go b/golang/pkg/dagent/utils/dockerhelper_test.go index 337e4092e3..900ae8e219 100644 --- a/golang/pkg/dagent/utils/dockerhelper_test.go +++ b/golang/pkg/dagent/utils/dockerhelper_test.go @@ -1,193 +1,194 @@ -//go:build unit -// +build unit - -package utils - -import ( - "context" - "testing" - - "github.com/docker/docker/api/types/events" - "github.com/dyrector-io/dyrectorio/golang/internal/label" - "github.com/stretchr/testify/assert" - - dockerHelper "github.com/dyrector-io/dyrectorio/golang/internal/helper/docker" - containerbuilder "github.com/dyrector-io/dyrectorio/golang/pkg/builder/container" - "github.com/dyrector-io/dyrectorio/protobuf/go/common" -) - -const nginxImage = "ghcr.io/dyrector-io/mirror/nginx:mainline-alpine" - -func TestGetContainerIdentifierFromEventEmptyAttributes(t *testing.T) { - event := events.Message{ - Actor: events.Actor{ - Attributes: map[string]string{}, - }, - } - - id := GetContainerIdentifierFromEvent(&event) - assert.Nil(t, id) -} - -func TestGetContainerIdentifierFromEventPrefix(t *testing.T) { - event := events.Message{ - Actor: events.Actor{ - Attributes: map[string]string{ - label.DyrectorioOrg + label.ContainerPrefix: "prefix", - }, - }, - } - - id := GetContainerIdentifierFromEvent(&event) - assert.Nil(t, id) -} - -func TestGetContainerIdentifierFromEventName(t *testing.T) { - event := events.Message{ - Actor: events.Actor{ - Attributes: map[string]string{ - "name": "prefix-name", - }, - }, - } - - id := GetContainerIdentifierFromEvent(&event) - assert.NotNil(t, id) - assert.Equal(t, "prefix-name", id.Name) - assert.Equal(t, "", id.Prefix) -} - -func TestGetContainerIdentifierFromEventBoth(t *testing.T) { - event := events.Message{ - Actor: events.Actor{ - Attributes: map[string]string{ - label.DyrectorioOrg + label.ContainerPrefix: "prefix", - "name": "prefix-name", - }, - }, - } - - id := GetContainerIdentifierFromEvent(&event) - assert.NotNil(t, id) - assert.Equal(t, "name", id.Name) - assert.Equal(t, "prefix", id.Prefix) -} - -func TestEventToMessageNonContainer(t *testing.T) { - event := events.Message{ - Type: "non-container", - } - - message, err := EventToMessage(context.Background(), "", &event) - assert.Nil(t, message) - assert.Nil(t, err) -} - -func TestEventToMessageNoName(t *testing.T) { - event := events.Message{ - Type: "container", - Actor: events.Actor{ - Attributes: map[string]string{}, - }, - } - - message, err := EventToMessage(context.Background(), "", &event) - assert.Nil(t, message) - assert.EqualError(t, err, "event has no container name") -} - -func TestEventToMessageActionDestroy(t *testing.T) { - event := events.Message{ - Type: "container", - Action: "destroy", - Actor: events.Actor{ - Attributes: map[string]string{ - "name": "prefix-name", - }, - }, - } - - message, err := EventToMessage(context.Background(), "", &event) - assert.NoError(t, err) - - expected := &common.ContainerStateItem{ - Id: &common.ContainerIdentifier{ - Name: "prefix-name", - Prefix: "", - }, - Command: "", - CreatedAt: nil, - State: common.ContainerState_REMOVED, - Reason: "", - Status: "", - Ports: []*common.ContainerStateItemPort{}, - ImageName: "", - ImageTag: "", - } - - assert.Equal(t, expected, message) -} - -func TestEventToMessageUnknownAction(t *testing.T) { - event := events.Message{ - Type: "container", - Action: "unknown-action", - Actor: events.Actor{ - Attributes: map[string]string{ - "name": "prefix-name", - }, - }, - } - - message, err := EventToMessage(context.Background(), "", &event) - assert.Nil(t, message) - assert.Nil(t, err) -} - -func TestEventToMessageNoContainer(t *testing.T) { - event := events.Message{ - Type: "container", - Action: "unknown-action", - Actor: events.Actor{ - ID: "container-id-does-not-exist", - Attributes: map[string]string{ - "name": "prefix-name", - }, - }, - } - - message, err := EventToMessage(context.Background(), "", &event) - assert.Nil(t, message) - assert.Nil(t, err) -} - -func TestEventToMessageContainer(t *testing.T) { - builder, err := containerbuilder.NewDockerBuilder(context.Background()). - WithImage(nginxImage). - WithName("test-event-to-message"). - WithRestartPolicy(containerbuilder.NoRestartPolicy). - Create() - - assert.NoError(t, err) - - containerID := *builder.GetContainerID() - - event := events.Message{ - Type: "container", - Action: "create", - Actor: events.Actor{ - ID: containerID, - Attributes: map[string]string{ - "name": "prefix-name", - }, - }, - } - - message, err := EventToMessage(context.Background(), "", &event) - - dockerHelper.DeleteContainerByID(context.Background(), nil, containerID) - - assert.Nil(t, err) - assert.NotNil(t, message) - assert.Equal(t, common.ContainerState_WAITING, message.State) -} +//go:build unit +// +build unit + +package utils + +import ( + "context" + "testing" + + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/events" + "github.com/dyrector-io/dyrectorio/golang/internal/label" + "github.com/stretchr/testify/assert" + + dockerHelper "github.com/dyrector-io/dyrectorio/golang/internal/helper/docker" + containerbuilder "github.com/dyrector-io/dyrectorio/golang/pkg/builder/container" + "github.com/dyrector-io/dyrectorio/protobuf/go/common" +) + +const nginxImage = "ghcr.io/dyrector-io/mirror/nginx:mainline-alpine" + +func TestGetContainerIdentifierFromEventEmptyAttributes(t *testing.T) { + event := events.Message{ + Actor: events.Actor{ + Attributes: map[string]string{}, + }, + } + + id := GetContainerIdentifierFromEvent(&event) + assert.Nil(t, id) +} + +func TestGetContainerIdentifierFromEventPrefix(t *testing.T) { + event := events.Message{ + Actor: events.Actor{ + Attributes: map[string]string{ + label.DyrectorioOrg + label.ContainerPrefix: "prefix", + }, + }, + } + + id := GetContainerIdentifierFromEvent(&event) + assert.Nil(t, id) +} + +func TestGetContainerIdentifierFromEventName(t *testing.T) { + event := events.Message{ + Actor: events.Actor{ + Attributes: map[string]string{ + "name": "prefix-name", + }, + }, + } + + id := GetContainerIdentifierFromEvent(&event) + assert.NotNil(t, id) + assert.Equal(t, "prefix-name", id.Name) + assert.Equal(t, "", id.Prefix) +} + +func TestGetContainerIdentifierFromEventBoth(t *testing.T) { + event := events.Message{ + Actor: events.Actor{ + Attributes: map[string]string{ + label.DyrectorioOrg + label.ContainerPrefix: "prefix", + "name": "prefix-name", + }, + }, + } + + id := GetContainerIdentifierFromEvent(&event) + assert.NotNil(t, id) + assert.Equal(t, "name", id.Name) + assert.Equal(t, "prefix", id.Prefix) +} + +func TestEventToMessageNonContainer(t *testing.T) { + event := events.Message{ + Type: "non-container", + } + + message, err := EventToMessage(context.Background(), "", &event) + assert.Nil(t, message) + assert.Nil(t, err) +} + +func TestEventToMessageNoName(t *testing.T) { + event := events.Message{ + Type: "container", + Actor: events.Actor{ + Attributes: map[string]string{}, + }, + } + + message, err := EventToMessage(context.Background(), "", &event) + assert.Nil(t, message) + assert.EqualError(t, err, "event has no container name") +} + +func TestEventToMessageActionDestroy(t *testing.T) { + event := events.Message{ + Type: "container", + Action: "destroy", + Actor: events.Actor{ + Attributes: map[string]string{ + "name": "prefix-name", + }, + }, + } + + message, err := EventToMessage(context.Background(), "", &event) + assert.NoError(t, err) + + expected := &common.ContainerStateItem{ + Id: &common.ContainerIdentifier{ + Name: "prefix-name", + Prefix: "", + }, + Command: "", + CreatedAt: nil, + State: common.ContainerState_REMOVED, + Reason: "", + Status: "", + Ports: []*common.ContainerStateItemPort{}, + ImageName: "", + ImageTag: "", + } + + assert.Equal(t, expected, message) +} + +func TestEventToMessageUnknownAction(t *testing.T) { + event := events.Message{ + Type: "container", + Action: "unknown-action", + Actor: events.Actor{ + Attributes: map[string]string{ + "name": "prefix-name", + }, + }, + } + + message, err := EventToMessage(context.Background(), "", &event) + assert.Nil(t, message) + assert.Nil(t, err) +} + +func TestEventToMessageNoContainer(t *testing.T) { + event := events.Message{ + Type: "container", + Action: "unknown-action", + Actor: events.Actor{ + ID: "container-id-does-not-exist", + Attributes: map[string]string{ + "name": "prefix-name", + }, + }, + } + + message, err := EventToMessage(context.Background(), "", &event) + assert.Nil(t, message) + assert.Nil(t, err) +} + +func TestEventToMessageContainer(t *testing.T) { + builder, err := containerbuilder.NewDockerBuilder(context.Background()). + WithImage(nginxImage). + WithName("test-event-to-message"). + WithRestartPolicy(container.RestartPolicyDisabled). + Create() + + assert.NoError(t, err) + + containerID := *builder.GetContainerID() + + event := events.Message{ + Type: "container", + Action: "create", + Actor: events.Actor{ + ID: containerID, + Attributes: map[string]string{ + "name": "prefix-name", + }, + }, + } + + message, err := EventToMessage(context.Background(), "", &event) + + dockerHelper.DeleteContainerByID(context.Background(), nil, containerID) + + assert.Nil(t, err) + assert.NotNil(t, message) + assert.Equal(t, common.ContainerState_WAITING, message.State) +} diff --git a/golang/pkg/dagent/utils/import_container.go b/golang/pkg/dagent/utils/import_container.go index 64859fe0a5..389ce5e1cf 100644 --- a/golang/pkg/dagent/utils/import_container.go +++ b/golang/pkg/dagent/utils/import_container.go @@ -54,8 +54,8 @@ func spawnImportContainer( WithMountPoints([]mount.Mount{targetVolume}). WithoutConflict(). WithLogWriter(dog). - WithPreStartHooks(func(ctx context.Context, client client.APIClient, - parentCont containerbuilder.ParentContainer, + WithPreStartHooks(func(_ context.Context, _ client.APIClient, + _ containerbuilder.ParentContainer, ) error { dog.WriteDeploymentStatus(common.DeploymentStatus_IN_PROGRESS, "Waiting for import container to finish") return nil diff --git a/golang/pkg/dagent/utils/init_container.go b/golang/pkg/dagent/utils/init_container.go index 0215f82d91..3d52231af4 100644 --- a/golang/pkg/dagent/utils/init_container.go +++ b/golang/pkg/dagent/utils/init_container.go @@ -61,7 +61,7 @@ func spawnInitContainer( WithNetworks(initCont.Networks). WithoutConflict(). WithPreStartHooks( - func(ctx context.Context, client client.APIClient, parentCont containerbuilder.ParentContainer) error { + func(_ context.Context, _ client.APIClient, _ containerbuilder.ParentContainer) error { dog.WriteDeploymentStatus(common.DeploymentStatus_IN_PROGRESS, "Waiting for init container to finish") return nil }). diff --git a/images/builder-golang/Dockerfile b/images/builder-golang/Dockerfile index 060897cbfd..c626ad838a 100644 --- a/images/builder-golang/Dockerfile +++ b/images/builder-golang/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/golang:1.20-alpine3.18 +FROM docker.io/library/golang:1.22-alpine3.19 ENV GOLANGCI_LINT_CACHE $GOPATH/cache ENV GOCACHE $GOPATH/cache