-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sync-subpipeline-sas
- Loading branch information
Showing
24 changed files
with
524 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,45 @@ on: | |
branches: | ||
- master | ||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
- name: Install dependencies | ||
run: go mod download | ||
- name: Run Tests | ||
run: CGO_ENABLED=0 GOOS=linux go test `go list ./... | grep -v "pkg/client"` -timeout 2m | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
- name: Install dependencies | ||
run: go mod download | ||
- name: Install GolangCI Lint | ||
run: go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
- name: Install StaticCheck | ||
run: go install honnef.co/go/tools/cmd/[email protected] | ||
|
||
- name: golangci-lint | ||
run: golangci-lint run --timeout=30m --max-same-issues=0 --out-format=github-actions --new | ||
|
||
# Add legacy checks since golangci-lint only tests changed files for now | ||
- name: StaticCheck | ||
run: staticcheck -f text `go list ./... | grep -v "pkg/client"` | ||
- name: Go Vet | ||
run: go vet `go list ./... | grep -v "pkg/client"` | ||
|
||
build-operator: | ||
name: Build-operator | ||
runs-on: ubuntu-latest | ||
|
@@ -14,6 +53,7 @@ jobs: | |
REF: ${{ github. sha }} | ||
DOCKER_BUILDKIT: 1 | ||
run: docker build -t radix-operator:${REF##*/} -f operator.Dockerfile . | ||
|
||
build-pipeline: | ||
name: Build-pipeline | ||
runs-on: ubuntu-latest | ||
|
@@ -23,4 +63,4 @@ jobs: | |
env: | ||
REF: ${{ github. sha }} | ||
DOCKER_BUILDKIT: 1 | ||
run: docker build -t radix-operator:${REF##*/} -f pipeline.Dockerfile . | ||
run: docker build -t radix-operator:${REF##*/} -f pipeline.Dockerfile . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,16 +13,6 @@ RUN go mod download | |
COPY ./radix-operator ./radix-operator | ||
COPY ./pkg ./pkg | ||
|
||
FROM base as run-staticcheck | ||
RUN go install honnef.co/go/tools/cmd/[email protected] | ||
RUN staticcheck `go list ./... | grep -v "pkg/client"` && touch /staticcheck.done | ||
|
||
FROM base as tester | ||
# Run tests | ||
RUN go vet `go list ./... | grep -v "pkg/client"` && \ | ||
CGO_ENABLED=0 GOOS=linux go test `go list ./... | grep -v "pkg/client"` && \ | ||
touch /tests.done | ||
|
||
FROM base as builder | ||
# Build | ||
WORKDIR /go/src/github.com/equinor/radix-operator/radix-operator/ | ||
|
@@ -35,8 +25,6 @@ FROM scratch | |
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /go/src/github.com/equinor/radix-operator/radix-operator/rootfs/radix-operator /usr/local/bin/radix-operator | ||
# This will make sure staticcheck and tests are run before the final stage is built | ||
COPY --from=run-staticcheck /staticcheck.done /staticcheck.done | ||
COPY --from=tester /tests.done /tests.done | ||
|
||
USER radix-operator | ||
ENTRYPOINT ["/usr/local/bin/radix-operator"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package test | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/equinor/radix-operator/pipeline-runner/internal/hash" | ||
"github.com/equinor/radix-operator/pipeline-runner/model" | ||
pipelineDefaults "github.com/equinor/radix-operator/pipeline-runner/model/defaults" | ||
"github.com/equinor/radix-operator/pkg/apis/defaults" | ||
radixv1 "github.com/equinor/radix-operator/pkg/apis/radix/v1" | ||
"github.com/equinor/radix-operator/pkg/apis/utils" | ||
"gopkg.in/yaml.v3" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes" | ||
yamlk8s "sigs.k8s.io/yaml" | ||
) | ||
|
||
func CreatePreparePipelineConfigMapResponse(kubeClient kubernetes.Interface, configMapName, appName string, ra *radixv1.RadixApplication, buildCtx *model.PrepareBuildContext) error { | ||
raBytes, err := yamlk8s.Marshal(ra) | ||
if err != nil { | ||
return err | ||
} | ||
data := map[string]string{ | ||
pipelineDefaults.PipelineConfigMapContent: string(raBytes), | ||
} | ||
|
||
if buildCtx != nil { | ||
buildCtxBytes, err := yaml.Marshal(buildCtx) | ||
if err != nil { | ||
return err | ||
} | ||
data[pipelineDefaults.PipelineConfigMapBuildContext] = string(buildCtxBytes) | ||
} | ||
cm := &corev1.ConfigMap{ | ||
ObjectMeta: metav1.ObjectMeta{Name: configMapName}, | ||
Data: data, | ||
} | ||
_, err = kubeClient.CoreV1().ConfigMaps(utils.GetAppNamespace(appName)).Create(context.Background(), cm, metav1.CreateOptions{}) | ||
return err | ||
} | ||
|
||
func CreateGitInfoConfigMapResponse(kubeClient kubernetes.Interface, configMapName, appName, gitHash, gitTags string) error { | ||
cm := &corev1.ConfigMap{ | ||
ObjectMeta: metav1.ObjectMeta{Name: configMapName}, | ||
Data: map[string]string{ | ||
defaults.RadixGitCommitHashKey: gitHash, | ||
defaults.RadixGitTagsKey: gitTags, | ||
}, | ||
} | ||
_, err := kubeClient.CoreV1().ConfigMaps(utils.GetAppNamespace(appName)).Create(context.Background(), cm, metav1.CreateOptions{}) | ||
return err | ||
} | ||
|
||
func CreateBuildSecret(kubeClient kubernetes.Interface, appName string, data map[string][]byte) error { | ||
secret := &corev1.Secret{ | ||
ObjectMeta: metav1.ObjectMeta{Name: defaults.BuildSecretsName}, | ||
Data: data, | ||
} | ||
|
||
_, err := kubeClient.CoreV1().Secrets(utils.GetAppNamespace(appName)).Create(context.Background(), secret, metav1.CreateOptions{}) | ||
return err | ||
} | ||
|
||
func GetRadixApplicationHash(ra *radixv1.RadixApplication) string { | ||
if ra == nil { | ||
hash, _ := hash.ToHashString(hash.SHA256, "0nXSg9l6EUepshGFmolpgV3elB0m8Mv7") | ||
return hash | ||
} | ||
hash, _ := hash.ToHashString(hash.SHA256, ra.Spec) | ||
return hash | ||
} | ||
|
||
func GetBuildSecretHash(secret *corev1.Secret) string { | ||
if secret == nil { | ||
hash, _ := hash.ToHashString(hash.SHA256, "34Wd68DsJRUzrHp2f63o3U5hUD6zl8Tj") | ||
return hash | ||
} | ||
hash, _ := hash.ToHashString(hash.SHA256, secret.Data) | ||
return hash | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.