diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7fc24e4..f0e3ded 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,14 +8,35 @@ permissions: pull-requests: read jobs: - test-pr-ci: + set-version: + runs-on: ubuntu-latest + container: + image: mcr.microsoft.com/dotnet/sdk:6.0 + outputs: + semVer: ${{ steps.gitversion.outputs.semVer }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: set safe path + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v1 + with: + versionSpec: '5.x' + - name: Set SemVer Version + uses: gittools/actions/gitversion/execute@v1 + id: gitversion + + pr-steps: runs-on: ubuntu-latest env: SEMVER: ${{ needs.set-version.outputs.semVer }} GIT_TAG: ${{ needs.set-version.outputs.semVer }} GOVCS: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 1 - name: git prep @@ -25,13 +46,18 @@ jobs: git config user.name ${{ github.actor }} - uses: actions/setup-go@v3 with: - go-version: '1.19.x' + go-version: '1.22.x' + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.37.0 + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: make test run: | - export DOCKER_HOST=unix:///var/run/docker.sock - make REVISION=$GITHUB_SHA test + task test-seeder - name: Publish Junit style Test Report - uses: mikepenz/action-junit-report@v3 + uses: mikepenz/action-junit-report@v4 if: always() with: report_paths: '**/.coverage/report-junit.xml' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 85d45cd..fff2e93 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,43 +12,48 @@ jobs: outputs: semVer: ${{ steps.gitversion.outputs.semVer }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: install deps + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.15 + uses: gittools/actions/gitversion/setup@v1 with: versionSpec: '5.x' - name: Set SemVer Version - uses: gittools/actions/gitversion/execute@v0.9.15 + uses: gittools/actions/gitversion/execute@v1 id: gitversion - - name: echo VERSIONS - run: | - echo "REVISION -> $GITHUB_SHA" - echo "VERSION -> $GITVERSION_SEMVER" test: runs-on: ubuntu-latest container: - image: golang:1.19-bullseye + image: golang:1.22-bullseye needs: set-version env: SEMVER: ${{ needs.set-version.outputs.semVer }} GIT_TAG: ${{ needs.set-version.outputs.semVer }} GOVCS: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 1 - name: install deps run: | - apt update && apt install -y jq git git config --global --add safe.directory "$GITHUB_WORKSPACE" git config user.email ${{ github.actor }}-ci@gha.org git config user.name ${{ github.actor }} - - name: make test + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.37.0 + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run tests pre-release run: | - make REVISION=$GITHUB_SHA test + task test-seeder + - name: Publish Junit style Test Report uses: mikepenz/action-junit-report@v3 if: always() # always run even if the previous step fails @@ -71,54 +76,59 @@ jobs: name: tag repo and publish binary runs-on: ubuntu-latest container: - image: golang:1.19-bullseye + image: golang:1.22-bullseye needs: - set-version - test env: SEMVER: ${{ needs.set-version.outputs.semVer }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.37.0 + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: generate binaries run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" git config user.email ${{ github.actor }}-ci@gha.org git config user.name ${{ github.actor }} - make GIT_TAG=$SEMVER REVISION=${{ github.sha }} PAT=${{ secrets.GITHUB_TOKEN }} build_ci - - name: release library - run: | - make GIT_TAG=$SEMVER REVISION=${{ github.sha }} tag + task build-seeder GIT_TAG=$SEMVER REVISION=${{ github.sha }} PAT=${{ secrets.GITHUB_TOKEN }} + # - name: release library + # run: | + # make GIT_TAG=$SEMVER REVISION=${{ github.sha }} tag - name: release cli run: | - make GIT_TAG=$SEMVER REVISION=${{ github.sha }} PAT=${{ secrets.GITHUB_TOKEN }} release - publish-docker-image: - name: build docker image and push to gchr - # run only when code is compiling and tests are passing - runs-on: ubuntu-latest - # steps to perform in job - needs: - - set-version - - test - env: - SEMVER: ${{ needs.set-version.outputs.semVer }} - steps: - - name: Checkout code - uses: actions/checkout@v3 - # setup Docker buld action - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 + task publish-seeder PAT=${{ secrets.GITHUB_TOKEN }} GIT_TAG=$SEMVER + # publish-docker-image: + # name: build docker image and push to gchr + # # run only when code is compiling and tests are passing + # runs-on: ubuntu-latest + # # steps to perform in job + # needs: + # - set-version + # - test + # env: + # SEMVER: ${{ needs.set-version.outputs.semVer }} + # steps: + # - name: Checkout code + # uses: actions/checkout@v3 + # # setup Docker buld action + # - name: Set up Docker Buildx + # id: buildx + # uses: docker/setup-buildx-action@v2 - - name: Login to Github Packages - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + # - name: Login to Github Packages + # uses: docker/login-action@v2 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} - - name: docker push controller - run: | - echo "SemVer: $SEMVER" - make GIT_TAG=$SEMVER REVISION=${{ github.sha }} docker_release + # - name: docker push controller + # run: | + # echo "SemVer: $SEMVER" + # make GIT_TAG=$SEMVER REVISION=${{ github.sha }} docker_release diff --git a/.gitignore b/.gitignore index 5fe0e3b..07f59e6 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ vendor/ # MISC .ignore* +local/ # generated # **/zz_generated.deepcopy.go @@ -32,3 +33,4 @@ vendor/ .DS_Store **/.coverage + diff --git a/Makefile b/Makefile index 6505458..1f9e421 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ build_controller: echo "build controller" cd controller && make OWNER=$(OWNER) NAME=$(NAME) VERSION=$(VERSION) REVISION=$(REVISION) build -build: build_seeder build_apis build_controller +build: build_seeder # build_apis build_controller build_ci: echo "build seeder first as it contains nested types for APIs" && cd seeder && make OWNER=$(OWNER) NAME=$(NAME) VERSION=$(VERSION) REVISION=$(REVISION) build_ci diff --git a/controller/go.mod b/controller/go.mod index 3d6fc55..a548f6e 100644 --- a/controller/go.mod +++ b/controller/go.mod @@ -1,6 +1,6 @@ module github.com/dnitsch/reststrategy/controller -go 1.19 +go 1.22 require ( github.com/dnitsch/reststrategy/apis v0.9.2-0.20230213152010-dac2bf42c37f @@ -21,14 +21,9 @@ require ( ) require ( - github.com/BurntSushi/toml v1.0.0 // indirect - github.com/alessio/shellescape v1.4.1 // indirect - github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/go-logr/zerologr v1.2.3 // indirect - github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect github.com/onsi/ginkgo/v2 v2.6.1 // indirect github.com/onsi/gomega v1.24.2 // indirect - github.com/pelletier/go-toml v1.9.4 // indirect ) require ( @@ -133,6 +128,5 @@ require ( k8s.io/kube-openapi v0.0.0-20230123231816-1cb3ae25d79a // indirect k8s.io/utils v0.0.0-20230115233650-391b47cb4029 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/kind v0.17.0 sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect ) diff --git a/controller/go.sum b/controller/go.sum index 482ad6d..f17cf5c 100644 --- a/controller/go.sum +++ b/controller/go.sum @@ -23,13 +23,9 @@ github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal v0.7.1/go.mod h1:9V2j0jn github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 h1:oPdPEZFSbl7oSPEAIPMPBMUmiL+mqgzBJwM/9qYcwNg= github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1/go.mod h1:4qFor3D/HDsvBME35Xy9rwW9DecL+M2sNw1ybjPtwA0= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= -github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/a8m/envsubst v1.3.1-0.20221106143949-dffd7176fbc4 h1:DfG4MaBOFewu1eLUkK9mPS93CTsxrd3Y78mab9NjWfk= github.com/a8m/envsubst v1.3.1-0.20221106143949-dffd7176fbc4/go.mod h1:MVUTQNGQ3tsjOOtKCNd+fl8RzhsXcDvvAEzkhGtlsbY= -github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= -github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aws/aws-sdk-go v1.30.27/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= @@ -75,7 +71,6 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX 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/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 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/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -101,8 +96,6 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m 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/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= @@ -164,8 +157,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN 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/safetext v0.0.0-20220905092116-b49f7bc46da2 h1:SJ+NtwL6QaZ21U+IrK7d0gGgpjGGvd2kz+FzTHVzdqI= -github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2/go.mod h1:Tv1PlzqC9t8wNnpPdctvtSUOPUUg4SHeE6vR1Ir2hmg= 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= @@ -213,11 +204,9 @@ github.com/hashicorp/vault/api/auth/aws v0.4.0 h1:2Myo+XU3X5gQTtr3S+WGXcrLUa6iO4 github.com/hashicorp/vault/api/auth/aws v0.4.0/go.mod h1:CGm5PAXEREuYpszyA2ERQPFBSIUD+QTqXfKvdI2Gw/Q= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -271,16 +260,12 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 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/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo/v2 v2.6.1 h1:1xQPCjcqYw/J5LchOcp4/2q/jzJFjiAOc25chhnDw+Q= github.com/onsi/ginkgo/v2 v2.6.1/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo= github.com/onsi/gomega v1.24.2 h1:J/tulyYK6JwBldPViHJReihxxZ+22FHs0piGjQAvoUE= github.com/onsi/gomega v1.24.2/go.mod h1:gs3J10IS7Z7r7eXRoNJIrNqU4ToQukCJhFtKrWgHWnk= -github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= -github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -298,7 +283,6 @@ github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFo github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -472,7 +456,6 @@ google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -509,8 +492,6 @@ k8s.io/utils v0.0.0-20230115233650-391b47cb4029 h1:L8zDtT4jrxj+TaQYD0k8KNlr556Wa k8s.io/utils v0.0.0-20230115233650-391b47cb4029/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/kind v0.17.0 h1:CScmGz/wX66puA06Gj8OZb76Wmk7JIjgWf5JDvY7msM= -sigs.k8s.io/kind v0.17.0/go.mod h1:Qqp8AiwOlMZmJWs37Hgs31xcbiYXjtXlRBSftcnZXQk= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/go.work b/go.work index 4445699..93ec710 100644 --- a/go.work +++ b/go.work @@ -1,4 +1,4 @@ -go 1.19 +go 1.22 use ( ./apis diff --git a/go.work.sum b/go.work.sum index aa6d307..65a646e 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,5 +1,4 @@ cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= -cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I= cloud.google.com/go/accessapproval v1.5.0/go.mod h1:HFy3tuiGvMdcd/u+Cu5b9NkO1pEICJ46IR82PoUdplw= cloud.google.com/go/accesscontextmanager v1.4.0/go.mod h1:/Kjh7BBu/Gh83sv+K60vN9QE5NJcd80sU33vIe2IFPE= cloud.google.com/go/aiplatform v1.27.0/go.mod h1:Bvxqtl40l0WImSb04d0hXFU7gDOiq9jQmorivIiWcKg= @@ -73,7 +72,6 @@ cloud.google.com/go/kms v1.6.0/go.mod h1:Jjy850yySiasBUDi6KFUwUv2n1+o7QZFyuUJg6O cloud.google.com/go/language v1.8.0/go.mod h1:qYPVHf7SPoNNiCL2Dr0FfEFNil1qi3pQEyygwpgVKB8= cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= cloud.google.com/go/logging v1.6.1/go.mod h1:5ZO0mHHbvm8gEmeEUHrmDlTDSu5imF6MUP9OfilNXBw= -cloud.google.com/go/longrunning v0.3.0/go.mod h1:qth9Y41RRSUE69rDcOn6DdK3HfQfsUI0YSmW3iIlLJc= cloud.google.com/go/managedidentities v1.4.0/go.mod h1:NWSBYbEMgqmbZsLIyKvxrYbtqOsxY1ZrGM+9RgDqInM= cloud.google.com/go/maps v0.1.0/go.mod h1:BQM97WGyfw9FWEmQMpZ5T6cpovXXSd1cGmFma94eubI= cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= @@ -133,13 +131,20 @@ github.com/AlekSi/gocov-xml v1.1.0/go.mod h1:g1dRVOCHjKkMtlPfW6BokJ/qxoeZ1uPNAK7 github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= +github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/axw/gocov v1.1.0/go.mod h1:H9G4tivgdN3pYSSVrTFBr6kGDCmAkgbJhtxFzAvgcdw= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= @@ -151,7 +156,6 @@ github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91 github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= @@ -169,12 +173,12 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= -github.com/dnitsch/reststrategy/seeder v0.0.0-20221011155009-3126798d4ab4/go.mod h1:Wkt+YVT7fWYHAPoAbMXvt34lQSZPiaPtgKHXK9+wPI8= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= @@ -187,8 +191,10 @@ github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= @@ -199,22 +205,26 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78 github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/cel-go v0.12.6/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2/go.mod h1:Tv1PlzqC9t8wNnpPdctvtSUOPUUg4SHeE6vR1Ir2hmg= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= @@ -224,27 +234,35 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-kms-wrapping/v2 v2.0.7/go.mod h1:sDQAfwJGv25uGPZA04x87ERglCG6avnRcBT9wYoMII8= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-plugin v1.4.5/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= +github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-secure-stdlib/mlock v0.1.2 h1:p4AKXPPS24tO8Wc8i1gLvSKdmkiSY5xuju57czJ/IJQ= +github.com/hashicorp/go-secure-stdlib/mlock v0.1.2/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I= github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.2/go.mod h1:l8slYwnJA26yBz+ErHpp2IRCLr0vuOMGBORIz4rRiAs= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 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/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/vault/sdk v0.7.0 h1:2pQRO40R1etpKkia5fb4kjrdYMx3BHklPxl1pxpxDHg= +github.com/hashicorp/vault/sdk v0.7.0/go.mod h1:KyfArJkhooyba7gYCKSq8v66QdqJmnbAxtV/OX1+JTs= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/jstemmer/go-junit-report v1.0.0/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= @@ -259,26 +277,38 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= +github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= +github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM= +github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= @@ -289,7 +319,6 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -306,6 +335,7 @@ github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY52 github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= +github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -345,11 +375,14 @@ go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSs go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -391,7 +424,6 @@ golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -438,14 +470,15 @@ google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsA google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= k8s.io/apiserver v0.26.1/go.mod h1:wr75z634Cv+sifswE9HlAo5FQ7UoUauIICRlOE+5dCg= -k8s.io/component-base v0.26.1/go.mod h1:VHrLR0b58oC035w6YQiBSbtsf0ThuSwXP+p5dD/kAWU= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= @@ -455,3 +488,4 @@ k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35/go.mod h1:WxjusMwXlKzfAs4p9km6XJRndVt2FROgMVCE4cdohFo= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/kind v0.17.0/go.mod h1:Qqp8AiwOlMZmJWs37Hgs31xcbiYXjtXlRBSftcnZXQk= diff --git a/kubebuilder-controller/cmd/controller/rest.go b/kubebuilder-controller/cmd/controller/rest.go index 489bb71..5972432 100644 --- a/kubebuilder-controller/cmd/controller/rest.go +++ b/kubebuilder-controller/cmd/controller/rest.go @@ -12,6 +12,8 @@ import ( ) var ( + Version string = "0.0.1" + Revision string = "1111aaaa" masterURL string kubeconfig string rsyncperiod int @@ -24,15 +26,16 @@ var ( configManagerKeySeparator string probeAddr string - controllerCmd = &cobra.Command{ - Short: fmt.Sprintf("%s starts the controller", "reststrategy-controller"), - Long: fmt.Sprintf(`%s CLI provides an idempotent rest caller for seeding configuration or data in a repeatable manner`, "reststrategy-controller"), - Run: controllerRun, + ControllerCmd = &cobra.Command{ + Short: fmt.Sprintf("%s starts the controller", "reststrategy-controller"), + Long: fmt.Sprintf(`%s CLI provides an idempotent rest caller for seeding configuration or data in a repeatable manner`, "reststrategy-controller"), + Run: controllerRun, + Version: fmt.Sprintf("%s-%s", Version, Revision), } ) func Execute() { - if err := controllerCmd.Execute(); err != nil { + if err := ControllerCmd.Execute(); err != nil { fmt.Errorf("cli error: %v", err) os.Exit(1) } @@ -40,23 +43,29 @@ func Execute() { } func init() { - controllerCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "k", "", "Path to a kubeconfig. Only required if out-of-cluster.") - controllerCmd.PersistentFlags().StringVarP(&masterURL, "master", "m", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") - controllerCmd.PersistentFlags().StringVarP(&namespace, "namespace", "n", "", "Only process RestStrategy in this namespace. Overrides using the controllers own namespace") - controllerCmd.PersistentFlags().StringVarP(&logLevel, "loglevel", "l", "error", "The severity threshold for emitting log events") - controllerCmd.PersistentFlags().IntVarP(&rsyncperiod, "rsync", "r", 12, "Period for resyncing the resources periodically even if there are no changes. Value is in minutes.") - controllerCmd.PersistentFlags().StringVarP(&metricsAddr, "metrics-bind-address", "x", ":8080", "The address the metric endpoint binds to.") - controllerCmd.PersistentFlags().StringVarP(&probeAddr, "health-probe-bind-address", "y", ":8081", "The address the probe endpoint binds to.") - controllerCmd.PersistentFlags().BoolVarP(&enableLeaderElection, "leader-elect", "z", false, "Enable leader election for controller manager. "+ + ControllerCmd.PersistentFlags().StringVarP(&kubeconfig, "kubeconfig", "k", "", "Path to a kubeconfig. Only required if out-of-cluster.") + ControllerCmd.PersistentFlags().StringVarP(&masterURL, "master", "m", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") + ControllerCmd.PersistentFlags().StringVarP(&namespace, "namespace", "n", "", "Only process RestStrategy in this namespace. Overrides using the controllers own namespace") + ControllerCmd.PersistentFlags().StringVarP(&logLevel, "loglevel", "l", "error", "The severity threshold for emitting log events") + ControllerCmd.PersistentFlags().IntVarP(&rsyncperiod, "rsync", "r", 12, "Period for resyncing the resources periodically even if there are no changes. Value is in minutes.") + ControllerCmd.PersistentFlags().StringVarP(&metricsAddr, "metrics-bind-address", "x", ":8080", "The address the metric endpoint binds to.") + ControllerCmd.PersistentFlags().StringVarP(&probeAddr, "health-probe-bind-address", "y", ":8081", "The address the probe endpoint binds to.") + ControllerCmd.PersistentFlags().BoolVarP(&enableLeaderElection, "leader-elect", "z", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") - controllerCmd.PersistentFlags().BoolVarP(&enableConfigManager, "configmanager", "c", false, "Enable configmanager on resources handling via the restseeder.") - controllerCmd.PersistentFlags().StringVarP(&configManagerKeySeparator, "configmanager-key-separator", "", "|", "If configmanager is enabled - this key separator will be used.") - controllerCmd.PersistentFlags().StringVarP(&configManagerTokenSeparator, "configmanager-token-separator", "t", "://", "If configmanager is enabled - this key separator will be used.") + ControllerCmd.PersistentFlags().BoolVarP(&enableConfigManager, "configmanager", "c", false, "Enable configmanager on resources handling via the restseeder.") + ControllerCmd.PersistentFlags().StringVarP(&configManagerKeySeparator, "configmanager-key-separator", "", "|", "If configmanager is enabled - this key separator will be used.") + ControllerCmd.PersistentFlags().StringVarP(&configManagerTokenSeparator, "configmanager-token-separator", "t", "://", "If configmanager is enabled - this key separator will be used.") } func controllerRun(cmd *cobra.Command, args []string) { logger := log.NewLogr(os.Stdout, log.ParseLevel(logLevel)) + + // if kubeconfig is set + // we want to overwrite the ENV variable with this value + if kubeconfig != "" { + os.Setenv("KUBECONFIG", kubeconfig) + } // great case for Viper here config := k8s.Config{ Kubeconfig: kubeconfig, diff --git a/kubebuilder-controller/cmd/controller/rest_test.go b/kubebuilder-controller/cmd/controller/rest_test.go new file mode 100644 index 0000000..1825741 --- /dev/null +++ b/kubebuilder-controller/cmd/controller/rest_test.go @@ -0,0 +1,111 @@ +package controller + +import ( + "bytes" + "io" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/dnitsch/reststrategy/seeder" + "gopkg.in/yaml.v2" +) + +func helperFileSeeder(conf *seeder.StrategyConfig) (string, string) { + b, _ := yaml.Marshal(conf) + dir, _ := os.MkdirTemp("", "seed-cli-test") + file := filepath.Join(dir, "seeder.yml") + k8sConf := filepath.Join(dir, ".kube-config") + _ = os.WriteFile(file, b, 0777) + _ = os.WriteFile(k8sConf, []byte(` +apiVersion: v1 +kind: Config +preferences: {}`), 0777) + return k8sConf, file +} + +func TestCmdController(t *testing.T) { + t.Skip() + ttests := map[string]struct { + // path to file and delete file return + testInput func(t *testing.T, url string) ([]string, func()) + expect string + }{ + "no config manager": { + func(t *testing.T, url string) ([]string, func()) { + kubeConf, sourceFile := helperFileSeeder(&seeder.StrategyConfig{}) + return []string{"--kubeconfig", kubeConf}, func() { + masterURL = "" + kubeconfig = "" + rsyncperiod = 0 + namespace = "" + logLevel = "" + metricsAddr = "" + enableLeaderElection = false + enableConfigManager = false + configManagerTokenSeparator = "" + configManagerKeySeparator = "" + probeAddr = "" + os.Remove(sourceFile) + os.Remove(kubeConf) + } + }, + "", + }, + "with config manager": { + func(t *testing.T, url string) ([]string, func()) { + + kubeConf, sourceFile := helperFileSeeder(&seeder.StrategyConfig{}) + return []string{"-c", "--kubeconfig", kubeConf}, func() { + masterURL = "" + kubeconfig = "" + rsyncperiod = 0 + namespace = "" + logLevel = "" + metricsAddr = "" + enableLeaderElection = false + enableConfigManager = false + configManagerTokenSeparator = "" + configManagerKeySeparator = "" + probeAddr = "" + os.Remove(sourceFile) + os.Remove(kubeConf) + } + }, + "", + }, + } + for name, tt := range ttests { + t.Run(name, func(t *testing.T) { + cmdArgs, cleanUp := tt.testInput(t, "") + defer cleanUp() + b := new(bytes.Buffer) + + cmd := ControllerCmd + + cmd.SetArgs(cmdArgs) + cmd.SetErr(b) + cmd.Execute() + out, err := io.ReadAll(b) + if err != nil { + t.Fatal(err) + } + // + if tt.expect == "" && len(out) > 0 { + t.Errorf(`%s +got: %v +wanted: ""`, "expected empty buffer", string(out)) + } + + if tt.expect != "" && !strings.Contains(string(out), tt.expect) { + t.Errorf(`%s +got: %v +want: %v`, "output comparison failed", string(out), tt.expect) + } + + cmd = nil + + }) + } +} diff --git a/kubebuilder-controller/cmd/controller/version.go b/kubebuilder-controller/cmd/controller/version.go deleted file mode 100644 index 9afa39d..0000000 --- a/kubebuilder-controller/cmd/controller/version.go +++ /dev/null @@ -1,26 +0,0 @@ -package controller - -import ( - "fmt" - "os" - - "github.com/spf13/cobra" -) - -var ( - Version string = "0.0.1" - Revision string = "1111aaaa" - versionCmd = &cobra.Command{ - Use: "version", - Short: fmt.Sprintf("Get version number %s", "reststrategy-controller"), - Long: `Version and Revision number of the installed CLI`, - Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("Version: %s\nRevision: %s\n", Version, Revision) - os.Exit(0) - }, - } -) - -func init() { - controllerCmd.AddCommand(versionCmd) -} diff --git a/kubebuilder-controller/go.mod b/kubebuilder-controller/go.mod index 4468de0..ad39e74 100644 --- a/kubebuilder-controller/go.mod +++ b/kubebuilder-controller/go.mod @@ -1,6 +1,6 @@ module github.com/dnitsch/reststrategy/kubebuilder-controller -go 1.19 +go 1.22 require ( github.com/dnitsch/configmanager v1.19.1 @@ -10,6 +10,7 @@ require ( github.com/onsi/ginkgo/v2 v2.6.1 github.com/onsi/gomega v1.24.2 github.com/spf13/cobra v1.6.1 + gopkg.in/yaml.v2 v2.4.0 k8s.io/apimachinery v0.26.1 k8s.io/client-go v0.26.1 sigs.k8s.io/controller-runtime v0.14.1 @@ -120,7 +121,6 @@ require ( google.golang.org/protobuf v1.28.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.26.1 // indirect k8s.io/apiextensions-apiserver v0.26.1 // indirect diff --git a/kubebuilder-controller/internal/k8s/k8s.go b/kubebuilder-controller/internal/k8s/k8s.go index eedc16c..14f993c 100644 --- a/kubebuilder-controller/internal/k8s/k8s.go +++ b/kubebuilder-controller/internal/k8s/k8s.go @@ -1,7 +1,9 @@ package k8s import ( + "fmt" "os" + // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. _ "k8s.io/client-go/plugin/pkg/client/auth" @@ -40,6 +42,9 @@ func Run(conf Config, logger logr.Logger, scheme *runtime.Scheme) { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(seederv1alpha1.AddToScheme(scheme)) + // fs := &flag.FlagSet{} + // ctrl.RegisterFlags(fs) + ctrl.SetLogger(logger.WithName("RestStrategyController")) mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ @@ -82,23 +87,25 @@ func Run(conf Config, logger logr.Logger, scheme *runtime.Scheme) { ConfigManagerConfig: conf.ConfigManager, }).SetupWithManager(mgr); err != nil { ctrl.Log.Error(err, "unable to create controller", "controller", "RestStrategy") - os.Exit(1) + MsgExit(ctrl.Log, 1, "CreateControllerError") } if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { ctrl.Log.Error(err, "unable to set up health check") - os.Exit(1) + MsgExit(ctrl.Log, 1, "AddHealthzCheck") } + if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil { ctrl.Log.Error(err, "unable to set up ready check") - os.Exit(1) + MsgExit(ctrl.Log, 1, "AddReadyzCheck") + } ctrl.Log.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { // setupLog.Error(err, "problem running manager") ctrl.Log.Error(err, "problem running manager") - os.Exit(1) + MsgExit(ctrl.Log, 1, "startingManager") } } @@ -115,3 +122,11 @@ func GetNamespace(namespace string) string { } return ns } + +func MsgExit(logger logr.Logger, code int, area string) { + if _, ok := os.LookupEnv("IN_CI_TEST"); ok { + logger.Info(fmt.Sprintf("In CI tests, do not exit with code: %d\n", code), "code", code, "area", area) + return + } + os.Exit(code) +} diff --git a/seeder/cmd/strategyrestseeder/root.go b/seeder/cmd/strategyrestseeder/root.go index 91e115c..91060fb 100644 --- a/seeder/cmd/strategyrestseeder/root.go +++ b/seeder/cmd/strategyrestseeder/root.go @@ -9,12 +9,15 @@ import ( ) var ( + Version string + Revision string verbose bool StrategyRestSeederCmd = &cobra.Command{ Use: config.SELF_NAME, Aliases: config.SHORT_NAME, Short: fmt.Sprintf("%s CLI provides an idempotent rest caller", config.SELF_NAME), Long: fmt.Sprintf(`%s CLI provides an idempotent rest caller for seeding configuration or data in a repeatable manner`, config.SELF_NAME), + Version: fmt.Sprintf("%s-%s", Version, Revision), } ) diff --git a/seeder/cmd/strategyrestseeder/runseed.go b/seeder/cmd/strategyrestseeder/runseed.go index a282ea2..6e5decf 100644 --- a/seeder/cmd/strategyrestseeder/runseed.go +++ b/seeder/cmd/strategyrestseeder/runseed.go @@ -7,6 +7,7 @@ import ( "github.com/dnitsch/configmanager" "github.com/dnitsch/configmanager/pkg/generator" + "gopkg.in/yaml.v3" srs "github.com/dnitsch/reststrategy/seeder" "github.com/dnitsch/reststrategy/seeder/internal/cmdutils" @@ -51,7 +52,16 @@ func runExecute(cmd *cobra.Command, args []string) error { l = log.New(os.Stderr, log.DebugLvl) } - strategy := srs.StrategyConfig{} + strategy := &srs.StrategyConfig{} + file, err := os.ReadFile(path) + if err != nil { + return err + } + + if err := yaml.Unmarshal(file, strategy); err != nil { + return err + } + s := srs.New(&l).WithRestClient(&http.Client{}) cmConfig := generator.NewConfig() @@ -67,5 +77,5 @@ func runExecute(cmd *cobra.Command, args []string) error { s.WithConfigManager(&configmanager.ConfigManager{}).WithConfigManagerOptions(cmConfig) } - return cmdutils.RunSeed(s, strategy, path, verbose) + return cmdutils.RunSeed(s, strategy) } diff --git a/seeder/cmd/strategyrestseeder/version.go b/seeder/cmd/strategyrestseeder/version.go deleted file mode 100644 index 6c701c6..0000000 --- a/seeder/cmd/strategyrestseeder/version.go +++ /dev/null @@ -1,27 +0,0 @@ -package cmd - -import ( - "fmt" - "os" - - "github.com/dnitsch/reststrategy/seeder/internal/config" - "github.com/spf13/cobra" -) - -var ( - Version string = "0.0.1" - Revision string = "1111aaaa" - versionCmd = &cobra.Command{ - Use: "version", - Short: fmt.Sprintf("Get version number %s", config.SELF_NAME), - Long: `Version and Revision number of the installed CLI`, - Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("Version: %s\nRevision: %s\n", Version, Revision) - os.Exit(0) - }, - } -) - -func init() { - StrategyRestSeederCmd.AddCommand(versionCmd) -} diff --git a/seeder/go.mod b/seeder/go.mod index 2cef54b..b3479fd 100644 --- a/seeder/go.mod +++ b/seeder/go.mod @@ -1,6 +1,6 @@ module github.com/dnitsch/reststrategy/seeder -go 1.19 +go 1.22 require ( github.com/a8m/envsubst v1.3.1-0.20221106143949-dffd7176fbc4 @@ -10,6 +10,7 @@ require ( github.com/spyzhov/ajson v0.7.2 golang.org/x/oauth2 v0.5.0 gopkg.in/yaml.v2 v2.4.0 + gopkg.in/yaml.v3 v3.0.1 k8s.io/apimachinery v0.26.1 k8s.io/code-generator v0.26.1 ) @@ -103,7 +104,6 @@ require ( google.golang.org/grpc v1.53.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect k8s.io/klog/v2 v2.90.0 // indirect k8s.io/kube-openapi v0.0.0-20230123231816-1cb3ae25d79a // indirect diff --git a/seeder/go.sum b/seeder/go.sum index b1680a7..2b649df 100644 --- a/seeder/go.sum +++ b/seeder/go.sum @@ -1,6 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.107.0 h1:qkj22L7bgkl6vIeZDlOY2po43Mx/TIa2Wsa7VR+PEww= +cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I= cloud.google.com/go/compute v1.18.0 h1:FEigFqoDbys2cvFkZ9Fjq4gnHBP55anJ0yQyau2f9oY= cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= @@ -8,6 +9,7 @@ cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2Aawl cloud.google.com/go/iam v0.12.0 h1:DRtTY29b75ciH6Ov1PHb4/iat2CLCvrOm40Q0a6DFpE= cloud.google.com/go/iam v0.12.0/go.mod h1:knyHGviacl11zrtZUoDuYpDgLjvr28sLQaG0YB2GYAY= cloud.google.com/go/longrunning v0.3.0 h1:NjljC+FYPV3uh5/OwWT6pVU+doBqMg2x/rZlE+CamDs= +cloud.google.com/go/longrunning v0.3.0/go.mod h1:qth9Y41RRSUE69rDcOn6DdK3HfQfsUI0YSmW3iIlLJc= cloud.google.com/go/secretmanager v1.10.0 h1:pu03bha7ukxF8otyPKTFdDz+rr9sE3YauS5PliDXK60= cloud.google.com/go/secretmanager v1.10.0/go.mod h1:MfnrdvKMPNra9aZtQFvBcvRU54hbPD8/HayQdlUgJpU= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.1 h1:gVXuXcWd1i4C2Ruxe321aU+IKGaStvGB/S90PUPB/W8= @@ -77,6 +79,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs 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/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnitsch/configmanager v1.19.1 h1:UQw60VjNvmDKUDTBx5p51USD/7o1rVmfZyDb1rPInCA= github.com/dnitsch/configmanager v1.19.1/go.mod h1:pA+zmN4iHLlaQE5N4niTTAVBIMDyH1BDT1VSo3lr5zc= github.com/dnitsch/simplelog v1.7.0 h1:Lg+/KaTZDNfIqzb8B5vrGW5QFBTVBoy27k6IH+nOwfc= @@ -263,6 +266,7 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= @@ -451,6 +455,7 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI= gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= diff --git a/seeder/internal/cmdutils/cmdutils.go b/seeder/internal/cmdutils/cmdutils.go index da2ca6c..e81078a 100644 --- a/seeder/internal/cmdutils/cmdutils.go +++ b/seeder/internal/cmdutils/cmdutils.go @@ -7,7 +7,7 @@ import ( srs "github.com/dnitsch/reststrategy/seeder" ) -func RunSeed(svc *srs.StrategyRestSeeder, strategy srs.StrategyConfig, path string, verbose bool) error { +func RunSeed(svc *srs.StrategyRestSeeder, strategy *srs.StrategyConfig) error { svc.WithActions(strategy.Seeders).WithAuth(strategy.AuthConfig) diff --git a/seeder/makefile b/seeder/makefile index 6b2137e..8559237 100644 --- a/seeder/makefile +++ b/seeder/makefile @@ -6,10 +6,6 @@ LDFLAGS := -ldflags="-s -w -X \"github.com/$(OWNER)/$(NAME)/seeder/cmd/strategyr install: go mod tidy - go mod vendor - -install_ci: - go mod vendor codegen: ./hack/update-codegen.sh @@ -35,6 +31,6 @@ bingen: GOOS=$$os CGO_ENABLED=0 go build -mod=readonly -buildvcs=false $(LDFLAGS) -o dist/seeder-$$os ./cmd; \ done -build: clean install copygened bingen +build: clean install bingen -build_ci: clean install_ci codegen_verify bingen +build_ci: clean install codegen_verify bingen diff --git a/seeder/rest.go b/seeder/rest.go index 7cefa78..0e09b68 100644 --- a/seeder/rest.go +++ b/seeder/rest.go @@ -135,8 +135,11 @@ type Action struct { PutEndpointSuffix *string `yaml:"putEndpointSuffix,omitempty" json:"putEndpointSuffix,omitempty"` DeleteEndpointSuffix *string `yaml:"deleteEndpointSuffix,omitempty" json:"deleteEndpointSuffix,omitempty"` FindByJsonPathExpr string `yaml:"findByJsonPathExpr,omitempty" json:"findByJsonPathExpr,omitempty"` - PayloadTemplate string `yaml:"payloadTemplate" json:"payloadTemplate"` - PatchPayloadTemplate string `yaml:"patchPayloadTemplate,omitempty" json:"patchPayloadTemplate,omitempty"` + // In the rare cases where POST is being used like a PUT + // and exposes a route that idemponently updates a record using the POST verb + PostIsPut bool `yaml:"postIsPut" json:"postIsPut"` + PayloadTemplate string `yaml:"payloadTemplate" json:"payloadTemplate"` + PatchPayloadTemplate string `yaml:"patchPayloadTemplate,omitempty" json:"patchPayloadTemplate,omitempty"` // +kubebuilder:pruning:PreserveUnknownFields RuntimeVars map[string]string `yaml:"runtimeVars,omitempty" json:"runtimeVars,omitempty"` AuthMapRef string `yaml:"authMapRef" json:"authMapRef"` @@ -190,10 +193,12 @@ func (r *SeederImpl) do(req *http.Request, action *Action) ([]byte, error) { r.log.Debugf("request: %+v", req) respBody := []byte{} req.Header = *action.header + + req.URL.Path = r.TemplateWithVars(req.URL.Path, action.Variables) + diag := &Diagnostic{HostPathMethod: fmt.Sprintf("Method => %s HostPath => %s%s Query => %s", req.Method, req.URL.Host, req.URL.Path, req.URL.RawQuery), Name: action.name, ProceedFallback: false, IsFatal: true} r.log.Debugf("restPayload diagnostic: %+v", diag) - resp, err := r.client.Do(r.setAuthHeader(req, action)) if err != nil { r.log.Debugf("failed to make network call: %v", err) @@ -272,6 +277,7 @@ func (r *SeederImpl) get(ctx context.Context, action *Action) ([]byte, error) { if action.GetEndpointSuffix != nil { endpoint = fmt.Sprintf("%s%s", endpoint, *action.GetEndpointSuffix) } + req, err := http.NewRequestWithContext(ctx, "GET", endpoint, nil) if err != nil { @@ -288,6 +294,7 @@ func (r *SeederImpl) post(ctx context.Context, action *Action) error { if action.PostEndpointSuffix != nil { endpoint = fmt.Sprintf("%s%s", endpoint, *action.PostEndpointSuffix) } + req, err := http.NewRequestWithContext(ctx, "POST", endpoint, strings.NewReader(action.templatedPayload)) if err != nil { @@ -408,13 +415,13 @@ func findPathByExpression(resp []byte, pathExpression string, log log.Loggerifac return "", nil } -// TemplatePayload parses input payload and replaces all $var ${var} with +// TemplateWithVars parses input payload and replaces all $var ${var} with // existing global env variable as well as injected from inside RestAction // into the local context -func (r *SeederImpl) TemplatePayload(payload string, vars KvMapVarsAny) string { - localVars := &KvMapVarsAny{} +func (r *SeederImpl) TemplateWithVars(payload string, vars KvMapVarsAny) string { + localVars := make(KvMapVarsAny) if vars == nil { - vars = *localVars + vars = localVars } // extend existing to allow for runtimeVars replacement diff --git a/seeder/rest_test.go b/seeder/rest_test.go index 6b81a67..5d246ae 100644 --- a/seeder/rest_test.go +++ b/seeder/rest_test.go @@ -107,7 +107,7 @@ func Test_templatePayload(t *testing.T) { t.Run(tt.name, func(t *testing.T) { os.Setenv("FUZZ", "BOO") - got := tt.rest.TemplatePayload(tt.payload, tt.variables) + got := tt.rest.TemplateWithVars(tt.payload, tt.variables) if got != tt.expect { t.Errorf(TestPhrase, got, tt.expect) } diff --git a/seeder/seeder.go b/seeder/seeder.go index 4ca9776..10b1637 100644 --- a/seeder/seeder.go +++ b/seeder/seeder.go @@ -25,6 +25,7 @@ const ( FIND_DELETE StrategyType = "FIND/DELETE" FIND_DELETE_POST StrategyType = "FIND/DELETE/POST" PUT StrategyType = "PUT" + POST StrategyType = "POST" ) type CMRetrieve interface { @@ -52,6 +53,7 @@ func New(log log.Loggeriface) *StrategyRestSeeder { rest: r, Strategy: map[StrategyType]StrategyFunc{ PUT: PutStrategyFunc, + POST: PostStrategyFunc, PUT_POST: PutPostStrategyFunc, GET_PUT_POST: GetPutPostStrategyFunc, FIND_PUT_POST: FindPutPostStrategyFunc, @@ -197,6 +199,12 @@ func PutStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) erro return rest.Put(ctx, action) } +// PostStrategyFunc calls a POST endpoint fails if an error occurs +// useful when there is a known Id of a resource and PUT supports creation +func PostStrategyFunc(ctx context.Context, action *Action, rest *SeederImpl) error { + return rest.Post(ctx, action) +} + // PutPostStrategyFunc is useful when the resource is created a user specified Id // the PUT endpoint DOES NOT support a creation of the resource. PUT should throw a 4XX // for the POST fallback to take effect diff --git a/seeder/seeder_test.go b/seeder/seeder_test.go index 6481fb6..f8d0bfc 100644 --- a/seeder/seeder_test.go +++ b/seeder/seeder_test.go @@ -2301,6 +2301,7 @@ func TestExecuteWithConfigManager(t *testing.T) { t.Parallel() for name, tt := range tests { t.Run(name, func(t *testing.T) { + srs := seeder.New(&logger).WithRestClient(&http.Client{}) ts := httptest.NewServer(tt.handler(t)) @@ -2323,6 +2324,7 @@ func TestExecuteWithConfigManager(t *testing.T) { } } + func TestExecuteWithConfigManagerError(t *testing.T) { logW := &bytes.Buffer{} diff --git a/seeder/seederstrategies.go b/seeder/seederstrategies.go index cb7b6a4..edc3569 100644 --- a/seeder/seederstrategies.go +++ b/seeder/seederstrategies.go @@ -10,7 +10,7 @@ import ( // does not support an update of existing item. func (r *SeederImpl) GetPost(ctx context.Context, action *Action) error { - action.templatedPayload = r.TemplatePayload(action.PayloadTemplate, action.Variables) + action.templatedPayload = r.TemplateWithVars(action.PayloadTemplate, action.Variables) resp, err := r.get(ctx, action) if err != nil { return err @@ -29,7 +29,7 @@ func (r *SeederImpl) GetPost(ctx context.Context, action *Action) error { // does not support an update of existing item. func (r *SeederImpl) FindPost(ctx context.Context, action *Action) error { - action.templatedPayload = r.TemplatePayload(action.PayloadTemplate, action.Variables) + action.templatedPayload = r.TemplateWithVars(action.PayloadTemplate, action.Variables) resp, err := r.get(ctx, action) if err != nil { return err @@ -38,7 +38,13 @@ func (r *SeederImpl) FindPost(ctx context.Context, action *Action) error { if err != nil { return err } - if found == "" { + // run Post as if its a PUT verb + // when an id was found + if found != "" && action.PostIsPut { + return r.post(ctx, action) + } + + if found == "" || action.PostIsPut { return r.post(ctx, action) } r.log.Infof("item: %s,found by expression: %s and cannot be updated continuing", found, action.FindByJsonPathExpr) @@ -51,7 +57,7 @@ func (r *SeederImpl) FindPost(ctx context.Context, action *Action) error { // else it will do a POST as the item can be created func (r *SeederImpl) FindPutPost(ctx context.Context, action *Action) error { - action.templatedPayload = r.TemplatePayload(action.PayloadTemplate, action.Variables) + action.templatedPayload = r.TemplateWithVars(action.PayloadTemplate, action.Variables) resp, err := r.get(ctx, action) if err != nil { return err @@ -73,7 +79,7 @@ func (r *SeederImpl) FindPutPost(ctx context.Context, action *Action) error { // FindPatchPost is same as FindPutPost strategy but uses PATCH func (r *SeederImpl) FindPatchPost(ctx context.Context, action *Action) error { - action.templatedPayload = r.TemplatePayload(action.PayloadTemplate, action.Variables) + action.templatedPayload = r.TemplateWithVars(action.PayloadTemplate, action.Variables) resp, err := r.get(ctx, action) if err != nil { return err @@ -89,14 +95,14 @@ func (r *SeederImpl) FindPatchPost(ctx context.Context, action *Action) error { r.log.Infof("item: %s,found by expression: %s\nupdating in place", found, action.FindByJsonPathExpr) action.foundId = found - action.templatedPayload = r.TemplatePayload(action.PatchPayloadTemplate, action.Variables) + action.templatedPayload = r.TemplateWithVars(action.PatchPayloadTemplate, action.Variables) return r.patch(ctx, action) } // FindDeletePost func (r *SeederImpl) FindDeletePost(ctx context.Context, action *Action) error { - action.templatedPayload = r.TemplatePayload(action.PayloadTemplate, action.Variables) + action.templatedPayload = r.TemplateWithVars(action.PayloadTemplate, action.Variables) resp, err := r.get(ctx, action) if err != nil { var diag *Diagnostic @@ -133,7 +139,7 @@ func (r *SeederImpl) FindDeletePost(ctx context.Context, action *Action) error { // else it will do a POST as the item can be created func (r *SeederImpl) GetPutPost(ctx context.Context, action *Action) error { - action.templatedPayload = r.TemplatePayload(action.PayloadTemplate, action.Variables) + action.templatedPayload = r.TemplateWithVars(action.PayloadTemplate, action.Variables) resp, err := r.get(ctx, action) if err != nil { var diag *Diagnostic @@ -170,14 +176,22 @@ func (r *SeederImpl) GetPutPost(ctx context.Context, action *Action) error { // Put strategy calls a PUT endpoint // if standards compliant this should be an idempotent operation func (r *SeederImpl) Put(ctx context.Context, action *Action) error { - action.templatedPayload = r.TemplatePayload(action.PayloadTemplate, action.Variables) + action.templatedPayload = r.TemplateWithVars(action.PayloadTemplate, action.Variables) return r.put(ctx, action) } +// Post strategy calls a POST endpoint +// This should not be an idempotent endpoint but in +// certain cases it is implemented with a 200 or 202. +func (r *SeederImpl) Post(ctx context.Context, action *Action) error { + action.templatedPayload = r.TemplateWithVars(action.PayloadTemplate, action.Variables) + return r.post(ctx, action) +} + // Put strategy calls a PUT endpoint // if standards compliant this should be an idempotent operation func (r *SeederImpl) PutPost(ctx context.Context, action *Action) error { - action.templatedPayload = r.TemplatePayload(action.PayloadTemplate, action.Variables) + action.templatedPayload = r.TemplateWithVars(action.PayloadTemplate, action.Variables) if err := r.put(ctx, action); err != nil { var diag *Diagnostic if errors.As(err, &diag) { diff --git a/seeder/test b/seeder/test deleted file mode 100755 index d9c7679..0000000 Binary files a/seeder/test and /dev/null differ diff --git a/taskfile.yml b/taskfile.yml new file mode 100644 index 0000000..f5ab8b6 --- /dev/null +++ b/taskfile.yml @@ -0,0 +1,74 @@ +# yaml-language-server: $schema=https://taskfile.dev/schema.json +version: '3' +vars: + OWNER: dnitsch + NAME: reststrategy + GIT_TAG: "0.9.0" + VERSION: "v{{ .GIT_TAG}}" + REVISION: aaaabbbb1234 + LDFLAGS: -ldflags="-s -w -X \"github.com/{{ .OWNER}}/{{ .NAME }}/seeder/cmd/strategyrestseeder.Version={{ .VERSION}}\" -X \"github.com/{{ .OWNER}}/{{ .NAME }}/seeder/cmd/strategyrestseeder.Revision={{ .REVISION }}\" -extldflags -static" + +tasks: + clean: + desc: cleans output dir + dir: '{{ .DIR }}' + cmds: + - rm -rf bin/* + - rm -rf dist/* + - rm -rf vendor/* + - mkdir -p dist + requires: + vars: + - DIR + build-seeder: + dir: seeder + cmds: + - | + go mod tidy + - task: clean + vars: + DIR: seeder + - cmd: | + for os in darwin linux windows; do + GOOS=${os} CGO_ENABLED=0 go build -mod=readonly -buildvcs=false {{ .LDFLAGS }} -o dist/seeder-${os} ./cmd; + done + + test-seeder: + dir: seeder + cmds: + - | + mkdir -p .coverage + go install github.com/jstemmer/go-junit-report/v2@latest && \ + go install github.com/axw/gocov/gocov@latest && \ + go install github.com/AlekSi/gocov-xml@latest + - | + go test ./... -v -buildvcs=false -mod=readonly -coverprofile=.coverage/out > .coverage/unit + cat .coverage/unit | go-junit-report > .coverage/report-junit.xml + gocov convert .coverage/out | gocov-xml > .coverage/report-cobertura.xml + + show_coverage: + desc: Shows coverage summary in default browser + dir: seeder + deps: + - test-seeder + cmds: + - go tool cover -html=.coverage/out + + publish-seeder: + dir: seeder + cmds: + - cmd: | + git tag -a {{ .VERSION }} -m "ci tag release reststrategy" {{ .REVISION }} + # git tag -a apis/{{ .VERSION }} -m "ci tag release reststrategy/apis" {{ .REVISION }} + git tag -a seeder/{{ .VERSION }} -m "ci tag release reststrategy/seeder" {{ .REVISION }} + git push origin --tags + - | + OWNER={{ .OWNER }} NAME={{ .NAME }} PAT={{ .PAT }} VERSION={{ .VERSION }} ./hack/release.sh + vars: + OWNER: '{{ .OWNER }}' + NAME: '{{ .NAME }}' + GIT_TAG: '{{ .GIT_TAG }}' + requires: + vars: + - PAT + - GIT_TAG