Skip to content

Commit 568702b

Browse files
committed
Upgrade to operator-sdk-v1.3
1 parent d264bb3 commit 568702b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+565
-480
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.13 as builder
2+
FROM golang:1.15 as builder
33

44
WORKDIR /workspace
55

Makefile

+28-36
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
SHELL := /bin/bash
21
# Current Operator version
32
VERSION ?= 0.0.1
4-
PKG_MAN_OPTS ?= $(PKG_FROM_VERSION) $(PKG_CHANNELS) $(PKG_IS_DEFAULT_CHANNEL)
53
# Default bundle image tag
64
BUNDLE_IMG ?= controller-bundle:$(VERSION)
75
# Options for 'bundle-build'
@@ -16,7 +14,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
1614
# Image URL to use all building/pushing image targets
1715
IMG ?= controller:latest
1816
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
19-
CRD_OPTIONS ?= "crd:trivialVersions=true"
17+
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
2018

2119
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
2220
ifeq (,$(shell go env GOBIN))
@@ -28,13 +26,11 @@ endif
2826
all: manager
2927

3028
# Run tests
31-
# test: generate fmt vet manifests
32-
# go test ./... -coverprofile cover.out
3329
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
3430
test: generate fmt vet manifests
3531
mkdir -p ${ENVTEST_ASSETS_DIR}
36-
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/master/hack/setup-envtest.sh
37-
. ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out
32+
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.7.0/hack/setup-envtest.sh
33+
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out
3834

3935
# Build manager binary
4036
manager: generate fmt vet
@@ -57,6 +53,10 @@ deploy: manifests kustomize
5753
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
5854
$(KUSTOMIZE) build config/default | kubectl apply -f -
5955

56+
# UnDeploy controller from the configured Kubernetes cluster in ~/.kube/config
57+
undeploy:
58+
$(KUSTOMIZE) build config/default | kubectl delete -f -
59+
6060
# Generate manifests e.g. CRD, RBAC etc.
6161
manifests: controller-gen
6262
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
@@ -75,43 +75,35 @@ generate: controller-gen
7575

7676
# Build the docker image
7777
docker-build: test
78-
docker build . -t ${IMG}
78+
docker build -t ${IMG} .
7979

8080
# Push the docker image
8181
docker-push:
8282
docker push ${IMG}
8383

84-
# find or download controller-gen
85-
# download controller-gen if necessary
84+
# Download controller-gen locally if necessary
85+
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
8686
controller-gen:
87-
ifeq (, $(shell which controller-gen))
88-
@{ \
89-
set -e ;\
90-
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
91-
cd $$CONTROLLER_GEN_TMP_DIR ;\
92-
go mod init tmp ;\
93-
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
94-
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
95-
}
96-
CONTROLLER_GEN=$(GOBIN)/controller-gen
97-
else
98-
CONTROLLER_GEN=$(shell which controller-gen)
99-
endif
87+
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
10088

89+
# Download kustomize locally if necessary
90+
KUSTOMIZE = $(shell pwd)/bin/kustomize
10191
kustomize:
102-
ifeq (, $(shell which kustomize))
103-
@{ \
104-
set -e ;\
105-
KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
106-
cd $$KUSTOMIZE_GEN_TMP_DIR ;\
107-
go mod init tmp ;\
108-
go get sigs.k8s.io/kustomize/kustomize/[email protected] ;\
109-
rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
110-
}
111-
KUSTOMIZE=$(GOBIN)/kustomize
112-
else
113-
KUSTOMIZE=$(shell which kustomize)
114-
endif
92+
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])
93+
94+
# go-get-tool will 'go get' any package $2 and install it to $1.
95+
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
96+
define go-get-tool
97+
@[ -f $(1) ] || { \
98+
set -e ;\
99+
TMP_DIR=$$(mktemp -d) ;\
100+
cd $$TMP_DIR ;\
101+
go mod init tmp ;\
102+
echo "Downloading $(2)" ;\
103+
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
104+
rm -rf $$TMP_DIR ;\
105+
}
106+
endef
115107

116108
# Generate bundle manifests and metadata, then validate generated files.
117109
.PHONY: bundle

PROJECT

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
domain: webservices.cern.ch
1+
domain: cern.ch
22
layout: go.kubebuilder.io/v3
33
projectName: drupalsite-operator
44
repo: gitlab.cern.ch/drupal/paas/drupalsite-operator
55
resources:
6-
- group: webservices.cern.ch
6+
- crdVersion: v1
7+
group: drupal.webservices
78
kind: DrupalSite
89
version: v1alpha1
9-
version: 3
10+
version: 3-alpha
1011
plugins:
1112
manifests.sdk.operatorframework.io/v2: {}
1213
scorecard.sdk.operatorframework.io/v2: {}

api/v1alpha1/drupalsiterequest_types.go api/v1alpha1/drupalsite_types.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
2+
Copyright 2021.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -22,16 +22,8 @@ import (
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
)
2424

25-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
26-
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
27-
2825
// DrupalSiteSpec defines the desired state of DrupalSite
2926
type DrupalSiteSpec struct {
30-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
31-
// Important: Run "make" to regenerate code after modifying this file
32-
33-
// Foo is an example field of DrupalSite. Edit DrupalSite_types.go to remove/update
34-
3527
// Publish defines if the site has to be published or not
3628
// +kubebuilder:validation:Required
3729
Publish bool `json:"publish"`
@@ -56,7 +48,7 @@ type DrupalSiteStatus struct {
5648
// +kubebuilder:object:root=true
5749
// +kubebuilder:subresource:status
5850

59-
// DrupalSite is the Schema for the drupalsiterequests API
51+
// DrupalSite is the Schema for the drupalsites API
6052
type DrupalSite struct {
6153
metav1.TypeMeta `json:",inline"`
6254
metav1.ObjectMeta `json:"metadata,omitempty"`

api/v1alpha1/groupversion_info.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
2+
Copyright 2021.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package v1alpha1 contains API Schema definitions for the webservices.cern.ch v1alpha1 API group
17+
// Package v1alpha1 contains API Schema definitions for the drupal.webservices v1alpha1 API group
1818
// +kubebuilder:object:generate=true
19-
// +groupName=webservices.cern.ch
19+
// +groupName=drupal.webservices.cern.ch
2020
package v1alpha1
2121

2222
import (
@@ -26,7 +26,7 @@ import (
2626

2727
var (
2828
// GroupVersion is group version used to register these objects
29-
GroupVersion = schema.GroupVersion{Group: "webservices.cern.ch", Version: "v1alpha1"}
29+
GroupVersion = schema.GroupVersion{Group: "drupal.webservices.cern.ch", Version: "v1alpha1"}
3030

3131
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
3232
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

api/v1alpha1/zz_generated.deepcopy.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/README.md

-2
This file was deleted.

config/certmanager/certificate.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# The following manifests contain a self-signed issuer CR and a certificate CR.
22
# More document can be found at https://docs.cert-manager.io
3-
# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for
4-
# breaking changes
5-
apiVersion: cert-manager.io/v1alpha2
3+
# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes.
4+
apiVersion: cert-manager.io/v1
65
kind: Issuer
76
metadata:
87
name: selfsigned-issuer
98
namespace: system
109
spec:
1110
selfSigned: {}
1211
---
13-
apiVersion: cert-manager.io/v1alpha2
12+
apiVersion: cert-manager.io/v1
1413
kind: Certificate
1514
metadata:
1615
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.4.1
8+
creationTimestamp: null
9+
name: drupalsites.drupal.webservices.cern.ch
10+
spec:
11+
group: drupal.webservices.cern.ch
12+
names:
13+
kind: DrupalSite
14+
listKind: DrupalSiteList
15+
plural: drupalsites
16+
singular: drupalsite
17+
scope: Namespaced
18+
versions:
19+
- name: v1alpha1
20+
schema:
21+
openAPIV3Schema:
22+
description: DrupalSite is the Schema for the drupalsites API
23+
properties:
24+
apiVersion:
25+
description: 'APIVersion defines the versioned schema of this representation
26+
of an object. Servers should convert recognized schemas to the latest
27+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
28+
type: string
29+
kind:
30+
description: 'Kind is a string value representing the REST resource this
31+
object represents. Servers may infer this from the endpoint the client
32+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
33+
type: string
34+
metadata:
35+
type: object
36+
spec:
37+
description: DrupalSiteSpec defines the desired state of DrupalSite
38+
properties:
39+
drupalVersion:
40+
description: DrupalVerion defines the version of the Drupal to install
41+
minLength: 1
42+
type: string
43+
publish:
44+
description: Publish defines if the site has to be published or not
45+
type: boolean
46+
required:
47+
- drupalVersion
48+
- publish
49+
type: object
50+
status:
51+
description: DrupalSiteStatus defines the observed state of DrupalSite
52+
properties:
53+
conditions:
54+
description: TODO conditions
55+
items:
56+
description: "Condition represents an observation of an object's
57+
state. Conditions are an extension mechanism intended to be used
58+
when the details of an observation are not a priori known or would
59+
not apply to all instances of a given Kind. \n Conditions should
60+
be added to explicitly convey properties that users and components
61+
care about rather than requiring those properties to be inferred
62+
from other observations. Once defined, the meaning of a Condition
63+
can not be changed arbitrarily - it becomes part of the API, and
64+
has the same backwards- and forwards-compatibility concerns of
65+
any other part of the API."
66+
properties:
67+
lastTransitionTime:
68+
format: date-time
69+
type: string
70+
message:
71+
type: string
72+
reason:
73+
description: ConditionReason is intended to be a one-word, CamelCase
74+
representation of the category of cause of the current status.
75+
It is intended to be used in concise output, such as one-line
76+
kubectl get output, and in summarizing occurrences of causes.
77+
type: string
78+
status:
79+
type: string
80+
type:
81+
description: "ConditionType is the type of the condition and
82+
is typically a CamelCased word or short phrase. \n Condition
83+
types should indicate state in the \"abnormal-true\" polarity.
84+
For example, if the condition indicates when a policy is invalid,
85+
the \"is valid\" case is probably the norm, so the condition
86+
should be called \"Invalid\"."
87+
type: string
88+
required:
89+
- status
90+
- type
91+
type: object
92+
type: array
93+
phase:
94+
description: 'Phase aggregates the information from all the conditions
95+
and reports on the lifecycle phase of the resource Enum: {Creating,Created,Deleted}'
96+
type: string
97+
type: object
98+
type: object
99+
served: true
100+
storage: true
101+
subresources:
102+
status: {}
103+
status:
104+
acceptedNames:
105+
kind: ""
106+
plural: ""
107+
conditions: []
108+
storedVersions: []

0 commit comments

Comments
 (0)