Skip to content

Commit

Permalink
Merge pull request #14 from goto-opensource/feature/update-kubebuilder
Browse files Browse the repository at this point in the history
feat: update to latest kubebuilder and AWS SDK
  • Loading branch information
alfredkrohmer authored Nov 17, 2022
2 parents 287758b + eb7d36e commit 42b94f2
Show file tree
Hide file tree
Showing 14 changed files with 1,067 additions and 232 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bin

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

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.14.4 as builder
FROM golang:1.18 as builder

WORKDIR /workspace
# Copy the go source
Expand Down
62 changes: 42 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
CRD_OPTIONS ?= "crd"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand All @@ -13,9 +13,16 @@ endif

all: manager

# Run tests
test: generate fmt vet manifests
go test ./... -coverprofile cover.out
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
test: manifests generate fmt vet ## Run tests.
mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out

# Build manager binary
manager: generate fmt vet
Expand Down Expand Up @@ -62,19 +69,34 @@ docker-build: test
docker-push:
docker push ${IMG}

# find or download controller-gen
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
##@ Build Dependencies

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.9.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
21 changes: 19 additions & 2 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
version: "2"
domain: k8s.logmein.com
version: "3"
projectName: k8s-aws-operator
domain: logmein.com
repo: github.com/logmein/k8s-aws-operator
layout:
- go.kubebuilder.io/v3
resources:
- api:
namespaced: true
domain: logmein.com
group: k8s
kind: EIP
- api:
crdVersion: v1alpha1
namespaced: true
domain: logmein.com
group: k8s
kind: ENI
controller: true
path: k8s-aws-operator/api/v1alpha1
1 change: 1 addition & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

201 changes: 96 additions & 105 deletions config/crd/bases/aws.k8s.logmein.com_eips.yaml
Original file line number Diff line number Diff line change
@@ -1,125 +1,116 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
name: eips.aws.k8s.logmein.com
spec:
additionalPrinterColumns:
- JSONPath: .status.state
name: State
type: string
- JSONPath: .status.publicIPAddress
name: Public IP
type: string
- JSONPath: .status.assignment.privateIPAddress
name: Private IP
type: string
- JSONPath: .status.assignment.podName
name: Pod
type: string
- JSONPath: .status.assignment.eni
name: ENI
type: string
group: aws.k8s.logmein.com
names:
kind: EIP
listKind: EIPList
plural: eips
singular: eip
scope: Namespaced
subresources: {}
validation:
openAPIV3Schema:
description: EIP is the Schema for the eips API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: EIPSpec defines the desired state of EIP
properties:
assignment:
description: "Which resource this EIP should be assigned to. \n If not
given, it will not be assigned to anything."
properties:
eni:
type: string
eniPrivateIPAddressIndex:
type: integer
podName:
minLength: 0
type: string
privateIPAddress:
type: string
type: object
publicIPAddress:
type: string
publicIPv4Pool:
type: string
publicIPv4Pools:
items:
versions:
- additionalPrinterColumns:
- jsonPath: .status.state
name: State
type: string
- jsonPath: .status.publicIPAddress
name: Public IP
type: string
- jsonPath: .status.assignment.privateIPAddress
name: Private IP
type: string
- jsonPath: .status.assignment.podName
name: Pod
type: string
- jsonPath: .status.assignment.eni
name: ENI
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: EIP is the Schema for the eips API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: EIPSpec defines the desired state of EIP
properties:
assignment:
description: "Which resource this EIP should be assigned to. \n If
not given, it will not be assigned to anything."
properties:
eni:
type: string
eniPrivateIPAddressIndex:
type: integer
podName:
minLength: 0
type: string
privateIPAddress:
type: string
type: object
publicIPAddress:
type: string
type: array
tags:
additionalProperties:
publicIPv4Pool:
type: string
description: Tags that will be applied to the created EIP.
type: object
type: object
status:
description: EIPStatus defines the observed state of EIP
properties:
allocationId:
type: string
assignment:
properties:
eni:
type: string
eniPrivateIPAddressIndex:
type: integer
podName:
minLength: 0
publicIPv4Pools:
items:
type: string
privateIPAddress:
type: array
tags:
additionalProperties:
type: string
type: object
associationId:
type: string
publicIPAddress:
type: string
state:
description: "Current state of the EIP object. \n State transfer diagram:
\n /------- unassigning <----\\--------------\\
\ | | | *start*:
\ V | | allocating ->
allocated <-> assigning -> assigned <-> reassigning |
\ | *end*: | | releasing <------/-------------/"
type: string
required:
- state
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
description: Tags that will be applied to the created EIP.
type: object
type: object
status:
description: EIPStatus defines the observed state of EIP
properties:
allocationId:
type: string
assignment:
properties:
eni:
type: string
eniPrivateIPAddressIndex:
type: integer
podName:
minLength: 0
type: string
privateIPAddress:
type: string
type: object
associationId:
type: string
publicIPAddress:
type: string
state:
description: "Current state of the EIP object. \n State transfer diagram:
\n /------- unassigning <----\\--------------\\ | |
\ | *start*: V | |
allocating -> allocated <-> assigning -> assigned <-> reassigning
| | *end*: | | releasing <------/-------------/"
type: string
required:
- state
type: object
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
subresources: {}
Loading

0 comments on commit 42b94f2

Please sign in to comment.