Skip to content

Commit

Permalink
Bump controller-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Moss committed Oct 23, 2020
1 parent 25b0576 commit 4f1ed6d
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 100 deletions.
36 changes: 10 additions & 26 deletions test/infrastructure/kubemark/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ else
GOBIN=$(shell go env GOBIN)
endif

ROOT_DIR_RELATIVE := .
include $(ROOT_DIR_RELATIVE)/common.mk

CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen

$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen


all: manager

# Run tests
Expand All @@ -51,7 +60,7 @@ vet:
go vet ./...

# Generate code
generate: controller-gen
generate: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# Build the docker image
Expand All @@ -69,34 +78,9 @@ docker-build-core: ## Build the docker image for controller-manager
docker-push: ## Push the docker image
docker push $(CONTROLLER_IMG)-$(ARCH):$(TAG)

# 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/controller-gen@v0.2.5 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif

## --------------------------------------
## Release
## --------------------------------------
ROOT_DIR_RELATIVE := .

include $(ROOT_DIR_RELATIVE)/common.mk

TOOLS_DIR := hack/tools
TOOLS_DIR_DEPS := $(TOOLS_DIR)/go.sum $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/Makefile
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize

PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH)

Expand Down
13 changes: 13 additions & 0 deletions test/infrastructure/kubemark/api/v1alpha4/kubemarkmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha4

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
)

const (
Expand All @@ -35,6 +36,10 @@ type KubemarkMachineStatus struct {
// Ready is true when the provider resource is ready.
// +optional
Ready bool `json:"ready"`

// Conditions defines current service state of the DockerMachine.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

// +kubebuilder:subresource:status
Expand All @@ -49,6 +54,14 @@ type KubemarkMachine struct {
Status KubemarkMachineStatus `json:"status,omitempty"`
}

func (c *KubemarkMachine) GetConditions() clusterv1.Conditions {
return c.Status.Conditions
}

func (c *KubemarkMachine) SetConditions(conditions clusterv1.Conditions) {
c.Status.Conditions = conditions
}

// +kubebuilder:object:root=true

// KubemarkMachineList contains a list of KubemarkMachine
Expand Down

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

3 changes: 2 additions & 1 deletion test/infrastructure/kubemark/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ SHELL:=bash
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules

BIN_DIR := bin
TOOLS_DIR := $(ROOT_DIR_RELATIVE)/hack/tools
TOOLS_DIR_DEPS := $(TOOLS_DIR)/go.sum $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/Makefile
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
TOOLS_BIN_DIR := $(TOOLS_DIR)/$(BIN_DIR)
UID := $(shell id -u)
GID := $(shell id -g)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: kubemarkmachines.infrastructure.cluster.x-k8s.io
spec:
Expand Down Expand Up @@ -39,6 +39,50 @@ spec:
status:
description: KubemarkMachineStatus defines the observed state of KubemarkMachine
properties:
conditions:
description: Conditions defines current service state of the DockerMachine.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
type: string
required:
- status
- type
type: object
type: array
ready:
description: Ready is true when the provider resource is ready.
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: kubemarkmachinetemplates.infrastructure.cluster.x-k8s.io
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
controller-gen.kubebuilder.io/version: (devel)
creationTimestamp: null
name: kubemarkmachines.infrastructure.cluster.x-k8s.io
spec:
Expand All @@ -15,40 +15,83 @@ spec:
plural: kubemarkmachines
singular: kubemarkmachine
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: KubemarkMachine is the Schema for the kubemarkmachines 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: KubemarkMachineSpec defines the desired state of KubemarkMachine
type: object
status:
description: KubemarkMachineStatus defines the observed state of KubemarkMachine
properties:
ready:
description: Ready is true when the provider resource is ready.
type: boolean
type: object
type: object
version: v1alpha4
versions:
- name: v1alpha4
schema:
openAPIV3Schema:
description: KubemarkMachine is the Schema for the kubemarkmachines 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: KubemarkMachineSpec defines the desired state of KubemarkMachine
type: object
status:
description: KubemarkMachineStatus defines the observed state of KubemarkMachine
properties:
conditions:
description: Conditions defines current service state of the DockerMachine.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
type: string
required:
- status
- type
type: object
type: array
ready:
description: Ready is true when the provider resource is ready.
type: boolean
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
Expand Down
Loading

0 comments on commit 4f1ed6d

Please sign in to comment.