Skip to content

Commit

Permalink
Add empty v1 package
Browse files Browse the repository at this point in the history
This commit adds an empty package for v1 and updates the hack directory to generate
code and OpenAPI spec for v1.
  • Loading branch information
lbernick committed Jun 30, 2022
1 parent 8a3a8e5 commit 2e1710e
Show file tree
Hide file tree
Showing 475 changed files with 34,692 additions and 9,658 deletions.
18 changes: 11 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ require (
go.uber.org/zap v1.19.1
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
gomodules.xyz/jsonpatch/v2 v2.2.0
k8s.io/api v0.23.5
k8s.io/apimachinery v0.23.5
k8s.io/client-go v0.23.5
k8s.io/api v0.24.2
k8s.io/apimachinery v0.24.2
k8s.io/client-go v0.24.2
k8s.io/code-generator v0.23.5
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42
knative.dev/pkg v0.0.0-20220329144915-0a1ec2e0d46c
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
)

require (
cloud.google.com/go/compute v1.5.0 // indirect
contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect
Expand Down Expand Up @@ -59,7 +64,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.10.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.15.0 // indirect
github.com/aws/smithy-go v1.11.0 // indirect
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220228164355-396b2034c795 // indirect
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220517224237-e6f29200ae04 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
Expand Down Expand Up @@ -89,7 +94,6 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20220301182634-bfe2ffc6b6bd // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
Expand Down Expand Up @@ -142,7 +146,7 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.23.4 // indirect
k8s.io/gengo v0.0.0-20220307231824-4627b89bbf1b // indirect
k8s.io/klog/v2 v2.60.1-0.20220317184644-43cc75f9ae89 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
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
Expand Down
23 changes: 16 additions & 7 deletions go.sum

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

24 changes: 19 additions & 5 deletions hack/spec-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ 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"
Expand All @@ -33,13 +35,25 @@ 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
Expand Down
8 changes: 4 additions & 4 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"

Expand Down
47 changes: 28 additions & 19 deletions hack/update-openapigen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -version="v0.17.2" -apiVersion=${APIVERSION} > pkg/apis/pipeline/${APIVERSION}/swagger.json
done
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2018 The Kubernetes Authors.
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.
Expand All @@ -14,11 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package
// +k8s:conversion-gen=k8s.io/client-go/pkg/apis/clientauthentication
// 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=client.authentication.k8s.io

package v1alpha1 // import "k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1"
// +groupName=tekton.dev
package v1
Loading

0 comments on commit 2e1710e

Please sign in to comment.