-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f30a843
commit 976f321
Showing
17 changed files
with
568 additions
and
48 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
* @spacelift-io/sirius |
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,12 @@ | ||
name: Setup golang | ||
description: "setup golang" | ||
inputs: | ||
version: | ||
description: "golang version" | ||
default: 1.21.4 | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ inputs.version }} |
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,33 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: setup go | ||
uses: ./.github/actions/setup-go/ | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build controller binary | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
args: build --snapshot | ||
|
||
- name: Build container image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: false |
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,59 @@ | ||
name: Lint | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
jobs: | ||
generate: | ||
name: generated files | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: setup go | ||
uses: ./.github/actions/setup-go/ | ||
- name: Make sure generated files are up to date | ||
run: | | ||
make generate | ||
git diff --no-patch --exit-code | ||
if [ $? -ne 0 ]; then | ||
echo "Please run make generate and commit the changes." | ||
exit 1 | ||
fi | ||
lint-manifest: | ||
name: Manifests | ||
runs-on: ubuntu-latest-4-cores | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: setup go | ||
uses: ./.github/actions/setup-go/ | ||
- name: Make sure manifest are up to date | ||
run: | | ||
make manifests | ||
git diff --no-patch --exit-code | ||
if [ $? -ne 0 ]; then | ||
echo "Please run make manifests and commit the changes." | ||
exit 1 | ||
fi | ||
lint-go: | ||
name: GO code | ||
runs-on: ubuntu-latest-4-cores | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: setup go | ||
uses: ./.github/actions/setup-go/ | ||
- name: Make sure go.mod and go.sum are up to date | ||
run: | | ||
go mod tidy | ||
git diff --no-patch --exit-code go.mod go.sum | ||
if [ $? -ne 0 ]; then | ||
echo "Please run go mod tidy and commit the changes." | ||
exit 1 | ||
fi | ||
- name: Run golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.54.2 | ||
args: --verbose |
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,17 @@ | ||
name: Test | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
jobs: | ||
unit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: setup go | ||
uses: ./.github/actions/setup-go/ | ||
- name: Test | ||
run: make test |
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 |
---|---|---|
|
@@ -24,3 +24,5 @@ Dockerfile.cross | |
*.swp | ||
*.swo | ||
*~ | ||
|
||
/dist |
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,139 @@ | ||
# This file contains all available configuration options | ||
# with their default values. | ||
|
||
# options for analysis running | ||
run: | ||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
timeout: 5m | ||
|
||
# include test files or not, default is true | ||
tests: false | ||
|
||
# default is true. Enables skipping of directories: | ||
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ | ||
skip-dirs-use-default: true | ||
|
||
|
||
# output configuration options | ||
output: | ||
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions | ||
# default is "colored-line-number" | ||
format: colored-line-number | ||
|
||
# print lines of code with issue, default is true | ||
print-issued-lines: true | ||
|
||
# print linter name in the end of issue text, default is true | ||
print-linter-name: true | ||
|
||
# make issues output unique by line, default is true | ||
uniq-by-line: true | ||
|
||
# add a prefix to the output file references; default is no prefix | ||
path-prefix: "" | ||
|
||
# sorts results by: filepath, line and column | ||
sort-results: false | ||
|
||
|
||
linters-settings: | ||
dupl: | ||
threshold: 100 | ||
funlen: | ||
lines: 100 | ||
statements: 50 | ||
gci: | ||
sections: | ||
- standard | ||
- default | ||
- prefix(github.com/spacelift-io/spacelift-operator) | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
staticcheck: | ||
go: "1.20" | ||
checks: [ "all", "-SA1019"] | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- performance | ||
disabled-checks: | ||
- ifElseChain | ||
- wrapperFunc | ||
- hugeParam | ||
- rangeValCopy | ||
- appendCombine | ||
- commentedOutCode | ||
- sloppyReassign | ||
- filepathJoin | ||
- evalOrder | ||
- equalFold | ||
- returnAfterHttpError | ||
- preferStringWriter | ||
- sprintfQuotedString | ||
- preferFprint | ||
goimports: | ||
local-prefixes: github.com/spacelift-io/spacelift-operator | ||
govet: | ||
check-shadowing: false | ||
nolintlint: | ||
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space) | ||
require-explanation: false # don't require an explanation for nolint directives | ||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped | ||
depguard: | ||
rules: | ||
main: | ||
deny: | ||
- pkg: "io/ioutil" | ||
# https://go.dev/doc/go1.16#ioutil | ||
desc: io/ioutil package has been deprecated. | ||
|
||
errorlint: | ||
errorf: false | ||
errorf-multi: false | ||
asserts: false | ||
comparison: true | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- depguard | ||
- exportloopref | ||
- gci | ||
- gocritic | ||
- gofmt | ||
- goimports | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- nolintlint | ||
- staticcheck | ||
- typecheck | ||
- errorlint | ||
|
||
severity: | ||
# Default value is empty string. | ||
# Set the default severity for issues. If severity rules are defined and the issues | ||
# do not match or no severity is provided to the rule this will be the default | ||
# severity applied. Severities should match the supported severity names of the | ||
# selected out format. | ||
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity | ||
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity | ||
# - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message | ||
default-severity: error | ||
|
||
# The default value is false. | ||
# If set to true severity-rules regular expressions become case sensitive. | ||
case-sensitive: false | ||
|
||
# Default value is empty list. | ||
# When a list of severity rules are provided, severity information will be added to lint | ||
# issues. Severity rules have the same filtering capability as exclude rules except you | ||
# are allowed to specify one matcher per severity rule. | ||
# Only affects out formats that support setting severity information. | ||
rules: | ||
- linters: | ||
- dupl | ||
severity: info |
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,15 @@ | ||
version: 1 | ||
|
||
project_name: spacelift-operator | ||
|
||
builds: | ||
- main: ./cmd | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
ldflags: | ||
- -s -w -X github.com/spacelift-io/spacelift-operator/internal/build.Version={{.Version}} |
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 |
---|---|---|
@@ -1,33 +1,12 @@ | ||
# Build the manager binary | ||
FROM golang:1.20 as builder | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY cmd/main.go cmd/main.go | ||
COPY api/ api/ | ||
COPY internal/controller/ internal/controller/ | ||
|
||
# Build | ||
# the GOARCH has not a default value to allow the binary be built according to the host where the command | ||
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO | ||
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, | ||
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
|
||
ARG TARGETARCH | ||
ARG TARGETOS | ||
|
||
WORKDIR / | ||
COPY --from=builder /workspace/manager . | ||
COPY dist/spacelift-operator_${TARGETOS}_${TARGETARCH}*/spacelift-operator . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/manager"] | ||
ENTRYPOINT ["/spacelift-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
Oops, something went wrong.