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

Closes #140 - Upgrading to kubebuilder format and SDK 1.0.1 #175

Merged
merged 3 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
branches:
- main
env:
OPERATOR_SDK_VERSION: v0.18.1
OPERATOR_SDK_VERSION: v1.0.1
GO_VERSION: 1.14
jobs:
golint:
Expand All @@ -31,11 +31,10 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Install Operator-sdk
run: ./hack/ci/install-operator-sdk.sh
- name: Check Vet
run: |
./hack/go-vet.sh
make generate
make manifests
changed_files=$(git status -s | grep -v 'go.mod\|go.sum' || :)
generated_changed_files=$(git status -s | grep zz_generated || :)
[[ -z "$generated_changed_files" ]] || (printf "There is change in auto-generated files" && exit 1)
Expand All @@ -60,108 +59,93 @@ jobs:
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ~/go/pkg/mod/cache
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-cache-

- name: Cache Operator SDK
uses: actions/cache@v2
with:
path: ${{ env.GOPATH }}/bin/operator-sdk
key: ${{ runner.os }}-sdk-cache-${{ env.OPERATOR_SDK_VERSION }}
restore-keys: |
${{ runner.os }}-sdk-cache
- name: Install Operator SDK
run: ./hack/ci/install-operator-sdk.sh

- name: Mod Tidy
run: |
go mod tidy

- name: FMT
run: gofmt -s -l -w cmd/ pkg/ version/

- name: Vet
run: go vet ./...

- name: Cache testenv
uses: actions/cache@v2
with:
path: ${{ env.PATH }}/nexus-operator/testbin
key: ${{ runner.os }}-testbin-${{ env.OPERATOR_SDK_VERSION }}
restore-keys: |
${{ runner.os }}-testbin-${{ env.OPERATOR_SDK_VERSION }}
- name: Test Packages
run: go test ./pkg/... -count=1 -coverprofile=coverage.txt -covermode=atomic
run: make test
- name: Validate codcov yaml file
run: curl -vvv --data-binary @codecov.yml https://codecov.io/validate
- name: Send Coverage Report
uses: codecov/codecov-action@v1
with:
file: ./coverage.txt
file: ./cover.out
flags: operator
name: operator-test
fail_ci_if_error: true

integration_tests:
name: Integration Tests
# we should wait for an ok from the other two
needs: [golint, unit_test]
runs-on: ubuntu-latest
env:
CLUSTER_NAME: operator-test
KIND_VERSION: v0.8.1
CREATE_NAMESPACE: false
NAMESPACE_E2E: default
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/go/pkg/mod/cache
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-cache-

- name: Cache Binaries
uses: actions/cache@v1
with:
path: ~/go/bin/
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}

- name: Install Operator SDK
run: |
./hack/ci/install-operator-sdk.sh

- name: Install KIND
run: |
./hack/ci/install-kind.sh
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH

- name: Start KIND
run: ./hack/ci/start-kind.sh

- name: Generate Manifests
run: ./hack/generate-manifests.sh

- name: Build Operator Image
env:
BUILDER: docker
CUSTOM_BASE_IMAGE: alpine:latest
run: |
./hack/go-build.sh

- name: Load Operator Image
run: ./hack/ci/load-operator-image.sh

- name: Run e2e test
env:
RUN_WITH_IMAGE: true
TIMEOUT_E2E: 30m
ADDITIONAL_FLAGS: "-coverprofile=coverage_e2e.txt -covermode=atomic"
run: ./hack/run-e2e-test.sh

- name: Send Coverage Report
uses: codecov/codecov-action@v1
with:
file: ./coverage_e2e.txt
flags: operator-e2e
name: operator-e2e-test
fail_ci_if_error: false

- name: Run Operator OLM Integration Test
run: ./hack/ci/operator-olm-test.sh
name: Integration Tests
# we should wait for an ok from the other two
needs: [golint, unit_test]
runs-on: ubuntu-latest
env:
CLUSTER_NAME: operator-test
KIND_VERSION: v0.8.1
CREATE_NAMESPACE: false
NAMESPACE_E2E: default
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/go/pkg/mod/cache
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-cache-
- name: Cache Binaries
uses: actions/cache@v2
with:
path: ~/go/bin/
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}
- name: Install Operator SDK
run: |
./hack/ci/install-operator-sdk.sh
- name: Install KIND
run: |
./hack/ci/install-kind.sh
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Start KIND
run: ./hack/ci/start-kind.sh

- name: Generate Manifests
run: make bundle

- name: Build Operator Image
run: make operator-build BUILDER=docker

- name: Run Operator OLM Integration Test
run: make ci-olm-test
92 changes: 17 additions & 75 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,88 +1,30 @@
*.bak
# Temporary Build Files
build/_output
build/_test
testbin/*
# built binary
nexus-operator

# logs
*.log
build
.vscode

# bin tools addition
bin/

# Created by https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
projectile-bookmarks.eld
# directory configuration
.dir-locals.el
# saveplace
places
# url cache
url/cache/
# cedet
ede-projects.el
# smex
smex-items
# company-statistics
company-statistics-cache.el
# anaconda-mode
anaconda-mode/
### Go ###
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, build with 'go test -c'
bin

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
### Vim ###
# swap
.sw[a-p]
.*.sw[a-p]
# session
Session.vim
# temporary
.netrwhist
# auto-generated tag files
tags
### VisualStudioCode ###
.vscode/*
.history
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
vendor

# Kubernetes Generated files - skip generated files, except for vendored files

!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
*.swp
*.swo
*~
11 changes: 0 additions & 11 deletions .osdk-scorecard.yaml

This file was deleted.

26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Build the manager binary
FROM golang:1.14 as builder

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 main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
WORKDIR /
COPY --from=builder /workspace/manager .
USER 1001

ENTRYPOINT ["/manager"]
Loading