Skip to content
Permalink
Browse files

clusterctlv2-api

  • Loading branch information
fabriziopandini committed Dec 2, 2019
1 parent b60e453 commit acf758ac642b3fa8ebb3cb625eab0d50b8a1c68b
@@ -22,5 +22,6 @@ run:
deadline: 4m
skip-files:
- "zz_generated.*\\.go$"
- crd_manifests.go
skip-dirs:
- third_party
@@ -46,6 +46,7 @@ RELEASE_NOTES := $(TOOLS_DIR)/$(RELEASE_NOTES_BIN)
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
CONVERSION_GEN := $(TOOLS_BIN_DIR)/conversion-gen
GOBINDATA_GEN := $(TOOLS_BIN_DIR)/go-bindata

# Define Docker related variables. Releases should modify and double check these vars.
REGISTRY ?= gcr.io/$(shell gcloud config get-value project)
@@ -103,6 +104,9 @@ $(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod # Build golangci-lint from tools folder.
$(CONVERSION_GEN): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-gen k8s.io/code-generator/cmd/conversion-gen

$(GOBINDATA_GEN): $(TOOLS_DIR)/go.mod # Build go-bindata from tools folder.
cd $(TOOLS_DIR); go install -tags=tools github.com/jteeuwen/go-bindata/go-bindata

$(RELEASE_NOTES) : $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && go build -o $(RELEASE_NOTES_BIN) -tags tools ./release

@@ -129,6 +133,7 @@ lint-full: $(GOLANGCI_LINT) ## Run slower linters to detect possible issues
generate: $(CONTROLLER_GEN) ## Generate code
$(MAKE) generate-manifests
$(MAKE) generate-go
$(MAKE) generate-bindata

.PHONY: generate-go
generate-go: $(CONTROLLER_GEN) $(CONVERSION_GEN) ## Runs Go related generate targets
@@ -140,6 +145,20 @@ generate-go: $(CONTROLLER_GEN) $(CONVERSION_GEN) ## Runs Go related generate tar
--input-dirs=./api/v1alpha2 \
--output-file-base=zz_generated.conversion \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
$(CONTROLLER_GEN) \
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
paths=./cmd/clusterctl/api/...

.PHONY: generate-bindata
generate-bindata: $(GOBINDATA_GEN) ## generate code for embedding the clusterctl api manifest
# package manifest YAML into a single file
mkdir -p ./cmd/clusterctl/config/manifest/
kubectl kustomize ./cmd/clusterctl/config/crd > ./cmd/clusterctl/config/manifest/clusterctl-api.yaml
# generate go-bindata, add boilerplate, then cleanup
go generate ./cmd/clusterctl/config/generate.go
cat ./hack/boilerplate/boilerplate.generatego.txt ./cmd/clusterctl/config/crd_manifests.go > ./cmd/clusterctl/config/manifest/crd_manifests.go
cp ./cmd/clusterctl/config/manifest/crd_manifests.go ./cmd/clusterctl/config/crd_manifests.go
rm -r ./cmd/clusterctl/config/manifest/

.PHONY: generate-manifests
generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
@@ -155,6 +174,10 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
paths=./bootstrap/kubeadm/api/... \
crd:trivialVersions=true \
output:crd:dir=./config/crd/bases
$(CONTROLLER_GEN) \
paths=./cmd/clusterctl/api/... \
crd:trivialVersions=true \
output:crd:dir=./cmd/clusterctl/config/crd/bases
## Copy files in CI folders.
cp -f ./config/rbac/*.yaml ./config/ci/rbac/
cp -f ./config/manager/manager*.yaml ./config/ci/manager/
@@ -0,0 +1,36 @@
/*
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 v1alpha3 contains API Schema definitions for the clusterctl v1alpha3 API group
// +kubebuilder:object:generate=true
// +groupName=clusterctl.cluster.x-k8s.io
package v1alpha3

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "clusterctl.cluster.x-k8s.io", Version: "v1alpha3"}

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

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
@@ -0,0 +1,22 @@
/*
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 v1alpha3

const (
ClusterctlLabelName = "clusterctl.cluster.x-k8s.io"
ClusterctlProviderLabelName = "clusterctl.cluster.x-k8s.io/provider"
)
@@ -0,0 +1,92 @@
/*
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 v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:resource:path=providers,scope=Namespaced,categories=cluster-api
// +kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".type"
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".version"
// +kubebuilder:printcolumn:name="Watch Namespace",type="string",JSONPath=".watchedNamespace"

// Provider is the Schema for the providers API
type Provider struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Type indicates the type of the provider.
// See ProviderType for a list of supported values
// +optional
Type string `json:"type,omitempty"`

// Version indicates the component version.
// +optional
Version string `json:"version,omitempty"`

// WatchedNamespace indicates the namespace where the provider controller is is watching.
// if empty the provider controller is watching for objects in all namespaces.
// +optional
WatchedNamespace string `json:"watchedNamespace,omitempty"`
}

// +kubebuilder:object:root=true

// ProviderList contains a list of Provider
type ProviderList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Provider `json:"items"`
}

func init() {
SchemeBuilder.Register(&Provider{}, &ProviderList{})
}

// ProviderType is a string representation of a TaskGroup create policy.
type ProviderType string

const (
// CoreProviderType
CoreProviderType = ProviderType("CoreProvider")

// BootstrapProviderType
BootstrapProviderType = ProviderType("BootstrapProvider")

// InfrastructureProviderType
InfrastructureProviderType = ProviderType("InfrastructureProvider")

// ProviderTypeUnknown
ProviderTypeUnknown = ProviderType("")
)

// GetTypedProviderType attempts to parse the ProviderType field and return
// the typed ProviderType representation.
func (in *Provider) GetTypedProviderType() ProviderType {
switch t := ProviderType(in.Type); t {
case
CoreProviderType,
BootstrapProviderType,
InfrastructureProviderType:
return t
default:
return ProviderTypeUnknown
}
}
@@ -0,0 +1,82 @@
// +build !ignore_autogenerated

/*
Copyright 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.
*/

// Code generated by controller-gen. DO NOT EDIT.

package v1alpha3

import (
runtime "k8s.io/apimachinery/pkg/runtime"
)

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Provider) DeepCopyInto(out *Provider) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Provider.
func (in *Provider) DeepCopy() *Provider {
if in == nil {
return nil
}
out := new(Provider)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Provider) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ProviderList) DeepCopyInto(out *ProviderList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Provider, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderList.
func (in *ProviderList) DeepCopy() *ProviderList {
if in == nil {
return nil
}
out := new(ProviderList)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ProviderList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
@@ -0,0 +1,71 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.3
creationTimestamp: null
name: providers.clusterctl.cluster.x-k8s.io
spec:
additionalPrinterColumns:
- JSONPath: .type
name: Type
type: string
- JSONPath: .version
name: Version
type: string
- JSONPath: .watchedNamespace
name: Watch Namespace
type: string
group: clusterctl.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: Provider
listKind: ProviderList
plural: providers
singular: provider
preserveUnknownFields: false
scope: Namespaced
subresources: {}
validation:
openAPIV3Schema:
description: Provider is the Schema for the providers 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/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/api-conventions.md#types-kinds'
type: string
metadata:
type: object
type:
description: Type indicates the type of the provider. See ProviderType for
a list of supported values
type: string
version:
description: Version indicates the component version.
type: string
watchedNamespace:
description: WatchedNamespace indicates the namespace where the provider
controller is is watching. if empty the provider controller is watching
for objects in all namespaces.
type: string
type: object
version: v1alpha3
versions:
- name: v1alpha3
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- bases/clusterctl.cluster.x-k8s.io_providers.yaml

0 comments on commit acf758a

Please sign in to comment.
You can’t perform that action at this time.