diff --git a/Makefile b/Makefile index eae33e9ce..ed224d59f 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ all: test manager test: generate fmt vet unit .PHONY: unit -unit: manifests unit-test +unit: unit-test .PHONY: unit-test unit-test: @@ -27,17 +27,10 @@ run: generate fmt vet # Install CRDs into a cluster .PHONY: install -install: manifests +install: kubectl apply -f vendor/github.com/openshift/machine-api-operator/install - kubectl apply -f config/crds kustomize build config | kubectl apply -f - -# Generate manifests e.g. CRD, RBAC etc. -.PHONY: manifests -manifests: - go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd paths=./pkg/apis/... output:crd:dir=./config/crds/ - @sed -i '/^ controller-gen.kubebuilder.io\/version: (devel)/d' config/crds/* - # Run go fmt against code .PHONY: fmt fmt: diff --git a/config/crds/baremetal.cluster.k8s.io_baremetalmachineproviderspecs.yaml b/config/crds/baremetal.cluster.k8s.io_baremetalmachineproviderspecs.yaml deleted file mode 100644 index 9061933b2..000000000 --- a/config/crds/baremetal.cluster.k8s.io_baremetalmachineproviderspecs.yaml +++ /dev/null @@ -1,93 +0,0 @@ - ---- -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - annotations: - creationTimestamp: null - name: baremetalmachineproviderspecs.baremetal.cluster.k8s.io -spec: - group: baremetal.cluster.k8s.io - names: - kind: BareMetalMachineProviderSpec - listKind: BareMetalMachineProviderSpecList - plural: baremetalmachineproviderspecs - singular: baremetalmachineproviderspec - scope: Namespaced - validation: - openAPIV3Schema: - description: BareMetalMachineProviderSpec holds data that the actuator needs to provision and manage a Machine. - 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 - hostSelector: - description: HostSelector specifies matching criteria for labels on BareMetalHosts. This is used to limit the set of BareMetalHost objects considered for claiming for a Machine. - properties: - matchExpressions: - description: Label match expressions that must be true on a chosen BareMetalHost - items: - properties: - key: - type: string - operator: - description: Operator represents a key/field's relationship to value(s). See labels.Requirement and fields.Requirement for more details. - type: string - values: - items: - type: string - type: array - required: - - key - - operator - - values - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: Key/value pairs of labels that must exist on a chosen BareMetalHost - type: object - type: object - image: - description: Image is the image to be provisioned. - properties: - checksum: - description: Checksum is a md5sum value or a URL to retrieve one. - type: string - url: - description: URL is a location of an image to deploy. - type: string - required: - - checksum - - url - type: object - 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 - userData: - description: UserData references the Secret that holds user data needed by the bare metal operator. The Namespace is optional; it will default to the Machine's namespace if not specified. - properties: - name: - description: Name is unique within a namespace to reference a secret resource. - type: string - namespace: - description: Namespace defines the space within which the secret name must be unique. - type: string - type: object - required: - - image - type: object - version: v1alpha1 - versions: - - name: v1alpha1 - served: true - storage: true -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/config/crds/baremetal.cluster.k8s.io_baremetalmachineproviderstatuses.yaml b/config/crds/baremetal.cluster.k8s.io_baremetalmachineproviderstatuses.yaml deleted file mode 100644 index 44c993a40..000000000 --- a/config/crds/baremetal.cluster.k8s.io_baremetalmachineproviderstatuses.yaml +++ /dev/null @@ -1,40 +0,0 @@ - ---- -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - annotations: - creationTimestamp: null - name: baremetalmachineproviderstatuses.baremetal.cluster.k8s.io -spec: - group: baremetal.cluster.k8s.io - names: - kind: BareMetalMachineProviderStatus - listKind: BareMetalMachineProviderStatusList - plural: baremetalmachineproviderstatuses - singular: baremetalmachineproviderstatus - scope: Namespaced - validation: - openAPIV3Schema: - description: BareMetalMachineProviderStatus is the Schema for the baremetalmachineproviderstatuses 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 - type: object - version: v1alpha1 - versions: - - name: v1alpha1 - served: true - storage: true -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/hack/generate.sh b/hack/generate.sh index d132ce468..d96d374fa 100755 --- a/hack/generate.sh +++ b/hack/generate.sh @@ -12,8 +12,8 @@ eval "$(go env)" cd "${GOPATH}"/src/github.com/openshift/cluster-api-provider-baremetal export XDG_CACHE_HOME="/tmp/.cache" -INPUT_FILES="config/crds/*.yaml pkg/apis/baremetal/v1alpha1//zz_generated.*.go" +INPUT_FILES="pkg/apis/baremetal/v1alpha1//zz_generated.*.go" cksum $INPUT_FILES > "$ARTIFACTS/lint.cksums.before" -make manifests generate +make generate cksum $INPUT_FILES > "$ARTIFACTS/lint.cksums.after" diff "$ARTIFACTS/lint.cksums.before" "$ARTIFACTS/lint.cksums.after" diff --git a/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderspec_types.go b/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderspec_types.go index c54ce4429..134d43a3e 100644 --- a/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderspec_types.go +++ b/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderspec_types.go @@ -29,7 +29,6 @@ import ( // BareMetalMachineProviderSpec holds data that the actuator needs to provision // and manage a Machine. -// +k8s:openapi-gen=true type BareMetalMachineProviderSpec struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderspec_types_test.go b/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderspec_types_test.go index e67461d82..1219745e9 100644 --- a/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderspec_types_test.go +++ b/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderspec_types_test.go @@ -19,11 +19,7 @@ package v1alpha1 import ( "testing" - "github.com/onsi/gomega" - "golang.org/x/net/context" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" ) func TestProviderSpecIsValid(t *testing.T) { @@ -160,39 +156,3 @@ func TestProviderSpecIsValid(t *testing.T) { } } } - -func TestStorageBareMetalMachineProviderSpec(t *testing.T) { - key := types.NamespacedName{ - Name: "foo", - Namespace: "default", - } - created := &BareMetalMachineProviderSpec{ - ObjectMeta: metav1.ObjectMeta{ - Name: "foo", - Namespace: "default", - }, - UserData: &corev1.SecretReference{ - Name: "foo", - }, - } - g := gomega.NewGomegaWithT(t) - - // Test Create - fetched := &BareMetalMachineProviderSpec{} - g.Expect(c.Create(context.TODO(), created)).NotTo(gomega.HaveOccurred()) - - g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred()) - g.Expect(fetched).To(gomega.Equal(created)) - - // Test Updating the Labels - updated := fetched.DeepCopy() - updated.Labels = map[string]string{"hello": "world"} - g.Expect(c.Update(context.TODO(), updated)).NotTo(gomega.HaveOccurred()) - - g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred()) - g.Expect(fetched).To(gomega.Equal(updated)) - - // Test Delete - g.Expect(c.Delete(context.TODO(), fetched)).NotTo(gomega.HaveOccurred()) - g.Expect(c.Get(context.TODO(), key, fetched)).To(gomega.HaveOccurred()) -} diff --git a/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderstatus_types.go b/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderstatus_types.go index 122ba5f7b..d1e6e2964 100644 --- a/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderstatus_types.go +++ b/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderstatus_types.go @@ -24,7 +24,6 @@ import ( // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // BareMetalMachineProviderStatus is the Schema for the baremetalmachineproviderstatuses API -// +k8s:openapi-gen=true type BareMetalMachineProviderStatus struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderstatus_types_test.go b/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderstatus_types_test.go deleted file mode 100644 index 4d6524f0e..000000000 --- a/pkg/apis/baremetal/v1alpha1/baremetalmachineproviderstatus_types_test.go +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "testing" - - "github.com/onsi/gomega" - "golang.org/x/net/context" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" -) - -func TestStorageBareMetalMachineProviderStatus(t *testing.T) { - key := types.NamespacedName{ - Name: "foo", - Namespace: "default", - } - created := &BareMetalMachineProviderStatus{ - ObjectMeta: metav1.ObjectMeta{ - Name: "foo", - Namespace: "default", - }} - g := gomega.NewGomegaWithT(t) - - // Test Create - fetched := &BareMetalMachineProviderStatus{} - g.Expect(c.Create(context.TODO(), created)).NotTo(gomega.HaveOccurred()) - - g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred()) - g.Expect(fetched).To(gomega.Equal(created)) - - // Test Updating the Labels - updated := fetched.DeepCopy() - updated.Labels = map[string]string{"hello": "world"} - g.Expect(c.Update(context.TODO(), updated)).NotTo(gomega.HaveOccurred()) - - g.Expect(c.Get(context.TODO(), key, fetched)).NotTo(gomega.HaveOccurred()) - g.Expect(fetched).To(gomega.Equal(updated)) - - // Test Delete - g.Expect(c.Delete(context.TODO(), fetched)).NotTo(gomega.HaveOccurred()) - g.Expect(c.Get(context.TODO(), key, fetched)).To(gomega.HaveOccurred()) -}