From d4c2ad8a5eca2565b5779ae0fae7a979cd6a842d Mon Sep 17 00:00:00 2001 From: Lee Bernick Date: Wed, 29 Jun 2022 14:41:59 -0400 Subject: [PATCH] Add empty v1 package This commit adds an empty package for v1 and updates the hack directory to generate code and OpenAPI spec for v1. --- go.mod | 2 +- go.sum | 2 +- hack/spec-gen/main.go | 28 +- hack/update-codegen.sh | 8 +- hack/update-openapigen.sh | 47 +-- pkg/apis/pipeline/v1/doc.go | 23 ++ pkg/apis/pipeline/v1/openapi_generated.go | 281 ++++++++++++++++++ pkg/apis/pipeline/v1/register.go | 52 ++++ pkg/apis/pipeline/v1/swagger.json | 135 +++++++++ pkg/apis/pipeline/v1/zz_generated.deepcopy.go | 22 ++ pkg/client/clientset/versioned/clientset.go | 13 + .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../versioned/typed/pipeline/v1/doc.go | 20 ++ .../versioned/typed/pipeline/v1/fake/doc.go | 20 ++ .../pipeline/v1/fake/fake_pipeline_client.go | 35 +++ .../typed/pipeline/v1/generated_expansion.go | 19 ++ .../typed/pipeline/v1/pipeline_client.go | 102 +++++++ 19 files changed, 786 insertions(+), 34 deletions(-) create mode 100644 pkg/apis/pipeline/v1/doc.go create mode 100644 pkg/apis/pipeline/v1/openapi_generated.go create mode 100644 pkg/apis/pipeline/v1/register.go create mode 100644 pkg/apis/pipeline/v1/swagger.json create mode 100644 pkg/apis/pipeline/v1/zz_generated.deepcopy.go create mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1/fake/fake_pipeline_client.go create mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/pipeline/v1/pipeline_client.go diff --git a/go.mod b/go.mod index 022946cb1dc..6c1c75664dd 100644 --- a/go.mod +++ b/go.mod @@ -146,4 +146,4 @@ require ( k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect -) +) \ No newline at end of file diff --git a/go.sum b/go.sum index 63370794120..926432d3c6e 100644 --- a/go.sum +++ b/go.sum @@ -2232,4 +2232,4 @@ sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZa sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= \ No newline at end of file diff --git a/hack/spec-gen/main.go b/hack/spec-gen/main.go index 1d8c2615068..e3457ac797f 100644 --- a/hack/spec-gen/main.go +++ b/hack/spec-gen/main.go @@ -18,11 +18,12 @@ package main import ( "encoding/json" + "flag" "fmt" - "os" "strings" - tekton "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" + tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "k8s.io/klog" "k8s.io/kube-openapi/pkg/common" @@ -30,16 +31,25 @@ import ( ) func main() { - if len(os.Args) <= 1 { - klog.Fatal("Supply a version") - } - version := os.Args[1] + pipelinesVersion := flag.String("version", "v0.17.2", "Tekton Pipelines software version") + apiVersion := flag.String("apiVersion", "v1beta1", "API version") + flag.Parse() + version := *pipelinesVersion if !strings.HasPrefix(version, "v") { version = "v" + version } - oAPIDefs := tekton.GetOpenAPIDefinitions(func(name string) spec.Ref { - return spec.MustCreateRef("#/definitions/" + common.EscapeJsonPointer(swaggify(name))) - }) + var oAPIDefs map[string]common.OpenAPIDefinition + if *apiVersion == "v1beta1" { + oAPIDefs = tektonv1beta1.GetOpenAPIDefinitions(func(name string) spec.Ref { + return spec.MustCreateRef("#/definitions/" + common.EscapeJsonPointer(swaggify(name))) + }) + } else if *apiVersion == "v1" { + oAPIDefs = tektonv1.GetOpenAPIDefinitions(func(name string) spec.Ref { + return spec.MustCreateRef("#/definitions/" + common.EscapeJsonPointer(swaggify(name))) + }) + } else { + panic(fmt.Sprintf("Unsupported API version: %s", *apiVersion)) + } defs := spec.Definitions{} for defName, val := range oAPIDefs { defs[swaggify(defName)] = val.Schema diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index ce40324fc08..e1da22a8537 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -40,10 +40,10 @@ bash ${REPO_ROOT_DIR}/hack/generate-groups.sh "deepcopy,client,informer,lister" github.com/tektoncd/pipeline/pkg/client/resource github.com/tektoncd/pipeline/pkg/apis \ "resource:v1alpha1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt -# This generates deepcopy,client,informer and lister for the pipeline package (v1alpha1 and v1beta1) +# This generates deepcopy,client,informer and lister for the pipeline package (v1alpha1, v1beta1, and v1) bash ${REPO_ROOT_DIR}/hack/generate-groups.sh "deepcopy,client,informer,lister" \ github.com/tektoncd/pipeline/pkg/client github.com/tektoncd/pipeline/pkg/apis \ - "pipeline:v1alpha1,v1beta1" \ + "pipeline:v1alpha1,v1beta1,v1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # Depends on generate-groups.sh to install bin/deepcopy-gen @@ -74,10 +74,10 @@ bash ${REPO_ROOT_DIR}/hack/generate-knative.sh "injection" \ github.com/tektoncd/pipeline/pkg/client/resource github.com/tektoncd/pipeline/pkg/apis \ "resource:v1alpha1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt -# This generates the knative inject packages for the pipeline package (v1alpha1, v1beta1). +# This generates the knative inject packages for the pipeline package (v1alpha1, v1beta1, v1). bash ${REPO_ROOT_DIR}/hack/generate-knative.sh "injection" \ github.com/tektoncd/pipeline/pkg/client github.com/tektoncd/pipeline/pkg/apis \ - "pipeline:v1alpha1,v1beta1" \ + "pipeline:v1alpha1,v1beta1,v1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt GOFLAGS="${OLDGOFLAGS}" diff --git a/hack/update-openapigen.sh b/hack/update-openapigen.sh index 6a32ead28e7..c96db0501e7 100755 --- a/hack/update-openapigen.sh +++ b/hack/update-openapigen.sh @@ -34,22 +34,31 @@ mkdir -p "${TMP_DIFFROOT}" trap cleanup EXIT -echo "Generating OpenAPI specification ..." -go run k8s.io/kube-openapi/cmd/openapi-gen \ - --input-dirs ./pkg/apis/pipeline/v1beta1,./pkg/apis/pipeline/pod,./pkg/apis/resource/v1alpha1,knative.dev/pkg/apis,knative.dev/pkg/apis/duck/v1beta1 \ - --output-package ./pkg/apis/pipeline/v1beta1 -o ./ \ - --go-header-file hack/boilerplate/boilerplate.go.txt \ - -r "${TMP_DIFFROOT}/api-report" - -violations=$(diff --changed-group-format='%>' --unchanged-group-format='' <(sort "hack/ignored-openapi-violations.list") <(sort "${TMP_DIFFROOT}/api-report") || echo "") -if [ -n "${violations}" ]; then - echo "" - echo "New API rule violations found which are not present in hack/ignored-openapi-violations.list. Please fix these violations:" - echo "" - echo "${violations}" - echo "" - exit 1 -fi - -echo "Generating swagger file ..." -go run hack/spec-gen/main.go v0.17.2 > pkg/apis/pipeline/v1beta1/swagger.json +for APIVERSION in "v1beta1" "v1" +do + input_dirs=./pkg/apis/pipeline/${APIVERSION},./pkg/apis/pipeline/pod,knative.dev/pkg/apis,knative.dev/pkg/apis/duck/v1beta1 + if [ ${APIVERSION} = "v1beta1" ] + then + input_dirs=${input_dirs},./pkg/apis/resource/v1alpha1 + fi + + echo "Generating OpenAPI specification for ${APIVERSION} ..." + go run k8s.io/kube-openapi/cmd/openapi-gen \ + --input-dirs ${input_dirs} \ + --output-package ./pkg/apis/pipeline/${APIVERSION} -o ./ \ + --go-header-file hack/boilerplate/boilerplate.go.txt \ + -r "${TMP_DIFFROOT}/api-report" + + violations=$(diff --changed-group-format='%>' --unchanged-group-format='' <(sort "hack/ignored-openapi-violations.list") <(sort "${TMP_DIFFROOT}/api-report") || echo "") + if [ -n "${violations}" ]; then + echo "" + echo "New API rule violations found which are not present in hack/ignored-openapi-violations.list. Please fix these violations:" + echo "" + echo "${violations}" + echo "" + exit 1 + fi + + echo "Generating swagger file for ${APIVERSION} ..." + go run hack/spec-gen/main.go -apiVersion=${APIVERSION} > pkg/apis/pipeline/${APIVERSION}/swagger.json +done \ No newline at end of file diff --git a/pkg/apis/pipeline/v1/doc.go b/pkg/apis/pipeline/v1/doc.go new file mode 100644 index 00000000000..d279002e615 --- /dev/null +++ b/pkg/apis/pipeline/v1/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2022 The Tekton 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 v1 contains API Schema definitions for the pipeline v1 API group +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:conversion-gen=github.com/tektoncd/pipeline/pkg/apis/pipeline +// +k8s:defaulter-gen=TypeMeta +// +groupName=tekton.dev +package v1 diff --git a/pkg/apis/pipeline/v1/openapi_generated.go b/pkg/apis/pipeline/v1/openapi_generated.go new file mode 100644 index 00000000000..72e1d403b26 --- /dev/null +++ b/pkg/apis/pipeline/v1/openapi_generated.go @@ -0,0 +1,281 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2020 The Tekton 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 openapi-gen. DO NOT EDIT. + +// This file was autogenerated by openapi-gen. Do not edit it manually! + +package v1 + +import ( + common "k8s.io/kube-openapi/pkg/common" + spec "k8s.io/kube-openapi/pkg/validation/spec" +) + +func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { + return map[string]common.OpenAPIDefinition{ + "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.AffinityAssistantTemplate": schema_pkg_apis_pipeline_pod_AffinityAssistantTemplate(ref), + "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod.Template": schema_pkg_apis_pipeline_pod_Template(ref), + } +} + +func schema_pkg_apis_pipeline_pod_AffinityAssistantTemplate(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AffinityAssistantTemplate holds pod specific configuration and is a subset of the generic pod Template", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "nodeSelector": { + SchemaProps: spec.SchemaProps{ + Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "tolerations": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "If specified, the pod's tolerations.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Toleration"), + }, + }, + }, + }, + }, + "imagePullSecrets": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "ImagePullSecrets gives the name of the secret used by the pod to pull the image if specified", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.Toleration"}, + } +} + +func schema_pkg_apis_pipeline_pod_Template(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Template holds pod specific configuration", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "nodeSelector": { + SchemaProps: spec.SchemaProps{ + Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "tolerations": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "If specified, the pod's tolerations.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Toleration"), + }, + }, + }, + }, + }, + "affinity": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the pod's scheduling constraints", + Ref: ref("k8s.io/api/core/v1.Affinity"), + }, + }, + "securityContext": { + SchemaProps: spec.SchemaProps{ + Description: "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field.", + Ref: ref("k8s.io/api/core/v1.PodSecurityContext"), + }, + }, + "volumes": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Volume"), + }, + }, + }, + }, + }, + "runtimeClassName": { + SchemaProps: spec.SchemaProps{ + Description: "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md This is a beta feature as of Kubernetes v1.14.", + Type: []string{"string"}, + Format: "", + }, + }, + "automountServiceAccountToken": { + SchemaProps: spec.SchemaProps{ + Description: "AutomountServiceAccountToken indicates whether pods running as this service account should have an API token automatically mounted.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "dnsPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Set DNS policy for the pod. Defaults to \"ClusterFirst\". Valid values are 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy.", + Type: []string{"string"}, + Format: "", + }, + }, + "dnsConfig": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy.", + Ref: ref("k8s.io/api/core/v1.PodDNSConfig"), + }, + }, + "enableServiceLinks": { + SchemaProps: spec.SchemaProps{ + Description: "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links. Optional: Defaults to true.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "priorityClassName": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, indicates the pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default.", + Type: []string{"string"}, + Format: "", + }, + }, + "schedulerName": { + SchemaProps: spec.SchemaProps{ + Description: "SchedulerName specifies the scheduler to be used to dispatch the Pod", + Type: []string{"string"}, + Format: "", + }, + }, + "imagePullSecrets": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "ImagePullSecrets gives the name of the secret used by the pod to pull the image if specified", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + }, + }, + "hostAliases": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.HostAlias"), + }, + }, + }, + }, + }, + "hostNetwork": { + SchemaProps: spec.SchemaProps{ + Description: "HostNetwork specifies whether the pod may use the node network namespace", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.Affinity", "k8s.io/api/core/v1.HostAlias", "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PodDNSConfig", "k8s.io/api/core/v1.PodSecurityContext", "k8s.io/api/core/v1.Toleration", "k8s.io/api/core/v1.Volume"}, + } +} diff --git a/pkg/apis/pipeline/v1/register.go b/pkg/apis/pipeline/v1/register.go new file mode 100644 index 00000000000..841f2a452e0 --- /dev/null +++ b/pkg/apis/pipeline/v1/register.go @@ -0,0 +1,52 @@ +/* +Copyright 2022 The Tekton 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 v1 + +import ( + "github.com/tektoncd/pipeline/pkg/apis/pipeline" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: pipeline.GroupName, Version: "v1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme adds Build types to the scheme. + AddToScheme = schemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion) // TODO(#4983): v1 types go here + + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/pipeline/v1/swagger.json b/pkg/apis/pipeline/v1/swagger.json new file mode 100644 index 00000000000..721c311745a --- /dev/null +++ b/pkg/apis/pipeline/v1/swagger.json @@ -0,0 +1,135 @@ +{ + "swagger": "2.0", + "info": { + "description": "Tekton Pipeline", + "title": "Tekton", + "version": "v0.17.2" + }, + "paths": {}, + "definitions": { + "pod.AffinityAssistantTemplate": { + "description": "AffinityAssistantTemplate holds pod specific configuration and is a subset of the generic pod Template", + "type": "object", + "properties": { + "imagePullSecrets": { + "description": "ImagePullSecrets gives the name of the secret used by the pod to pull the image if specified", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.LocalObjectReference" + }, + "x-kubernetes-list-type": "atomic" + }, + "nodeSelector": { + "description": "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + }, + "tolerations": { + "description": "If specified, the pod's tolerations.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.Toleration" + }, + "x-kubernetes-list-type": "atomic" + } + } + }, + "pod.Template": { + "description": "Template holds pod specific configuration", + "type": "object", + "properties": { + "affinity": { + "description": "If specified, the pod's scheduling constraints", + "$ref": "#/definitions/v1.Affinity" + }, + "automountServiceAccountToken": { + "description": "AutomountServiceAccountToken indicates whether pods running as this service account should have an API token automatically mounted.", + "type": "boolean" + }, + "dnsConfig": { + "description": "Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy.", + "$ref": "#/definitions/v1.PodDNSConfig" + }, + "dnsPolicy": { + "description": "Set DNS policy for the pod. Defaults to \"ClusterFirst\". Valid values are 'ClusterFirst', 'Default' or 'None'. DNS parameters given in DNSConfig will be merged with the policy selected with DNSPolicy.", + "type": "string" + }, + "enableServiceLinks": { + "description": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links. Optional: Defaults to true.", + "type": "boolean" + }, + "hostAliases": { + "description": "HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts file if specified. This is only valid for non-hostNetwork pods.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.HostAlias" + }, + "x-kubernetes-list-type": "atomic" + }, + "hostNetwork": { + "description": "HostNetwork specifies whether the pod may use the node network namespace", + "type": "boolean" + }, + "imagePullSecrets": { + "description": "ImagePullSecrets gives the name of the secret used by the pod to pull the image if specified", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.LocalObjectReference" + }, + "x-kubernetes-list-type": "atomic" + }, + "nodeSelector": { + "description": "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + }, + "priorityClassName": { + "description": "If specified, indicates the pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default.", + "type": "string" + }, + "runtimeClassName": { + "description": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md This is a beta feature as of Kubernetes v1.14.", + "type": "string" + }, + "schedulerName": { + "description": "SchedulerName specifies the scheduler to be used to dispatch the Pod", + "type": "string" + }, + "securityContext": { + "description": "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See type description for default values of each field.", + "$ref": "#/definitions/v1.PodSecurityContext" + }, + "tolerations": { + "description": "If specified, the pod's tolerations.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.Toleration" + }, + "x-kubernetes-list-type": "atomic" + }, + "volumes": { + "description": "List of volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.Volume" + }, + "x-kubernetes-list-type": "atomic", + "x-kubernetes-patch-merge-key": "name", + "x-kubernetes-patch-strategy": "merge,retainKeys" + } + } + } + } +} diff --git a/pkg/apis/pipeline/v1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..c7bc4c6077c --- /dev/null +++ b/pkg/apis/pipeline/v1/zz_generated.deepcopy.go @@ -0,0 +1,22 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2020 The Tekton 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 deepcopy-gen. DO NOT EDIT. + +package v1 diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 0681ce1abdc..0763f48419c 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -22,6 +22,7 @@ import ( "fmt" "net/http" + tektonv1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1" tektonv1alpha1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1alpha1" tektonv1beta1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1" discovery "k8s.io/client-go/discovery" @@ -33,6 +34,7 @@ type Interface interface { Discovery() discovery.DiscoveryInterface TektonV1alpha1() tektonv1alpha1.TektonV1alpha1Interface TektonV1beta1() tektonv1beta1.TektonV1beta1Interface + TektonV1() tektonv1.TektonV1Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -41,6 +43,7 @@ type Clientset struct { *discovery.DiscoveryClient tektonV1alpha1 *tektonv1alpha1.TektonV1alpha1Client tektonV1beta1 *tektonv1beta1.TektonV1beta1Client + tektonV1 *tektonv1.TektonV1Client } // TektonV1alpha1 retrieves the TektonV1alpha1Client @@ -53,6 +56,11 @@ func (c *Clientset) TektonV1beta1() tektonv1beta1.TektonV1beta1Interface { return c.tektonV1beta1 } +// TektonV1 retrieves the TektonV1Client +func (c *Clientset) TektonV1() tektonv1.TektonV1Interface { + return c.tektonV1 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -101,6 +109,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.tektonV1, err = tektonv1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { @@ -124,6 +136,7 @@ func New(c rest.Interface) *Clientset { var cs Clientset cs.tektonV1alpha1 = tektonv1alpha1.New(c) cs.tektonV1beta1 = tektonv1beta1.New(c) + cs.tektonV1 = tektonv1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 473078696a5..98218788986 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -20,6 +20,8 @@ package fake import ( clientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" + tektonv1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1" + faketektonv1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1/fake" tektonv1alpha1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1alpha1" faketektonv1alpha1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1alpha1/fake" tektonv1beta1 "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1" @@ -90,3 +92,8 @@ func (c *Clientset) TektonV1alpha1() tektonv1alpha1.TektonV1alpha1Interface { func (c *Clientset) TektonV1beta1() tektonv1beta1.TektonV1beta1Interface { return &faketektonv1beta1.FakeTektonV1beta1{Fake: &c.Fake} } + +// TektonV1 retrieves the TektonV1Client +func (c *Clientset) TektonV1() tektonv1.TektonV1Interface { + return &faketektonv1.FakeTektonV1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 644e02d5960..951cec59e8f 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -19,6 +19,7 @@ limitations under the License. package fake import ( + tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" tektonv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -34,6 +35,7 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ tektonv1alpha1.AddToScheme, tektonv1beta1.AddToScheme, + tektonv1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 757e6eb815a..21c3e532dfd 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -19,6 +19,7 @@ limitations under the License. package scheme import ( + tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" tektonv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -34,6 +35,7 @@ var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ tektonv1alpha1.AddToScheme, tektonv1beta1.AddToScheme, + tektonv1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1/doc.go b/pkg/client/clientset/versioned/typed/pipeline/v1/doc.go new file mode 100644 index 00000000000..6f9b4198cf9 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/pipeline/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Tekton 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 client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1/fake/doc.go b/pkg/client/clientset/versioned/typed/pipeline/v1/fake/doc.go new file mode 100644 index 00000000000..1a72e0befe2 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/pipeline/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Tekton 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 client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1/fake/fake_pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1/fake/fake_pipeline_client.go new file mode 100644 index 00000000000..28c423bf089 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/pipeline/v1/fake/fake_pipeline_client.go @@ -0,0 +1,35 @@ +/* +Copyright 2020 The Tekton 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 client-gen. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeTektonV1 struct { + *testing.Fake +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeTektonV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1/generated_expansion.go b/pkg/client/clientset/versioned/typed/pipeline/v1/generated_expansion.go new file mode 100644 index 00000000000..1d3c2bd18b5 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/pipeline/v1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2020 The Tekton 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 client-gen. DO NOT EDIT. + +package v1 diff --git a/pkg/client/clientset/versioned/typed/pipeline/v1/pipeline_client.go b/pkg/client/clientset/versioned/typed/pipeline/v1/pipeline_client.go new file mode 100644 index 00000000000..53c0a77712a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/pipeline/v1/pipeline_client.go @@ -0,0 +1,102 @@ +/* +Copyright 2020 The Tekton 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 client-gen. DO NOT EDIT. + +package v1 + +import ( + "net/http" + + v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" + "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type TektonV1Interface interface { + RESTClient() rest.Interface +} + +// TektonV1Client is used to interact with features provided by the tekton.dev group. +type TektonV1Client struct { + restClient rest.Interface +} + +// NewForConfig creates a new TektonV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*TektonV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new TektonV1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*TektonV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &TektonV1Client{client}, nil +} + +// NewForConfigOrDie creates a new TektonV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *TektonV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new TektonV1Client for the given RESTClient. +func New(c rest.Interface) *TektonV1Client { + return &TektonV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *TektonV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +}