Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable readonly filesystem #122

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions .github/workflows/radix-cost-allocation-api-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -37,32 +37,38 @@ 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
run: go mod download
- 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
Expand All @@ -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

Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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-<env>
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
Expand All @@ -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;)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
10 changes: 4 additions & 6 deletions radixconfig.c2.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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"
Expand All @@ -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"
10 changes: 4 additions & 6 deletions radixconfig.dev.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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"
Expand All @@ -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"
10 changes: 4 additions & 6 deletions radixconfig.platform.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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"
Expand All @@ -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"
10 changes: 4 additions & 6 deletions radixconfig.playground.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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"
Expand All @@ -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"
10 changes: 4 additions & 6 deletions radixconfig.tpl.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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}"
Expand All @@ -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"
51 changes: 0 additions & 51 deletions radixconfig.yaml

This file was deleted.

Loading