Skip to content

Commit 42b94f2

Browse files
Merge pull request #14 from goto-opensource/feature/update-kubebuilder
feat: update to latest kubebuilder and AWS SDK
2 parents 287758b + eb7d36e commit 42b94f2

14 files changed

+1067
-232
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ bin
99

1010
# Test binary, build with `go test -c`
1111
*.test
12+
/testbin
1213

1314
# Output of the go coverage tool, specifically when used with LiteIDE
1415
*.out

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.14.4 as builder
2+
FROM golang:1.18 as builder
33

44
WORKDIR /workspace
55
# Copy the go source

Makefile

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:latest
44
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
5-
CRD_OPTIONS ?= "crd:trivialVersions=true"
5+
CRD_OPTIONS ?= "crd"
66

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

1414
all: manager
1515

16-
# Run tests
17-
test: generate fmt vet manifests
18-
go test ./... -coverprofile cover.out
16+
# Setting SHELL to bash allows bash commands to be executed by recipes.
17+
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
18+
SHELL = /usr/bin/env bash -o pipefail
19+
.SHELLFLAGS = -ec
20+
21+
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
22+
test: manifests generate fmt vet ## Run tests.
23+
mkdir -p ${ENVTEST_ASSETS_DIR}
24+
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
25+
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out
1926

2027
# Build manager binary
2128
manager: generate fmt vet
@@ -62,19 +69,34 @@ docker-build: test
6269
docker-push:
6370
docker push ${IMG}
6471

65-
# find or download controller-gen
66-
# download controller-gen if necessary
67-
controller-gen:
68-
ifeq (, $(shell which controller-gen))
69-
@{ \
70-
set -e ;\
71-
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
72-
cd $$CONTROLLER_GEN_TMP_DIR ;\
73-
go mod init tmp ;\
74-
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
75-
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
76-
}
77-
CONTROLLER_GEN=$(GOBIN)/controller-gen
78-
else
79-
CONTROLLER_GEN=$(shell which controller-gen)
80-
endif
72+
##@ Build Dependencies
73+
74+
## Location to install dependencies to
75+
LOCALBIN ?= $(shell pwd)/bin
76+
$(LOCALBIN):
77+
mkdir -p $(LOCALBIN)
78+
79+
## Tool Binaries
80+
KUSTOMIZE ?= $(LOCALBIN)/kustomize
81+
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
82+
ENVTEST ?= $(LOCALBIN)/setup-envtest
83+
84+
## Tool Versions
85+
KUSTOMIZE_VERSION ?= v3.8.7
86+
CONTROLLER_TOOLS_VERSION ?= v0.9.0
87+
88+
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
89+
.PHONY: kustomize
90+
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
91+
$(KUSTOMIZE): $(LOCALBIN)
92+
test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
93+
94+
.PHONY: controller-gen
95+
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
96+
$(CONTROLLER_GEN): $(LOCALBIN)
97+
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
98+
99+
.PHONY: envtest
100+
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
101+
$(ENVTEST): $(LOCALBIN)
102+
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

PROJECT

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1-
version: "2"
2-
domain: k8s.logmein.com
1+
version: "3"
2+
projectName: k8s-aws-operator
3+
domain: logmein.com
34
repo: github.com/logmein/k8s-aws-operator
5+
layout:
6+
- go.kubebuilder.io/v3
7+
resources:
8+
- api:
9+
namespaced: true
10+
domain: logmein.com
11+
group: k8s
12+
kind: EIP
13+
- api:
14+
crdVersion: v1alpha1
15+
namespaced: true
16+
domain: logmein.com
17+
group: k8s
18+
kind: ENI
19+
controller: true
20+
path: k8s-aws-operator/api/v1alpha1

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 96 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,116 @@
1-
21
---
3-
apiVersion: apiextensions.k8s.io/v1beta1
2+
apiVersion: apiextensions.k8s.io/v1
43
kind: CustomResourceDefinition
54
metadata:
65
annotations:
7-
controller-gen.kubebuilder.io/version: v0.3.0
6+
controller-gen.kubebuilder.io/version: v0.9.0
87
creationTimestamp: null
98
name: eips.aws.k8s.logmein.com
109
spec:
11-
additionalPrinterColumns:
12-
- JSONPath: .status.state
13-
name: State
14-
type: string
15-
- JSONPath: .status.publicIPAddress
16-
name: Public IP
17-
type: string
18-
- JSONPath: .status.assignment.privateIPAddress
19-
name: Private IP
20-
type: string
21-
- JSONPath: .status.assignment.podName
22-
name: Pod
23-
type: string
24-
- JSONPath: .status.assignment.eni
25-
name: ENI
26-
type: string
2710
group: aws.k8s.logmein.com
2811
names:
2912
kind: EIP
3013
listKind: EIPList
3114
plural: eips
3215
singular: eip
3316
scope: Namespaced
34-
subresources: {}
35-
validation:
36-
openAPIV3Schema:
37-
description: EIP is the Schema for the eips API
38-
properties:
39-
apiVersion:
40-
description: 'APIVersion defines the versioned schema of this representation
41-
of an object. Servers should convert recognized schemas to the latest
42-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
43-
type: string
44-
kind:
45-
description: 'Kind is a string value representing the REST resource this
46-
object represents. Servers may infer this from the endpoint the client
47-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
48-
type: string
49-
metadata:
50-
type: object
51-
spec:
52-
description: EIPSpec defines the desired state of EIP
53-
properties:
54-
assignment:
55-
description: "Which resource this EIP should be assigned to. \n If not
56-
given, it will not be assigned to anything."
57-
properties:
58-
eni:
59-
type: string
60-
eniPrivateIPAddressIndex:
61-
type: integer
62-
podName:
63-
minLength: 0
64-
type: string
65-
privateIPAddress:
66-
type: string
67-
type: object
68-
publicIPAddress:
69-
type: string
70-
publicIPv4Pool:
71-
type: string
72-
publicIPv4Pools:
73-
items:
17+
versions:
18+
- additionalPrinterColumns:
19+
- jsonPath: .status.state
20+
name: State
21+
type: string
22+
- jsonPath: .status.publicIPAddress
23+
name: Public IP
24+
type: string
25+
- jsonPath: .status.assignment.privateIPAddress
26+
name: Private IP
27+
type: string
28+
- jsonPath: .status.assignment.podName
29+
name: Pod
30+
type: string
31+
- jsonPath: .status.assignment.eni
32+
name: ENI
33+
type: string
34+
name: v1alpha1
35+
schema:
36+
openAPIV3Schema:
37+
description: EIP is the Schema for the eips API
38+
properties:
39+
apiVersion:
40+
description: 'APIVersion defines the versioned schema of this representation
41+
of an object. Servers should convert recognized schemas to the latest
42+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
43+
type: string
44+
kind:
45+
description: 'Kind is a string value representing the REST resource this
46+
object represents. Servers may infer this from the endpoint the client
47+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
48+
type: string
49+
metadata:
50+
type: object
51+
spec:
52+
description: EIPSpec defines the desired state of EIP
53+
properties:
54+
assignment:
55+
description: "Which resource this EIP should be assigned to. \n If
56+
not given, it will not be assigned to anything."
57+
properties:
58+
eni:
59+
type: string
60+
eniPrivateIPAddressIndex:
61+
type: integer
62+
podName:
63+
minLength: 0
64+
type: string
65+
privateIPAddress:
66+
type: string
67+
type: object
68+
publicIPAddress:
7469
type: string
75-
type: array
76-
tags:
77-
additionalProperties:
70+
publicIPv4Pool:
7871
type: string
79-
description: Tags that will be applied to the created EIP.
80-
type: object
81-
type: object
82-
status:
83-
description: EIPStatus defines the observed state of EIP
84-
properties:
85-
allocationId:
86-
type: string
87-
assignment:
88-
properties:
89-
eni:
90-
type: string
91-
eniPrivateIPAddressIndex:
92-
type: integer
93-
podName:
94-
minLength: 0
72+
publicIPv4Pools:
73+
items:
9574
type: string
96-
privateIPAddress:
75+
type: array
76+
tags:
77+
additionalProperties:
9778
type: string
98-
type: object
99-
associationId:
100-
type: string
101-
publicIPAddress:
102-
type: string
103-
state:
104-
description: "Current state of the EIP object. \n State transfer diagram:
105-
\n /------- unassigning <----\\--------------\\
106-
\ | | | *start*:
107-
\ V | | allocating ->
108-
allocated <-> assigning -> assigned <-> reassigning |
109-
\ | *end*: | | releasing <------/-------------/"
110-
type: string
111-
required:
112-
- state
113-
type: object
114-
type: object
115-
version: v1alpha1
116-
versions:
117-
- name: v1alpha1
79+
description: Tags that will be applied to the created EIP.
80+
type: object
81+
type: object
82+
status:
83+
description: EIPStatus defines the observed state of EIP
84+
properties:
85+
allocationId:
86+
type: string
87+
assignment:
88+
properties:
89+
eni:
90+
type: string
91+
eniPrivateIPAddressIndex:
92+
type: integer
93+
podName:
94+
minLength: 0
95+
type: string
96+
privateIPAddress:
97+
type: string
98+
type: object
99+
associationId:
100+
type: string
101+
publicIPAddress:
102+
type: string
103+
state:
104+
description: "Current state of the EIP object. \n State transfer diagram:
105+
\n /------- unassigning <----\\--------------\\ | |
106+
\ | *start*: V | |
107+
allocating -> allocated <-> assigning -> assigned <-> reassigning
108+
| | *end*: | | releasing <------/-------------/"
109+
type: string
110+
required:
111+
- state
112+
type: object
113+
type: object
118114
served: true
119115
storage: true
120-
status:
121-
acceptedNames:
122-
kind: ""
123-
plural: ""
124-
conditions: []
125-
storedVersions: []
116+
subresources: {}

0 commit comments

Comments
 (0)