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

feat: operator lifecycle manager #66

Merged
merged 20 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
20 changes: 11 additions & 9 deletions .github/common-actions/e2e-test-cli/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,29 @@ runs:
working-directory: /tmp/operator-builder-test
run: |
if [[ "${{ inputs.test-deploy }}" == "true" ]]; then
COMMAND=`find ${PWD}/bin ! -name kustomize ! -name controller-gen ! -name operator-builder -type f`
MANIFEST=`find ${PWD}/config/samples -name "*.yaml" | head -1`
echo "::set-output name=command::${COMMAND}"
echo "::set-output name=manifest::${MANIFEST}"
COMMAND=`find ${PWD}/bin ! -name kustomize ! -name controller-gen ! -name operator-builder ! -name kube-apiserver ! -name etcd ! -name kubectl ! -name setup-envtest -type f`
echo $COMMAND
MANIFEST=`find ${PWD}/config/samples ! -name kustomization.yaml -name "*.yaml" | head -1`
echo $MANIFEST
echo "CLI_COMMAND=$COMMAND" >> "$GITHUB_OUTPUT"
echo "CLI_MANIFEST=$MANIFEST" >> "$GITHUB_OUTPUT"
fi

- name: Generate and Apply Child Resources
shell: bash
run: |
if [[ "${{ inputs.test-deploy }}" == "true" ]]; then
${{ steps.get-cli-inputs.outputs.command }} generate \
-w ${{ steps.get-cli-inputs.outputs.manifest }} \
${{ steps.get-cli-inputs.outputs.CLI_COMMAND }} generate \
-w ${{ steps.get-cli-inputs.outputs.CLI_MANIFEST }} \
| kubectl apply -f -
fi

- name: Uninstall Child Resources
shell: bash
run: |
if [[ "${{ inputs.test-deploy }}" == "true" ]]; then
${{ steps.get-cli-inputs.outputs.command }} generate \
-w ${{ steps.get-cli-inputs.outputs.manifest }} \
${{ steps.get-cli-inputs.outputs.CLI_COMMAND }} generate \
-w ${{ steps.get-cli-inputs.outputs.CLI_MANIFEST }} \
| kubectl delete -f -
fi

Expand All @@ -56,7 +58,7 @@ runs:
run: |
if [[ "${{ inputs.test-deploy }}" == "true" ]]; then
make install
${{ steps.get-cli-inputs.outputs.command }} init | kubectl apply -f -
${{ steps.get-cli-inputs.outputs.CLI_COMMAND }} init | kubectl apply -f -
fi

- name: Uninstall Parent Custom Resources
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Check Latest Commit Message
run: make test-commit
Expand All @@ -27,7 +27,7 @@ jobs:
if: github.event_name == 'pull_request'
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Get PR Commits
id: get-pr-commits
Expand All @@ -52,7 +52,7 @@ jobs:
if: github.event_name == 'pull_request'
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Check Pull Request Title
uses: deepakputhraya/action-pr-title@master
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Check License Lines
uses: kt3k/license_checker@v1.0.6
Expand All @@ -91,13 +91,13 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: "1.19"

- name: Checkout Code
uses: actions/checkout@v3

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.46.2
version: v1.52.2
args: --timeout 3m
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: "1.19"

# NOTE: removing support for snapcraft as their CLI has become increasingly unstable and errors have become
# common place. See https://github.com/snapcore/action-publish/issues/28 for an example of some of the issues
Expand Down
48 changes: 24 additions & 24 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
fail-fast: false
matrix:
include:
- go-version: 1.18
- go-version: 1.19
- go-version: "1.19"
- go-version: "1.20"
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

Expand All @@ -42,24 +42,24 @@ jobs:
fail-fast: false
matrix:
include:
- go-version: 1.18
- go-version: 1.19
- go-version: "1.19"
- go-version: "1.20"
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Build Binary Artifact (operator-builder)
run: make build

- name: Store Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: operator-builder
path: bin/operator-builder
Expand All @@ -78,36 +78,36 @@ jobs:
- name: Standalone Operator (Current Go Version)
artifact: standalone-codebase
test-workload-path: test/cases/standalone
go-version: 1.19
go-version: "1.20"
- name: Standalone Edge Cases Operator (Current Go Version - 1)
artifact: standalone-edge-codebase
test-workload-path: test/cases/edge-standalone
go-version: 1.18
go-version: "1.19"
- name: Workload Collection Operator (Current Go Version)
artifact: collection-codebase
test-workload-path: test/cases/collection
go-version: 1.19
go-version: "1.20"
- name: Workload Collection Edge Cases Operator (Current Go Version - 1)
artifact: collection-edge-codebase
test-workload-path: test/cases/edge-collection
go-version: 1.18
go-version: "1.19"
env:
TEST_WORKLOAD_PATH: "${{ matrix.test-workload-path }}"
TEST_PATH: "/tmp/operator-builder-func-test"
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download operator-builder Binary
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: operator-builder
path: bin

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

Expand All @@ -122,7 +122,7 @@ jobs:

- name: Store ${{ matrix.name }} Codebase
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact }}
path: ${{ env.TEST_PATH }}
Expand All @@ -145,22 +145,22 @@ jobs:
artifact: standalone-codebase
test-build: "true"
test-deploy: "true"
go-version: 1.19
go-version: "1.20"
- name: Standalone Edge Cases Operator (Current Go Version - 1)
artifact: standalone-edge-codebase
test-build: "false"
test-deploy: "false"
go-version: 1.18
go-version: "1.19"
- name: Workload Collection Operator (Current Go Version)
artifact: collection-codebase
test-build: "true"
test-deploy: "false"
go-version: 1.19
go-version: "1.20"
- name: Workload Collection Edge Cases Operator (Current Go Version - 1)
artifact: collection-edge-codebase
test-build: "true"
test-deploy: "false"
go-version: 1.18
go-version: "1.19"
services:
registry:
image: registry:2
Expand All @@ -171,17 +171,17 @@ jobs:
working-directory: /tmp/operator-builder-test
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Download ${{ matrix.name }} Codebase
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: ${{ matrix.artifact }}
path: /tmp/operator-builder-test
Expand Down
13 changes: 5 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ linters:
- asciicheck
- bodyclose
#- cyclop
- deadcode
- depguard
- dogsled
- dupl
Expand All @@ -85,7 +84,8 @@ linters:
- forbidigo
- forcetypeassert
- funlen
- gci
# disable due to false positives
#- gci
- gochecknoglobals
- gochecknoinits
- gocognit
Expand All @@ -99,18 +99,15 @@ linters:
#- gofmt
- goheader
- goimports
- golint
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- ifshort
- importas
- ineffassign
- interfacer
- lll
- makezero
- misspell
Expand All @@ -126,7 +123,6 @@ linters:
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- testpackage
- thelper
Expand All @@ -135,7 +131,6 @@ linters:
- unconvert
- unparam
- unused
- varcheck
- wastedassign
- whitespace
- wrapcheck
Expand All @@ -152,7 +147,9 @@ issues:
- path: internal/commands/*\.go
linters:
- gochecknoglobals

- path: internal/plugins/workload/v1/scaffolds/templates/readme.go
linters:
- gomnd
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
Expand Down
2 changes: 1 addition & 1 deletion .licenserc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"**/*.go": [
"// Copyright 2022 Nukleros"
"// Copyright 2023 Nukleros"
]
}
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ INIT_OPTS=init \
--workload-config .workloadConfig/workload.yaml \
--repo github.com/acme/acme-cnp-mgr \
--skip-go-version-check \
--controller-image controller:latest
--controller-image controller:latest \
--enable-olm=true
CREATE_OPTS=create api \
--workload-config .workloadConfig/workload.yaml \
--controller \
--resource
--resource \
--enable-olm=true

define create_path
if [ ! -d $(1)/.workloadConfig ]; then\
Expand All @@ -34,7 +36,7 @@ install: build
#
# traditional testing
#
GOLANGCI_LINT_VERSION ?= v1.46.2
GOLANGCI_LINT_VERSION ?= v1.52.2
install-linter:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)

Expand Down
2 changes: 1 addition & 1 deletion cmd/operator-builder/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 Nukleros
// Copyright 2023 Nukleros
// Copyright 2021 VMware, Inc.
// SPDX-License-Identifier: MIT

Expand Down
Loading