diff --git a/.github/workflows/radix-cost-allocation-api-pr.yml b/.github/workflows/radix-cost-allocation-api-pr.yml index b5416dc..d42b446 100644 --- a/.github/workflows/radix-cost-allocation-api-pr.yml +++ b/.github/workflows/radix-cost-allocation-api-pr.yml @@ -9,7 +9,7 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build docker image env: REF: ${{ github. sha }} @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 2 - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version: '1.21' - name: Install dependencies @@ -37,8 +37,8 @@ jobs: name: Unit Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version: '1.21' - name: Install dependencies @@ -46,23 +46,29 @@ jobs: - name: Run Tests run: go test -cover `go list ./...` - test-swagger: - name: Test Swagger + verify-code-generation: + name: Verify Code Generation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Verify Code Generation + run: | + make verify-generate + + report-swagger-changes: + name: Report Changes In Swagger Spec runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: git fetch --no-tags --no-recurse-submodules --depth=1 origin master:master - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version: '1.21' - - name: Install dependencies - run: go mod download - name: Install Swagger run: go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 - - name: Generate Swagger - run: swagger generate spec -o ./swagger.json --scan-models --exclude-deps --exclude=github.com/equinor/radix-cost-allocation-api/models/radix_api/generated_client/models - - name: Validate no changes - run: diff ./swagger.json ./swaggerui/html/swagger.json - name: Check breaking changes if: always() id: breaking @@ -85,7 +91,6 @@ jobs: - uses: actions/checkout@v4 - run: git fetch --no-tags --no-recurse-submodules --depth=1 origin master:master - - run: make generate-radixconfig-envs - name: Test radixconfig template changes run: git diff --exit-code diff --git a/Makefile b/Makefile index ffc656c..a8fce67 100644 --- a/Makefile +++ b/Makefile @@ -10,13 +10,13 @@ test: lint: bootstrap golangci-lint run --max-same-issues 0 -.PHONY: generate-radix-api-client -generate-radix-api-client: bootstrap +.PHONY: radixapiclient +radixapiclient: bootstrap swagger generate client -t ./models/radix_api/generated_client -f https://api.radix.equinor.com/swaggerui/swagger.json -A radixapi -.PHONY: generate-radixconfig-envs -generate-radixconfig-envs: +.PHONY: radixconfigs +radixconfigs: # radix-id-vulnerability-scan-reader- AZURE_CLIENT_ID=b8fd30d4-61d0-4842-b6c1-e91ceb58db8c SQL_SERVER=sql-radix-cost-allocation-dev.database.windows.net envsubst < radixconfig.tpl.yaml > radixconfig.dev.yaml AZURE_CLIENT_ID=bb6d92a0-2f6d-421e-80e6-1b2174953d21 SQL_SERVER=sql-radix-cost-allocation-c2.database.windows.net envsubst < radixconfig.tpl.yaml > radixconfig.c2.yaml @@ -38,6 +38,13 @@ mocks: bootstrap mockgen -source ./api/utils/auth/auth_provider.go -destination ./api/test/mock/auth_provider_mock.go -package mock mockgen -source ./service/costservice.go -destination ./service/mock/costservice.go -package mock +.PHONY: generate +generate: radixconfigs mocks swagger + +.PHONY: verify-generate +verify-generate: generate + git diff --exit-code + HAS_SWAGGER := $(shell command -v swagger;) HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;) HAS_MOCKGEN := $(shell command -v mockgen;) @@ -47,7 +54,7 @@ ifndef HAS_SWAGGER go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 endif ifndef HAS_GOLANGCI_LINT - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 endif ifndef HAS_MOCKGEN go install github.com/golang/mock/mockgen@v1.6.0 diff --git a/README.md b/README.md index 840ffbe..dae83f3 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ Go modules are used for dependency management. See [link](https://blog.golang.or Run once after cloning of the GitHub repository: 1. `go mod download` -2. `make swagger` -3. `make generate-radix-api-client`0.222 +2. `make generate` +3. `make radixapiclient` The following env var is needed. Useful default values in brackets. diff --git a/radixconfig.c2.yaml b/radixconfig.c2.yaml index a9a4c93..aedc3d4 100644 --- a/radixconfig.c2.yaml +++ b/radixconfig.c2.yaml @@ -1,3 +1,5 @@ +# yaml-language-server: =https://raw.githubusercontent.com/equinor/radix-operator/release/json-schema/radixapplication.json + apiVersion: radix.equinor.com/v1 kind: RadixApplication metadata: @@ -26,9 +28,9 @@ spec: limits: memory: "2000Mi" cpu: "1000m" - public: true + publicPort: http monitoring: true - runAsNonRoot: true + readOnlyFileSystem: true variables: LOG_LEVEL: INFO SQL_SERVER: "sql-radix-cost-allocation-c2.database.windows.net" @@ -43,9 +45,5 @@ spec: environmentConfig: - environment: qa replicas: 1 - variables: - PIPELINE_IMG_TAG: "master-latest" - environment: prod replicas: 2 - variables: - PIPELINE_IMG_TAG: "release-latest" diff --git a/radixconfig.dev.yaml b/radixconfig.dev.yaml index 14d99d9..eb3d76b 100644 --- a/radixconfig.dev.yaml +++ b/radixconfig.dev.yaml @@ -1,3 +1,5 @@ +# yaml-language-server: =https://raw.githubusercontent.com/equinor/radix-operator/release/json-schema/radixapplication.json + apiVersion: radix.equinor.com/v1 kind: RadixApplication metadata: @@ -26,9 +28,9 @@ spec: limits: memory: "2000Mi" cpu: "1000m" - public: true + publicPort: http monitoring: true - runAsNonRoot: true + readOnlyFileSystem: true variables: LOG_LEVEL: INFO SQL_SERVER: "sql-radix-cost-allocation-dev.database.windows.net" @@ -43,9 +45,5 @@ spec: environmentConfig: - environment: qa replicas: 1 - variables: - PIPELINE_IMG_TAG: "master-latest" - environment: prod replicas: 2 - variables: - PIPELINE_IMG_TAG: "release-latest" diff --git a/radixconfig.platform.yaml b/radixconfig.platform.yaml index 4c87928..a64a6eb 100644 --- a/radixconfig.platform.yaml +++ b/radixconfig.platform.yaml @@ -1,3 +1,5 @@ +# yaml-language-server: =https://raw.githubusercontent.com/equinor/radix-operator/release/json-schema/radixapplication.json + apiVersion: radix.equinor.com/v1 kind: RadixApplication metadata: @@ -26,9 +28,9 @@ spec: limits: memory: "2000Mi" cpu: "1000m" - public: true + publicPort: http monitoring: true - runAsNonRoot: true + readOnlyFileSystem: true variables: LOG_LEVEL: INFO SQL_SERVER: "sql-radix-cost-allocation-platform.database.windows.net" @@ -43,9 +45,5 @@ spec: environmentConfig: - environment: qa replicas: 1 - variables: - PIPELINE_IMG_TAG: "master-latest" - environment: prod replicas: 2 - variables: - PIPELINE_IMG_TAG: "release-latest" diff --git a/radixconfig.playground.yaml b/radixconfig.playground.yaml index f53d014..6a99e32 100644 --- a/radixconfig.playground.yaml +++ b/radixconfig.playground.yaml @@ -1,3 +1,5 @@ +# yaml-language-server: =https://raw.githubusercontent.com/equinor/radix-operator/release/json-schema/radixapplication.json + apiVersion: radix.equinor.com/v1 kind: RadixApplication metadata: @@ -26,9 +28,9 @@ spec: limits: memory: "2000Mi" cpu: "1000m" - public: true + publicPort: http monitoring: true - runAsNonRoot: true + readOnlyFileSystem: true variables: LOG_LEVEL: INFO SQL_SERVER: "sql-radix-cost-allocation-playground.database.windows.net" @@ -43,9 +45,5 @@ spec: environmentConfig: - environment: qa replicas: 1 - variables: - PIPELINE_IMG_TAG: "master-latest" - environment: prod replicas: 2 - variables: - PIPELINE_IMG_TAG: "release-latest" diff --git a/radixconfig.tpl.yaml b/radixconfig.tpl.yaml index 3780de0..4bb793b 100644 --- a/radixconfig.tpl.yaml +++ b/radixconfig.tpl.yaml @@ -1,3 +1,5 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/equinor/radix-operator/release/json-schema/radixapplication.json + apiVersion: radix.equinor.com/v1 kind: RadixApplication metadata: @@ -26,9 +28,9 @@ spec: limits: memory: "2000Mi" cpu: "1000m" - public: true + publicPort: http monitoring: true - runAsNonRoot: true + readOnlyFileSystem: true variables: LOG_LEVEL: INFO SQL_SERVER: "${SQL_SERVER}" @@ -43,9 +45,5 @@ spec: environmentConfig: - environment: qa replicas: 1 - variables: - PIPELINE_IMG_TAG: "master-latest" - environment: prod replicas: 2 - variables: - PIPELINE_IMG_TAG: "release-latest" diff --git a/radixconfig.yaml b/radixconfig.yaml deleted file mode 100644 index 89f0909..0000000 --- a/radixconfig.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: radix.equinor.com/v1 -kind: RadixApplication -metadata: - name: radix-cost-allocation-api -spec: - build: - useBuildKit: true - environments: - - name: prod - build: - from: release - - name: qa - build: - from: master - components: - - name: server - readOnlyFileSystem: true - src: "." - dockerfileName: "Dockerfile" - ports: - - name: http - port: 3003 - resources: - requests: - memory: "1500Mi" - cpu: "20m" - limits: - memory: "2000Mi" - cpu: "1000m" - monitoring: true - publicPort: http - variables: - LOG_LEVEL: INFO - SQL_SERVER: "sql-radix-cost-allocation-dev.database.windows.net" - SQL_DATABASE: "sqldb-radix-cost-allocation" - WHITELIST: '{"whiteList":["canarycicd-test","canarycicd-test1","canarycicd-test2","canarycicd-test3","canarycicd-test4","radix-api","radix-canary-golang","radix-cost-allocation-api","radix-github-webhook","radix-platform","radix-web-console","radix-vulnerability-scanner-api","radix-networkpolicy-canary","radix-servicenow-proxy"]}' - AD_REPORT_READERS: '{"groups":["ad4f6a93-79fb-4a6e-9861-e280bf6cb4e6"]}' - TOKEN_AUDIENCE: "6dae42f8-4368-4678-94ff-3960e28e3630" - TOKEN_ISSUER: "https://sts.windows.net/3aa4a235-b6e2-48d5-9195-7fcf05b459b0/" - identity: - azure: - clientId: "b8fd30d4-61d0-4842-b6c1-e91ceb58db8c" - environmentConfig: - - environment: qa - replicas: 1 - variables: - PIPELINE_IMG_TAG: "master-latest" - - environment: prod - replicas: 2 - variables: - PIPELINE_IMG_TAG: "release-latest"