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

Fix .dockerignore, add docker run and go vet tests in CI #55

Merged
merged 12 commits into from
Oct 16, 2024
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
!go.sum
!.git/
!internal/
!main.go/
!main.go
!main_init.go
!main_generate.go
!main_resources.go/
11 changes: 10 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run Go Vet
run: go vet ./...
- name: Run Go Tests
run: go test ./... -cover -race
- name: Build binary
Expand All @@ -33,4 +35,11 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
push: false
push: false
load: true
tags: score-k8s:test
- name: Test docker image
run: |
docker run --rm score-k8s:test --version
docker run -v .:/score-k8s --rm score-k8s:test init
ls | grep score.yaml
11 changes: 9 additions & 2 deletions internal/convert/container_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ func convertContainerFile(
Name: mount.Name,
VolumeSource: coreV1.VolumeSource{
ConfigMap: &coreV1.ConfigMapVolumeSource{
Items: []coreV1.KeyToPath{{"file", filepath.Base(fileElem.Target), mountMode}},
Items: []coreV1.KeyToPath{{
Key: "file",
Path: filepath.Base(fileElem.Target),
Mode: mountMode,
}},
LocalObjectReference: coreV1.LocalObjectReference{Name: configMapName},
},
},
Expand All @@ -107,7 +111,10 @@ func convertContainerFile(
VolumeSource: coreV1.VolumeSource{
Secret: &coreV1.SecretVolumeSource{
SecretName: refs[0].Name,
Items: []coreV1.KeyToPath{{refs[0].Key, filepath.Base(fileElem.Target), mountMode}},
Items: []coreV1.KeyToPath{{
Key: refs[0].Key,
Path: filepath.Base(fileElem.Target),
Mode: mountMode}},
},
},
}, nil
Expand Down