diff --git a/Makefile b/Makefile index 342aecd5b..1d30fe472 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,13 @@ COMPONENT_CLI_IMAGE_REPOSITORY := $(REGISTRY)/cli SOURCES := $(shell go list -f '{{$$I:=.Dir}}{{range .GoFiles }}{{$$I}}/{{.}} {{end}}' ./... ) GOPATH := $(shell go env GOPATH) +# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) +ifeq (,$(shell go env GOBIN)) +GOBIN=$(shell go env GOPATH)/bin +else +GOBIN=$(shell go env GOBIN) +endif + build: ${SOURCES} mkdir -p bin go build -ldflags "-s -w \ @@ -75,3 +82,42 @@ install: cross-build: @EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) ./hack/cross-build.sh +##@ Build Dependencies + +## Location to install dependencies to +LOCALBIN ?= $(shell pwd)/bin +$(LOCALBIN): + mkdir -p $(LOCALBIN) + +## Tool Binaries +KUSTOMIZE ?= $(LOCALBIN)/kustomize +CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen +ENVTEST ?= $(LOCALBIN)/setup-envtest + +## Tool Versions +KUSTOMIZE_VERSION ?= v3.8.7 +CONTROLLER_TOOLS_VERSION ?= v0.9.0 + +KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" +.PHONY: kustomize +kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. +$(KUSTOMIZE): $(LOCALBIN) + curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN) + +.PHONY: controller-gen +controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. +$(CONTROLLER_GEN): $(LOCALBIN) + GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) + +.PHONY: envtest +envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. +$(ENVTEST): $(LOCALBIN) + GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + +.PHONY: manifests +manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. + $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=config/crd/bases + +.PHONY: generate-deepcopy +generate-deepcopy: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. + $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/..." diff --git a/api/v2/doc.go b/api/v2/doc.go new file mode 100644 index 000000000..3418b23f3 --- /dev/null +++ b/api/v2/doc.go @@ -0,0 +1,17 @@ +// Copyright 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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. + +// +kubebuilder:object:generate=true +// +k8s:deepcopy-gen=package,v2 +package v2 diff --git a/api/v2/groupversion_info.go b/api/v2/groupversion_info.go new file mode 100644 index 000000000..c7c34880a --- /dev/null +++ b/api/v2/groupversion_info.go @@ -0,0 +1,31 @@ +// Copyright 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 contains API Schema definitions for the infrastructure v2 API group +// +kubebuilder:object:generate=true +// +groupName=ocm.open-component-model.software +package v2 + +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: "open-component-model.ocm.software", Version: "v2"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} +) diff --git a/api/v2/ocm_descriptor.go b/api/v2/ocm_descriptor.go new file mode 100644 index 000000000..d69460530 --- /dev/null +++ b/api/v2/ocm_descriptor.go @@ -0,0 +1,47 @@ +// Copyright 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 v2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + compdesc "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/versions/v2" +) + +type ComponentDescriptorStatus struct{} + +// +kubebuilder:object:root=true +// +kubebuilder:storageversion + +type ComponentDescriptor struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec compdesc.ComponentSpec `json:"spec,omitempty"` + Status ComponentDescriptorStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// ComponentDescriptorList contains a list of Component Descriptors. +type ComponentDescriptorList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ComponentDescriptor `json:"items"` +} + +func init() { + SchemeBuilder.Register(&ComponentDescriptor{}, &ComponentDescriptorList{}) +} diff --git a/api/v2/zz_generated.deepcopy.go b/api/v2/zz_generated.deepcopy.go new file mode 100644 index 000000000..f35c7492f --- /dev/null +++ b/api/v2/zz_generated.deepcopy.go @@ -0,0 +1,98 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// Copyright 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 v2 + +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 *ComponentDescriptor) DeepCopyInto(out *ComponentDescriptor) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDescriptor. +func (in *ComponentDescriptor) DeepCopy() *ComponentDescriptor { + if in == nil { + return nil + } + out := new(ComponentDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ComponentDescriptor) 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 *ComponentDescriptorList) DeepCopyInto(out *ComponentDescriptorList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ComponentDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDescriptorList. +func (in *ComponentDescriptorList) DeepCopy() *ComponentDescriptorList { + if in == nil { + return nil + } + out := new(ComponentDescriptorList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ComponentDescriptorList) 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 *ComponentDescriptorStatus) DeepCopyInto(out *ComponentDescriptorStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDescriptorStatus. +func (in *ComponentDescriptorStatus) DeepCopy() *ComponentDescriptorStatus { + if in == nil { + return nil + } + out := new(ComponentDescriptorStatus) + in.DeepCopyInto(out) + return out +} diff --git a/api/v3alpha1/doc.go b/api/v3alpha1/doc.go new file mode 100644 index 000000000..371351c63 --- /dev/null +++ b/api/v3alpha1/doc.go @@ -0,0 +1,17 @@ +// Copyright 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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. + +// +kubebuilder:object:generate=true +// +k8s:deepcopy-gen=package,v3alpha1 +package v3alpha1 diff --git a/api/v3alpha1/groupversion_info.go b/api/v3alpha1/groupversion_info.go new file mode 100644 index 000000000..a1316c91c --- /dev/null +++ b/api/v3alpha1/groupversion_info.go @@ -0,0 +1,31 @@ +// Copyright 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 contains API Schema definitions for the infrastructure v3alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=ocm.open-component-model.software +package v3alpha1 + +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: "open-component-model.ocm.software", Version: "v3alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} +) diff --git a/api/v3alpha1/ocm_descriptor.go b/api/v3alpha1/ocm_descriptor.go new file mode 100644 index 000000000..3785e58a1 --- /dev/null +++ b/api/v3alpha1/ocm_descriptor.go @@ -0,0 +1,46 @@ +// Copyright 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 v3alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/open-component-model/ocm/pkg/contexts/ocm/compdesc/versions/ocm.gardener.cloud/v3alpha1" +) + +type ComponentDescriptorStatus struct{} + +// +kubebuilder:object:root=true + +type ComponentDescriptor struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec v3alpha1.ComponentVersionSpec `json:"spec,omitempty"` + Status ComponentDescriptorStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// ComponentDescriptorList contains a list of Component Descriptors. +type ComponentDescriptorList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ComponentDescriptor `json:"items"` +} + +func init() { + SchemeBuilder.Register(&ComponentDescriptor{}, &ComponentDescriptorList{}) +} diff --git a/api/v3alpha1/zz_generated.deepcopy.go b/api/v3alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..ea573c5ee --- /dev/null +++ b/api/v3alpha1/zz_generated.deepcopy.go @@ -0,0 +1,98 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// Copyright 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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 v3alpha1 + +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 *ComponentDescriptor) DeepCopyInto(out *ComponentDescriptor) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDescriptor. +func (in *ComponentDescriptor) DeepCopy() *ComponentDescriptor { + if in == nil { + return nil + } + out := new(ComponentDescriptor) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ComponentDescriptor) 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 *ComponentDescriptorList) DeepCopyInto(out *ComponentDescriptorList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ComponentDescriptor, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDescriptorList. +func (in *ComponentDescriptorList) DeepCopy() *ComponentDescriptorList { + if in == nil { + return nil + } + out := new(ComponentDescriptorList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ComponentDescriptorList) 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 *ComponentDescriptorStatus) DeepCopyInto(out *ComponentDescriptorStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentDescriptorStatus. +func (in *ComponentDescriptorStatus) DeepCopy() *ComponentDescriptorStatus { + if in == nil { + return nil + } + out := new(ComponentDescriptorStatus) + in.DeepCopyInto(out) + return out +} diff --git a/config/crd/bases/ocm.open-component-model.software_componentdescriptors.yaml b/config/crd/bases/ocm.open-component-model.software_componentdescriptors.yaml new file mode 100644 index 000000000..e9bfc6b36 --- /dev/null +++ b/config/crd/bases/ocm.open-component-model.software_componentdescriptors.yaml @@ -0,0 +1,651 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: componentdescriptors.ocm.open-component-model.software +spec: + group: ocm.open-component-model.software + names: + kind: ComponentDescriptor + listKind: ComponentDescriptorList + plural: componentdescriptors + singular: componentdescriptor + scope: Namespaced + versions: + - name: v2 + schema: + openAPIV3Schema: + 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: ComponentSpec defines a virtual component with a repository + context, source and dependencies. + properties: + componentReferences: + description: ComponentReferences references component dependencies + that can be resolved in the current context. + items: + description: ComponentReference describes the reference to another + component in the registry. + properties: + componentName: + description: ComponentName describes the remote name of the + referenced object + maxLength: 255 + pattern: ^[a-z][-a-z0-9]*([.][a-z][-a-z0-9]*)*[.][a-z]{2,}(/[a-z][-a-z0-9_]*([.][a-z][-a-z0-9_]*)*)+$ + type: string + digest: + description: Digest is the optional digest of the referenced + component. + properties: + hashAlgorithm: + type: string + normalisationAlgorithm: + type: string + value: + type: string + required: + - hashAlgorithm + - normalisationAlgorithm + - value + type: object + extraIdentity: + additionalProperties: + type: string + description: ExtraIdentity is the identity of an object. An + additional label with key "name" ist not allowed + type: object + labels: + description: Labels defines an optional set of additional labels + describing the object. + items: + description: Label is a label that can be set on objects. + properties: + name: + description: Name is the unique name of the label. + type: string + signing: + description: Signing describes whether the label should + be included into the signature + type: boolean + value: + description: Value is the json/yaml data of the label + format: byte + type: string + version: + description: Version is the optional specification version + of the attribute value + pattern: ^v[0-9]+$ + type: string + required: + - name + - value + type: object + type: array + name: + description: Name is the context unique name of the object. + type: string + version: + description: Version is the semver version of the object. + type: string + required: + - componentName + - name + - version + type: object + type: array + labels: + description: Labels defines an optional set of additional labels describing + the object. + items: + description: Label is a label that can be set on objects. + properties: + name: + description: Name is the unique name of the label. + type: string + signing: + description: Signing describes whether the label should be included + into the signature + type: boolean + value: + description: Value is the json/yaml data of the label + format: byte + type: string + version: + description: Version is the optional specification version of + the attribute value + pattern: ^v[0-9]+$ + type: string + required: + - name + - value + type: object + type: array + name: + description: Name is the context unique name of the object. + type: string + provider: + description: Provider defines the provider type of a component. It + can be external or internal. + type: string + repositoryContexts: + description: RepositoryContexts defines the previous repositories + of the component + items: + description: UnstructuredTypedObject describes a generic typed object. + properties: + type: + description: Type describes the type of the object. + type: string + required: + - type + type: object + type: array + resources: + description: Resources defines all resources that are created by the + component and by a third party. + items: + description: Resource describes a resource dependency of a component. + properties: + access: + description: Access describes the type specific method to access + the defined resource. + properties: + type: + description: Type describes the type of the object. + type: string + required: + - type + type: object + digest: + description: Digest is the optional digest of the referenced + resource. + properties: + hashAlgorithm: + type: string + normalisationAlgorithm: + type: string + value: + type: string + required: + - hashAlgorithm + - normalisationAlgorithm + - value + type: object + extraIdentity: + additionalProperties: + type: string + description: ExtraIdentity is the identity of an object. An + additional label with key "name" ist not allowed + type: object + labels: + description: Labels defines an optional set of additional labels + describing the object. + items: + description: Label is a label that can be set on objects. + properties: + name: + description: Name is the unique name of the label. + type: string + signing: + description: Signing describes whether the label should + be included into the signature + type: boolean + value: + description: Value is the json/yaml data of the label + format: byte + type: string + version: + description: Version is the optional specification version + of the attribute value + pattern: ^v[0-9]+$ + type: string + required: + - name + - value + type: object + type: array + name: + description: Name is the context unique name of the object. + type: string + relation: + description: Relation describes the relation of the resource + to the component. Can be a local or external resource + type: string + srcRef: + description: SourceRef defines a list of source names. These + names reference the sources defines in `component.sources`. + items: + description: SourceRef defines a reference to a source + properties: + identitySelector: + additionalProperties: + type: string + description: IdentitySelector defines the identity that + is used to match a source. + type: object + labels: + description: Labels defines an optional set of additional + labels describing the object. + items: + description: Label is a label that can be set on objects. + properties: + name: + description: Name is the unique name of the label. + type: string + signing: + description: Signing describes whether the label + should be included into the signature + type: boolean + value: + description: Value is the json/yaml data of the + label + format: byte + type: string + version: + description: Version is the optional specification + version of the attribute value + pattern: ^v[0-9]+$ + type: string + required: + - name + - value + type: object + type: array + type: object + type: array + type: + description: Type describes the type of the object. + type: string + version: + description: Version is the semver version of the object. + type: string + required: + - access + - name + - type + - version + type: object + type: array + sources: + description: Sources defines sources that produced the component + items: + description: Source is the definition of a component's source. + properties: + access: + description: UnstructuredTypedObject describes a generic typed + object. + properties: + type: + description: Type describes the type of the object. + type: string + required: + - type + type: object + extraIdentity: + additionalProperties: + type: string + description: ExtraIdentity is the identity of an object. An + additional label with key "name" ist not allowed + type: object + labels: + description: Labels defines an optional set of additional labels + describing the object. + items: + description: Label is a label that can be set on objects. + properties: + name: + description: Name is the unique name of the label. + type: string + signing: + description: Signing describes whether the label should + be included into the signature + type: boolean + value: + description: Value is the json/yaml data of the label + format: byte + type: string + version: + description: Version is the optional specification version + of the attribute value + pattern: ^v[0-9]+$ + type: string + required: + - name + - value + type: object + type: array + name: + description: Name is the context unique name of the object. + type: string + type: + description: Type describes the type of the object. + type: string + version: + description: Version is the semver version of the object. + type: string + required: + - access + - name + - type + - version + type: object + type: array + version: + description: Version is the semver version of the object. + type: string + required: + - componentReferences + - name + - provider + - repositoryContexts + - resources + - sources + - version + type: object + status: + type: object + type: object + served: true + storage: true + - name: v3alpha1 + schema: + openAPIV3Schema: + 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: ComponentVersionSpec defines a virtual component with a repository + context, source and dependencies. + properties: + references: + description: References references component version dependencies + that can be resolved in the current context. + items: + description: Reference describes the reference to another component + in the registry. + properties: + componentName: + description: ComponentName describes the remote name of the + referenced object + type: string + digest: + description: Digest is the optional digest of the referenced + component. + properties: + hashAlgorithm: + type: string + normalisationAlgorithm: + type: string + value: + type: string + required: + - hashAlgorithm + - normalisationAlgorithm + - value + type: object + extraIdentity: + additionalProperties: + type: string + description: ExtraIdentity is the identity of an object. An + additional label with key "name" ist not allowed + type: object + labels: + description: Labels defines an optional set of additional labels + describing the object. + items: + description: Label is a label that can be set on objects. + properties: + name: + description: Name is the unique name of the label. + type: string + signing: + description: Signing describes whether the label should + be included into the signature + type: boolean + value: + description: Value is the json/yaml data of the label + format: byte + type: string + version: + description: Version is the optional specification version + of the attribute value + pattern: ^v[0-9]+$ + type: string + required: + - name + - value + type: object + type: array + name: + description: Name is the context unique name of the object. + type: string + version: + description: Version is the semver version of the object. + type: string + required: + - componentName + - name + - version + type: object + type: array + resources: + description: Resources defines all resources that are created by the + component and by a third party. + items: + description: Resource describes a resource dependency of a component. + properties: + access: + description: Access describes the type specific method to access + the defined resource. + properties: + type: + description: Type describes the type of the object. + type: string + required: + - type + type: object + digest: + description: Digest is the optional digest of the referenced + resource. + properties: + hashAlgorithm: + type: string + normalisationAlgorithm: + type: string + value: + type: string + required: + - hashAlgorithm + - normalisationAlgorithm + - value + type: object + extraIdentity: + additionalProperties: + type: string + description: ExtraIdentity is the identity of an object. An + additional label with key "name" ist not allowed + type: object + labels: + description: Labels defines an optional set of additional labels + describing the object. + items: + description: Label is a label that can be set on objects. + properties: + name: + description: Name is the unique name of the label. + type: string + signing: + description: Signing describes whether the label should + be included into the signature + type: boolean + value: + description: Value is the json/yaml data of the label + format: byte + type: string + version: + description: Version is the optional specification version + of the attribute value + pattern: ^v[0-9]+$ + type: string + required: + - name + - value + type: object + type: array + name: + description: Name is the context unique name of the object. + type: string + relation: + description: Relation describes the relation of the resource + to the component. Can be a local or external resource + type: string + srcRef: + description: SourceRef defines a list of source names. These + names reference the sources defines in `component.sources`. + items: + description: SourceRef defines a reference to a source + properties: + identitySelector: + additionalProperties: + type: string + description: IdentitySelector defines the identity that + is used to match a source. + type: object + labels: + description: Labels defines an optional set of additional + labels describing the object. + items: + description: Label is a label that can be set on objects. + properties: + name: + description: Name is the unique name of the label. + type: string + signing: + description: Signing describes whether the label + should be included into the signature + type: boolean + value: + description: Value is the json/yaml data of the + label + format: byte + type: string + version: + description: Version is the optional specification + version of the attribute value + pattern: ^v[0-9]+$ + type: string + required: + - name + - value + type: object + type: array + type: object + type: array + type: + description: Type describes the type of the object. + type: string + version: + description: Version is the semver version of the object. + type: string + required: + - access + - name + - type + - version + type: object + type: array + sources: + description: Sources defines sources that produced the component + items: + description: Source is the definition of a component's source. + properties: + access: + description: UnstructuredTypedObject describes a generic typed + object. + properties: + type: + description: Type describes the type of the object. + type: string + required: + - type + type: object + extraIdentity: + additionalProperties: + type: string + description: ExtraIdentity is the identity of an object. An + additional label with key "name" ist not allowed + type: object + labels: + description: Labels defines an optional set of additional labels + describing the object. + items: + description: Label is a label that can be set on objects. + properties: + name: + description: Name is the unique name of the label. + type: string + signing: + description: Signing describes whether the label should + be included into the signature + type: boolean + value: + description: Value is the json/yaml data of the label + format: byte + type: string + version: + description: Version is the optional specification version + of the attribute value + pattern: ^v[0-9]+$ + type: string + required: + - name + - value + type: object + type: array + name: + description: Name is the context unique name of the object. + type: string + type: + description: Type describes the type of the object. + type: string + version: + description: Version is the semver version of the object. + type: string + required: + - access + - name + - type + - version + type: object + type: array + type: object + status: + type: object + type: object + served: true + storage: false diff --git a/go.mod b/go.mod index 7edc1f26a..4146455d3 100644 --- a/go.mod +++ b/go.mod @@ -57,6 +57,8 @@ require ( golang.org/x/text v0.3.7 gopkg.in/yaml.v3 v3.0.1 helm.sh/helm/v3 v3.9.4 + k8s.io/apiextensions-apiserver v0.24.2 + sigs.k8s.io/controller-runtime v0.12.3 ) require ( @@ -148,7 +150,6 @@ require ( github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/nxadm/tail v1.4.8 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -181,7 +182,6 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/api v0.24.3 // indirect - k8s.io/apiextensions-apiserver v0.24.2 // indirect k8s.io/apiserver v0.24.2 // indirect k8s.io/cli-runtime v0.24.3 // indirect k8s.io/client-go v0.24.3 // indirect diff --git a/go.sum b/go.sum index a8075d703..0ff49c2e2 100644 --- a/go.sum +++ b/go.sum @@ -456,8 +456,8 @@ github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoD github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA= github.com/fvbommel/sortorder v1.0.1 h1:dSnXLt4mJYH25uDDGa3biZNQsozaUWDSWeKJ0qqFfzE= github.com/fvbommel/sortorder v1.0.1/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= @@ -924,7 +924,6 @@ github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= @@ -940,7 +939,7 @@ github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY= github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/gomega v0.0.0-20151007035656-2152b45fa28a/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= @@ -1854,6 +1853,8 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30/go.mod h1:fEO7lRTdivWO2qYVCVG7dEADOMo/MLDCVr8So2g88Uw= +sigs.k8s.io/controller-runtime v0.12.3 h1:FCM8xeY/FI8hoAfh/V4XbbYMY20gElh9yh+A98usMio= +sigs.k8s.io/controller-runtime v0.12.3/go.mod h1:qKsk4WE6zW2Hfj0G4v10EnNB2jMG1C+NTb8h+DwCoU0= sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 h1:kDi4JBNAsJWfz1aEXhO8Jg87JJaPNLh5tIzYHgStQ9Y= sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY= sigs.k8s.io/kustomize/api v0.11.4 h1:/0Mr3kfBBNcNPOW5Qwk/3eb8zkswCwnqQxxKtmrTkRo= diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt new file mode 100644 index 000000000..ac5646d5f --- /dev/null +++ b/hack/boilerplate.go.txt @@ -0,0 +1,13 @@ +// Copyright 2022 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file +// +// 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. diff --git a/pkg/contexts/ocm/compdesc/meta/v1/labels.go b/pkg/contexts/ocm/compdesc/meta/v1/labels.go index c2ed227ef..14b458cef 100644 --- a/pkg/contexts/ocm/compdesc/meta/v1/labels.go +++ b/pkg/contexts/ocm/compdesc/meta/v1/labels.go @@ -35,6 +35,7 @@ type Label struct { Value json.RawMessage `json:"value"` // Version is the optional specification version of the attribute value + // +kubebuilder:validation:Pattern:=`^v[0-9]+$` Version string `json:"version,omitempty"` // Signing describes whether the label should be included into the signature Signing bool `json:"signing,omitempty"` diff --git a/pkg/contexts/ocm/compdesc/versions/ocm.gardener.cloud/v3alpha1/componentdescriptor.go b/pkg/contexts/ocm/compdesc/versions/ocm.gardener.cloud/v3alpha1/componentdescriptor.go index 7b7d5ccd5..ec1e6b3ab 100644 --- a/pkg/contexts/ocm/compdesc/versions/ocm.gardener.cloud/v3alpha1/componentdescriptor.go +++ b/pkg/contexts/ocm/compdesc/versions/ocm.gardener.cloud/v3alpha1/componentdescriptor.go @@ -188,11 +188,11 @@ func (s *Source) GetMeta() *ElementMeta { return &s.ElementMeta } -// SourceMeta is the definition of the meta data of a source. +// SourceMeta is the definition of the metadata of a source. // +k8s:deepcopy-gen=true // +k8s:openapi-gen=true type SourceMeta struct { - ElementMeta + ElementMeta `json:",inline"` // Type describes the type of the object. Type string `json:"type"` } diff --git a/pkg/contexts/ocm/compdesc/versions/v2/componentdescriptor.go b/pkg/contexts/ocm/compdesc/versions/v2/componentdescriptor.go index c9278678c..05340f8c0 100644 --- a/pkg/contexts/ocm/compdesc/versions/v2/componentdescriptor.go +++ b/pkg/contexts/ocm/compdesc/versions/v2/componentdescriptor.go @@ -234,7 +234,7 @@ func (s *Source) GetMeta() *ElementMeta { // +k8s:deepcopy-gen=true // +k8s:openapi-gen=true type SourceMeta struct { - ElementMeta + ElementMeta `json:",inline"` // Type describes the type of the object. Type string `json:"type"` } @@ -328,6 +328,8 @@ func (r ComponentReferences) Get(i int) ElementMetaAccessor { type ComponentReference struct { ElementMeta `json:",inline"` // ComponentName describes the remote name of the referenced object + // +kubebuilder:validation:MaxLength=255 + // +kubebuilder:validation:Pattern:=`^[a-z][-a-z0-9]*([.][a-z][-a-z0-9]*)*[.][a-z]{2,}(/[a-z][-a-z0-9_]*([.][a-z][-a-z0-9_]*)*)+$` ComponentName string `json:"componentName"` // Digest is the optional digest of the referenced component. // +optional diff --git a/pkg/contexts/ocm/repositories/genericocireg/type.go b/pkg/contexts/ocm/repositories/genericocireg/type.go index c8a927306..65013b961 100644 --- a/pkg/contexts/ocm/repositories/genericocireg/type.go +++ b/pkg/contexts/ocm/repositories/genericocireg/type.go @@ -29,6 +29,7 @@ import ( // ComponentNameMapping describes the method that is used to map the "Component Name", "Component Version"-tuples // to OCI Image References. +// +kubebuilder:validation:Enum:=urlPath;sha256-digest type ComponentNameMapping string const (