diff --git a/Makefile b/Makefile index 39d1cea737..01442c52b3 100644 --- a/Makefile +++ b/Makefile @@ -101,7 +101,7 @@ release: .PHONY: generate generate: - hack/generate-client.sh + hack/update-codegen.sh hack/generate-fakes.sh hack/generate-copyright.sh diff --git a/hack/README.md b/hack/README.md new file mode 100644 index 0000000000..2f6b96a1c3 --- /dev/null +++ b/hack/README.md @@ -0,0 +1,16 @@ +# Assorted scripts for development + +This directory contains several scripts useful in the development process of Shipwright Build. + +- `build-logs.sh` Collect the log of specific BuildRun Pod in the cluster. +- `generate-copyright.sh` Generate the Shipwright Copyright header for all required files. +- `generate-fakes.sh` Use Go counterfeiter to generate fakes. +- `install-counterfeiter.sh` Install the Go counterfeiter. +- `install-kind.sh` Install the latest verified Kubernetes cluster by KinD. +- `install-kubectl.sh` Install the kubectl command line. +- `install-operator-sdk.sh` Install the verified oeprator-sdk command line. +- `install-registry.sh` Install the local container registry in the KinD cluster. +- `install-tekton.sh` Install the latest verified Tekton Pipeline release. +- `release.sh` Creates a new release of Shipwright Build. +- `update-codegen.sh` Updates auto-generated client libraries. +- `verify-codegen.sh` Verifies that auto-generated client libraries are up-to-date. diff --git a/hack/generate-client.sh b/hack/update-codegen.sh similarity index 88% rename from hack/generate-client.sh rename to hack/update-codegen.sh index 3c9d368204..dc9a2f1bc8 100755 --- a/hack/generate-client.sh +++ b/hack/update-codegen.sh @@ -21,8 +21,8 @@ echo "The code-generator package is imported via the pkg/kubecodegen dir" echo "To modify the current version, please modify this in the go.mod" echo "" -GOFLAGS="" GOPATH=${GOPATH} /bin/bash ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client" \ - github.com/shipwright-io/build/pkg/client/build \ +GOFLAGS="" GOPATH=${GOPATH} /bin/bash ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ + github.com/shipwright-io/build/pkg/client \ github.com/shipwright-io/build/pkg/apis \ - build:v1alpha1 \ + "build:v1alpha1" \ --go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt" diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh new file mode 100755 index 0000000000..88c3f3ab3a --- /dev/null +++ b/hack/verify-codegen.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright The Shipwright Contributors +# +# SPDX-License-Identifier: Apache-2.0 + +set -o errexit +set -o nounset +set -o pipefail + +REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" +readonly REPO_ROOT_DIR +readonly TMP_DIFFROOT="$(mktemp -d ${REPO_ROOT_DIR}/tmpdiffroot.XXXXXX)" + +cleanup() { + rm -rf "${TMP_DIFFROOT}" +} + +trap "cleanup" EXIT SIGINT + +cleanup + +# Save working tree state +mkdir -p "${TMP_DIFFROOT}/pkg" +cp -aR "${REPO_ROOT_DIR}/pkg" "${TMP_DIFFROOT}" + +mkdir -p "${TMP_DIFFROOT}/vendor" +cp -aR "${REPO_ROOT_DIR}/vendor" "${TMP_DIFFROOT}" + +"${REPO_ROOT_DIR}/hack/update-codegen.sh" +echo "Diffing ${REPO_ROOT_DIR} against freshly generated codegen" +ret=0 +diff -Naupr "${REPO_ROOT_DIR}/pkg" "${TMP_DIFFROOT}/pkg" || ret=1 +diff -Naupr "${REPO_ROOT_DIR}/vendor" "${TMP_DIFFROOT}/vendor" || ret=1 + +# Restore working tree state +rm -fr "${REPO_ROOT_DIR}/pkg" +rm -fr "${REPO_ROOT_DIR}/vendor" +cp -aR "${TMP_DIFFROOT}"/* "${REPO_ROOT_DIR}" + +if [[ $ret -eq 0 ]] +then + echo "${REPO_ROOT_DIR} up to date." +else + echo "${REPO_ROOT_DIR} is out of date. Please run hack/update-codegen.sh" + exit 1 +fi diff --git a/pkg/apis/build/v1alpha1/register.go b/pkg/apis/build/v1alpha1/register.go index f4220be207..fb60135266 100644 --- a/pkg/apis/build/v1alpha1/register.go +++ b/pkg/apis/build/v1alpha1/register.go @@ -24,3 +24,13 @@ var ( // AddToScheme is used in the generated kube code AddToScheme = SchemeBuilder.AddToScheme ) + +// 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() +} diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_build_client.go b/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_build_client.go deleted file mode 100644 index 03e7f8cf2a..0000000000 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_build_client.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The Shipwright Contributors -// -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1alpha1 "github.com/shipwright-io/build/pkg/client/build/clientset/versioned/typed/build/v1alpha1" - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeBuildV1alpha1 struct { - *testing.Fake -} - -func (c *FakeBuildV1alpha1) Builds(namespace string) v1alpha1.BuildInterface { - return &FakeBuilds{c, namespace} -} - -func (c *FakeBuildV1alpha1) BuildRuns(namespace string) v1alpha1.BuildRunInterface { - return &FakeBuildRuns{c, namespace} -} - -func (c *FakeBuildV1alpha1) BuildStrategies(namespace string) v1alpha1.BuildStrategyInterface { - return &FakeBuildStrategies{c, namespace} -} - -func (c *FakeBuildV1alpha1) ClusterBuildStrategies() v1alpha1.ClusterBuildStrategyInterface { - return &FakeClusterBuildStrategies{c} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeBuildV1alpha1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/pkg/client/build/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go similarity index 76% rename from pkg/client/build/clientset/versioned/clientset.go rename to pkg/client/clientset/versioned/clientset.go index 06f458217e..bdb18a088c 100644 --- a/pkg/client/build/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -9,7 +9,7 @@ package versioned import ( "fmt" - buildv1alpha1 "github.com/shipwright-io/build/pkg/client/build/clientset/versioned/typed/build/v1alpha1" + shipwrightv1alpha1 "github.com/shipwright-io/build/pkg/client/clientset/versioned/typed/build/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -17,19 +17,19 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - BuildV1alpha1() buildv1alpha1.BuildV1alpha1Interface + ShipwrightV1alpha1() shipwrightv1alpha1.ShipwrightV1alpha1Interface } // Clientset contains the clients for groups. Each group has exactly one // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - buildV1alpha1 *buildv1alpha1.BuildV1alpha1Client + shipwrightV1alpha1 *shipwrightv1alpha1.ShipwrightV1alpha1Client } -// BuildV1alpha1 retrieves the BuildV1alpha1Client -func (c *Clientset) BuildV1alpha1() buildv1alpha1.BuildV1alpha1Interface { - return c.buildV1alpha1 +// ShipwrightV1alpha1 retrieves the ShipwrightV1alpha1Client +func (c *Clientset) ShipwrightV1alpha1() shipwrightv1alpha1.ShipwrightV1alpha1Interface { + return c.shipwrightV1alpha1 } // Discovery retrieves the DiscoveryClient @@ -53,7 +53,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { } var cs Clientset var err error - cs.buildV1alpha1, err = buildv1alpha1.NewForConfig(&configShallowCopy) + cs.shipwrightV1alpha1, err = shipwrightv1alpha1.NewForConfig(&configShallowCopy) if err != nil { return nil, err } @@ -69,7 +69,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { // panics if there is an error in the config. func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset - cs.buildV1alpha1 = buildv1alpha1.NewForConfigOrDie(c) + cs.shipwrightV1alpha1 = shipwrightv1alpha1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -78,7 +78,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.buildV1alpha1 = buildv1alpha1.New(c) + cs.shipwrightV1alpha1 = shipwrightv1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/build/clientset/versioned/doc.go b/pkg/client/clientset/versioned/doc.go similarity index 100% rename from pkg/client/build/clientset/versioned/doc.go rename to pkg/client/clientset/versioned/doc.go diff --git a/pkg/client/build/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go similarity index 78% rename from pkg/client/build/clientset/versioned/fake/clientset_generated.go rename to pkg/client/clientset/versioned/fake/clientset_generated.go index 34e52328ea..9db031597b 100644 --- a/pkg/client/build/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -7,9 +7,9 @@ package fake import ( - clientset "github.com/shipwright-io/build/pkg/client/build/clientset/versioned" - buildv1alpha1 "github.com/shipwright-io/build/pkg/client/build/clientset/versioned/typed/build/v1alpha1" - fakebuildv1alpha1 "github.com/shipwright-io/build/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake" + clientset "github.com/shipwright-io/build/pkg/client/clientset/versioned" + shipwrightv1alpha1 "github.com/shipwright-io/build/pkg/client/clientset/versioned/typed/build/v1alpha1" + fakeshipwrightv1alpha1 "github.com/shipwright-io/build/pkg/client/clientset/versioned/typed/build/v1alpha1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -64,7 +64,7 @@ func (c *Clientset) Tracker() testing.ObjectTracker { var _ clientset.Interface = &Clientset{} -// BuildV1alpha1 retrieves the BuildV1alpha1Client -func (c *Clientset) BuildV1alpha1() buildv1alpha1.BuildV1alpha1Interface { - return &fakebuildv1alpha1.FakeBuildV1alpha1{Fake: &c.Fake} +// ShipwrightV1alpha1 retrieves the ShipwrightV1alpha1Client +func (c *Clientset) ShipwrightV1alpha1() shipwrightv1alpha1.ShipwrightV1alpha1Interface { + return &fakeshipwrightv1alpha1.FakeShipwrightV1alpha1{Fake: &c.Fake} } diff --git a/pkg/client/build/clientset/versioned/fake/doc.go b/pkg/client/clientset/versioned/fake/doc.go similarity index 100% rename from pkg/client/build/clientset/versioned/fake/doc.go rename to pkg/client/clientset/versioned/fake/doc.go diff --git a/pkg/client/build/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go similarity index 92% rename from pkg/client/build/clientset/versioned/fake/register.go rename to pkg/client/clientset/versioned/fake/register.go index 17d86f66a1..c07f95386b 100644 --- a/pkg/client/build/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -7,7 +7,7 @@ package fake import ( - buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + shipwrightv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -19,7 +19,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - buildv1alpha1.AddToScheme, + shipwrightv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/build/clientset/versioned/scheme/doc.go b/pkg/client/clientset/versioned/scheme/doc.go similarity index 100% rename from pkg/client/build/clientset/versioned/scheme/doc.go rename to pkg/client/clientset/versioned/scheme/doc.go diff --git a/pkg/client/build/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go similarity index 92% rename from pkg/client/build/clientset/versioned/scheme/register.go rename to pkg/client/clientset/versioned/scheme/register.go index a9e137c33f..3e6e6a2104 100644 --- a/pkg/client/build/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -7,7 +7,7 @@ package scheme import ( - buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + shipwrightv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -19,7 +19,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - buildv1alpha1.AddToScheme, + shipwrightv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/build.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/build.go similarity index 97% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/build.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/build.go index e9360fcfc0..674579ff50 100644 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/build.go +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/build.go @@ -11,7 +11,7 @@ import ( "time" v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" - scheme "github.com/shipwright-io/build/pkg/client/build/clientset/versioned/scheme" + scheme "github.com/shipwright-io/build/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" @@ -45,7 +45,7 @@ type builds struct { } // newBuilds returns a Builds -func newBuilds(c *BuildV1alpha1Client, namespace string) *builds { +func newBuilds(c *ShipwrightV1alpha1Client, namespace string) *builds { return &builds{ client: c.RESTClient(), ns: namespace, diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/build_client.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/build_client.go similarity index 53% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/build_client.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/build_client.go index e06c72c69d..7b99f8d6d6 100644 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/build_client.go +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/build_client.go @@ -8,11 +8,11 @@ package v1alpha1 import ( v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" - "github.com/shipwright-io/build/pkg/client/build/clientset/versioned/scheme" + "github.com/shipwright-io/build/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) -type BuildV1alpha1Interface interface { +type ShipwrightV1alpha1Interface interface { RESTClient() rest.Interface BuildsGetter BuildRunsGetter @@ -20,29 +20,29 @@ type BuildV1alpha1Interface interface { ClusterBuildStrategiesGetter } -// BuildV1alpha1Client is used to interact with features provided by the shipwright.io group. -type BuildV1alpha1Client struct { +// ShipwrightV1alpha1Client is used to interact with features provided by the shipwright.io group. +type ShipwrightV1alpha1Client struct { restClient rest.Interface } -func (c *BuildV1alpha1Client) Builds(namespace string) BuildInterface { +func (c *ShipwrightV1alpha1Client) Builds(namespace string) BuildInterface { return newBuilds(c, namespace) } -func (c *BuildV1alpha1Client) BuildRuns(namespace string) BuildRunInterface { +func (c *ShipwrightV1alpha1Client) BuildRuns(namespace string) BuildRunInterface { return newBuildRuns(c, namespace) } -func (c *BuildV1alpha1Client) BuildStrategies(namespace string) BuildStrategyInterface { +func (c *ShipwrightV1alpha1Client) BuildStrategies(namespace string) BuildStrategyInterface { return newBuildStrategies(c, namespace) } -func (c *BuildV1alpha1Client) ClusterBuildStrategies() ClusterBuildStrategyInterface { +func (c *ShipwrightV1alpha1Client) ClusterBuildStrategies() ClusterBuildStrategyInterface { return newClusterBuildStrategies(c) } -// NewForConfig creates a new BuildV1alpha1Client for the given config. -func NewForConfig(c *rest.Config) (*BuildV1alpha1Client, error) { +// NewForConfig creates a new ShipwrightV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*ShipwrightV1alpha1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -51,12 +51,12 @@ func NewForConfig(c *rest.Config) (*BuildV1alpha1Client, error) { if err != nil { return nil, err } - return &BuildV1alpha1Client{client}, nil + return &ShipwrightV1alpha1Client{client}, nil } -// NewForConfigOrDie creates a new BuildV1alpha1Client for the given config and +// NewForConfigOrDie creates a new ShipwrightV1alpha1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *BuildV1alpha1Client { +func NewForConfigOrDie(c *rest.Config) *ShipwrightV1alpha1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -64,9 +64,9 @@ func NewForConfigOrDie(c *rest.Config) *BuildV1alpha1Client { return client } -// New creates a new BuildV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *BuildV1alpha1Client { - return &BuildV1alpha1Client{c} +// New creates a new ShipwrightV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *ShipwrightV1alpha1Client { + return &ShipwrightV1alpha1Client{c} } func setConfigDefaults(config *rest.Config) error { @@ -84,7 +84,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *BuildV1alpha1Client) RESTClient() rest.Interface { +func (c *ShipwrightV1alpha1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/buildrun.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/buildrun.go similarity index 97% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/buildrun.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/buildrun.go index 9f1d094e8d..1418865da9 100644 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/buildrun.go +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/buildrun.go @@ -11,7 +11,7 @@ import ( "time" v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" - scheme "github.com/shipwright-io/build/pkg/client/build/clientset/versioned/scheme" + scheme "github.com/shipwright-io/build/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" @@ -45,7 +45,7 @@ type buildRuns struct { } // newBuildRuns returns a BuildRuns -func newBuildRuns(c *BuildV1alpha1Client, namespace string) *buildRuns { +func newBuildRuns(c *ShipwrightV1alpha1Client, namespace string) *buildRuns { return &buildRuns{ client: c.RESTClient(), ns: namespace, diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/buildstrategy.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/buildstrategy.go similarity index 97% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/buildstrategy.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/buildstrategy.go index 979e3a6f36..52330975bb 100644 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/buildstrategy.go +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/buildstrategy.go @@ -11,7 +11,7 @@ import ( "time" v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" - scheme "github.com/shipwright-io/build/pkg/client/build/clientset/versioned/scheme" + scheme "github.com/shipwright-io/build/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" @@ -45,7 +45,7 @@ type buildStrategies struct { } // newBuildStrategies returns a BuildStrategies -func newBuildStrategies(c *BuildV1alpha1Client, namespace string) *buildStrategies { +func newBuildStrategies(c *ShipwrightV1alpha1Client, namespace string) *buildStrategies { return &buildStrategies{ client: c.RESTClient(), ns: namespace, diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/clusterbuildstrategy.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/clusterbuildstrategy.go similarity index 97% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/clusterbuildstrategy.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/clusterbuildstrategy.go index f4ea69da50..9ff6f63046 100644 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/clusterbuildstrategy.go +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/clusterbuildstrategy.go @@ -11,7 +11,7 @@ import ( "time" v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" - scheme "github.com/shipwright-io/build/pkg/client/build/clientset/versioned/scheme" + scheme "github.com/shipwright-io/build/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" @@ -44,7 +44,7 @@ type clusterBuildStrategies struct { } // newClusterBuildStrategies returns a ClusterBuildStrategies -func newClusterBuildStrategies(c *BuildV1alpha1Client) *clusterBuildStrategies { +func newClusterBuildStrategies(c *ShipwrightV1alpha1Client) *clusterBuildStrategies { return &clusterBuildStrategies{ client: c.RESTClient(), } diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/doc.go similarity index 100% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/doc.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/doc.go diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/doc.go similarity index 100% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/doc.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/fake/doc.go diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_build.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_build.go similarity index 99% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_build.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_build.go index a88ba8da77..4c9c4c3c53 100644 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_build.go +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_build.go @@ -20,7 +20,7 @@ import ( // FakeBuilds implements BuildInterface type FakeBuilds struct { - Fake *FakeBuildV1alpha1 + Fake *FakeShipwrightV1alpha1 ns string } diff --git a/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_build_client.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_build_client.go new file mode 100644 index 0000000000..8132a483ea --- /dev/null +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_build_client.go @@ -0,0 +1,40 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/shipwright-io/build/pkg/client/clientset/versioned/typed/build/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeShipwrightV1alpha1 struct { + *testing.Fake +} + +func (c *FakeShipwrightV1alpha1) Builds(namespace string) v1alpha1.BuildInterface { + return &FakeBuilds{c, namespace} +} + +func (c *FakeShipwrightV1alpha1) BuildRuns(namespace string) v1alpha1.BuildRunInterface { + return &FakeBuildRuns{c, namespace} +} + +func (c *FakeShipwrightV1alpha1) BuildStrategies(namespace string) v1alpha1.BuildStrategyInterface { + return &FakeBuildStrategies{c, namespace} +} + +func (c *FakeShipwrightV1alpha1) ClusterBuildStrategies() v1alpha1.ClusterBuildStrategyInterface { + return &FakeClusterBuildStrategies{c} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeShipwrightV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_buildrun.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_buildrun.go similarity index 99% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_buildrun.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_buildrun.go index 5ab7e5f380..68c9f28820 100644 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_buildrun.go +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_buildrun.go @@ -20,7 +20,7 @@ import ( // FakeBuildRuns implements BuildRunInterface type FakeBuildRuns struct { - Fake *FakeBuildV1alpha1 + Fake *FakeShipwrightV1alpha1 ns string } diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_buildstrategy.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_buildstrategy.go similarity index 99% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_buildstrategy.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_buildstrategy.go index 75ef96fb8b..342c2516f2 100644 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_buildstrategy.go +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_buildstrategy.go @@ -20,7 +20,7 @@ import ( // FakeBuildStrategies implements BuildStrategyInterface type FakeBuildStrategies struct { - Fake *FakeBuildV1alpha1 + Fake *FakeShipwrightV1alpha1 ns string } diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_clusterbuildstrategy.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_clusterbuildstrategy.go similarity index 99% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_clusterbuildstrategy.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_clusterbuildstrategy.go index 1016b1d634..14fd8f5fc1 100644 --- a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/fake/fake_clusterbuildstrategy.go +++ b/pkg/client/clientset/versioned/typed/build/v1alpha1/fake/fake_clusterbuildstrategy.go @@ -20,7 +20,7 @@ import ( // FakeClusterBuildStrategies implements ClusterBuildStrategyInterface type FakeClusterBuildStrategies struct { - Fake *FakeBuildV1alpha1 + Fake *FakeShipwrightV1alpha1 } var clusterbuildstrategiesResource = schema.GroupVersionResource{Group: "shipwright.io", Version: "v1alpha1", Resource: "clusterbuildstrategies"} diff --git a/pkg/client/build/clientset/versioned/typed/build/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/build/v1alpha1/generated_expansion.go similarity index 100% rename from pkg/client/build/clientset/versioned/typed/build/v1alpha1/generated_expansion.go rename to pkg/client/clientset/versioned/typed/build/v1alpha1/generated_expansion.go diff --git a/pkg/client/informers/externalversions/build/interface.go b/pkg/client/informers/externalversions/build/interface.go new file mode 100644 index 0000000000..eb31e4bd21 --- /dev/null +++ b/pkg/client/informers/externalversions/build/interface.go @@ -0,0 +1,34 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package build + +import ( + v1alpha1 "github.com/shipwright-io/build/pkg/client/informers/externalversions/build/v1alpha1" + internalinterfaces "github.com/shipwright-io/build/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/build/v1alpha1/build.go b/pkg/client/informers/externalversions/build/v1alpha1/build.go new file mode 100644 index 0000000000..42c6b49c85 --- /dev/null +++ b/pkg/client/informers/externalversions/build/v1alpha1/build.go @@ -0,0 +1,78 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + versioned "github.com/shipwright-io/build/pkg/client/clientset/versioned" + internalinterfaces "github.com/shipwright-io/build/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/shipwright-io/build/pkg/client/listers/build/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// BuildInformer provides access to a shared informer and lister for +// Builds. +type BuildInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.BuildLister +} + +type buildInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewBuildInformer constructs a new informer for Build type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewBuildInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredBuildInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredBuildInformer constructs a new informer for Build type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredBuildInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ShipwrightV1alpha1().Builds(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ShipwrightV1alpha1().Builds(namespace).Watch(context.TODO(), options) + }, + }, + &buildv1alpha1.Build{}, + resyncPeriod, + indexers, + ) +} + +func (f *buildInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredBuildInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *buildInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&buildv1alpha1.Build{}, f.defaultInformer) +} + +func (f *buildInformer) Lister() v1alpha1.BuildLister { + return v1alpha1.NewBuildLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/build/v1alpha1/buildrun.go b/pkg/client/informers/externalversions/build/v1alpha1/buildrun.go new file mode 100644 index 0000000000..af279288db --- /dev/null +++ b/pkg/client/informers/externalversions/build/v1alpha1/buildrun.go @@ -0,0 +1,78 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + versioned "github.com/shipwright-io/build/pkg/client/clientset/versioned" + internalinterfaces "github.com/shipwright-io/build/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/shipwright-io/build/pkg/client/listers/build/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// BuildRunInformer provides access to a shared informer and lister for +// BuildRuns. +type BuildRunInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.BuildRunLister +} + +type buildRunInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewBuildRunInformer constructs a new informer for BuildRun type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewBuildRunInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredBuildRunInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredBuildRunInformer constructs a new informer for BuildRun type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredBuildRunInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ShipwrightV1alpha1().BuildRuns(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ShipwrightV1alpha1().BuildRuns(namespace).Watch(context.TODO(), options) + }, + }, + &buildv1alpha1.BuildRun{}, + resyncPeriod, + indexers, + ) +} + +func (f *buildRunInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredBuildRunInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *buildRunInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&buildv1alpha1.BuildRun{}, f.defaultInformer) +} + +func (f *buildRunInformer) Lister() v1alpha1.BuildRunLister { + return v1alpha1.NewBuildRunLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/build/v1alpha1/buildstrategy.go b/pkg/client/informers/externalversions/build/v1alpha1/buildstrategy.go new file mode 100644 index 0000000000..a75cc00da6 --- /dev/null +++ b/pkg/client/informers/externalversions/build/v1alpha1/buildstrategy.go @@ -0,0 +1,78 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + versioned "github.com/shipwright-io/build/pkg/client/clientset/versioned" + internalinterfaces "github.com/shipwright-io/build/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/shipwright-io/build/pkg/client/listers/build/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// BuildStrategyInformer provides access to a shared informer and lister for +// BuildStrategies. +type BuildStrategyInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.BuildStrategyLister +} + +type buildStrategyInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewBuildStrategyInformer constructs a new informer for BuildStrategy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewBuildStrategyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredBuildStrategyInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredBuildStrategyInformer constructs a new informer for BuildStrategy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredBuildStrategyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ShipwrightV1alpha1().BuildStrategies(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ShipwrightV1alpha1().BuildStrategies(namespace).Watch(context.TODO(), options) + }, + }, + &buildv1alpha1.BuildStrategy{}, + resyncPeriod, + indexers, + ) +} + +func (f *buildStrategyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredBuildStrategyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *buildStrategyInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&buildv1alpha1.BuildStrategy{}, f.defaultInformer) +} + +func (f *buildStrategyInformer) Lister() v1alpha1.BuildStrategyLister { + return v1alpha1.NewBuildStrategyLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/build/v1alpha1/clusterbuildstrategy.go b/pkg/client/informers/externalversions/build/v1alpha1/clusterbuildstrategy.go new file mode 100644 index 0000000000..d350b2e5bb --- /dev/null +++ b/pkg/client/informers/externalversions/build/v1alpha1/clusterbuildstrategy.go @@ -0,0 +1,77 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + versioned "github.com/shipwright-io/build/pkg/client/clientset/versioned" + internalinterfaces "github.com/shipwright-io/build/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/shipwright-io/build/pkg/client/listers/build/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ClusterBuildStrategyInformer provides access to a shared informer and lister for +// ClusterBuildStrategies. +type ClusterBuildStrategyInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ClusterBuildStrategyLister +} + +type clusterBuildStrategyInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewClusterBuildStrategyInformer constructs a new informer for ClusterBuildStrategy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewClusterBuildStrategyInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterBuildStrategyInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterBuildStrategyInformer constructs a new informer for ClusterBuildStrategy type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredClusterBuildStrategyInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ShipwrightV1alpha1().ClusterBuildStrategies().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ShipwrightV1alpha1().ClusterBuildStrategies().Watch(context.TODO(), options) + }, + }, + &buildv1alpha1.ClusterBuildStrategy{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterBuildStrategyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterBuildStrategyInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterBuildStrategyInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&buildv1alpha1.ClusterBuildStrategy{}, f.defaultInformer) +} + +func (f *clusterBuildStrategyInformer) Lister() v1alpha1.ClusterBuildStrategyLister { + return v1alpha1.NewClusterBuildStrategyLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/build/v1alpha1/interface.go b/pkg/client/informers/externalversions/build/v1alpha1/interface.go new file mode 100644 index 0000000000..2d3e5bb2b5 --- /dev/null +++ b/pkg/client/informers/externalversions/build/v1alpha1/interface.go @@ -0,0 +1,54 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/shipwright-io/build/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Builds returns a BuildInformer. + Builds() BuildInformer + // BuildRuns returns a BuildRunInformer. + BuildRuns() BuildRunInformer + // BuildStrategies returns a BuildStrategyInformer. + BuildStrategies() BuildStrategyInformer + // ClusterBuildStrategies returns a ClusterBuildStrategyInformer. + ClusterBuildStrategies() ClusterBuildStrategyInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Builds returns a BuildInformer. +func (v *version) Builds() BuildInformer { + return &buildInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// BuildRuns returns a BuildRunInformer. +func (v *version) BuildRuns() BuildRunInformer { + return &buildRunInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// BuildStrategies returns a BuildStrategyInformer. +func (v *version) BuildStrategies() BuildStrategyInformer { + return &buildStrategyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ClusterBuildStrategies returns a ClusterBuildStrategyInformer. +func (v *version) ClusterBuildStrategies() ClusterBuildStrategyInformer { + return &clusterBuildStrategyInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go new file mode 100644 index 0000000000..fbba65f89a --- /dev/null +++ b/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,168 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/shipwright-io/build/pkg/client/clientset/versioned" + build "github.com/shipwright-io/build/pkg/client/informers/externalversions/build" + internalinterfaces "github.com/shipwright-io/build/pkg/client/informers/externalversions/internalinterfaces" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Shipwright() build.Interface +} + +func (f *sharedInformerFactory) Shipwright() build.Interface { + return build.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go new file mode 100644 index 0000000000..eb1ac3fa70 --- /dev/null +++ b/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,56 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=shipwright.io, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("builds"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Shipwright().V1alpha1().Builds().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("buildruns"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Shipwright().V1alpha1().BuildRuns().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("buildstrategies"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Shipwright().V1alpha1().BuildStrategies().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("clusterbuildstrategies"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Shipwright().V1alpha1().ClusterBuildStrategies().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000000..f355d340b8 --- /dev/null +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,28 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + versioned "github.com/shipwright-io/build/pkg/client/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/client/listers/build/v1alpha1/build.go b/pkg/client/listers/build/v1alpha1/build.go new file mode 100644 index 0000000000..7e0b260dc3 --- /dev/null +++ b/pkg/client/listers/build/v1alpha1/build.go @@ -0,0 +1,82 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// BuildLister helps list Builds. +type BuildLister interface { + // List lists all Builds in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Build, err error) + // Builds returns an object that can list and get Builds. + Builds(namespace string) BuildNamespaceLister + BuildListerExpansion +} + +// buildLister implements the BuildLister interface. +type buildLister struct { + indexer cache.Indexer +} + +// NewBuildLister returns a new BuildLister. +func NewBuildLister(indexer cache.Indexer) BuildLister { + return &buildLister{indexer: indexer} +} + +// List lists all Builds in the indexer. +func (s *buildLister) List(selector labels.Selector) (ret []*v1alpha1.Build, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Build)) + }) + return ret, err +} + +// Builds returns an object that can list and get Builds. +func (s *buildLister) Builds(namespace string) BuildNamespaceLister { + return buildNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// BuildNamespaceLister helps list and get Builds. +type BuildNamespaceLister interface { + // List lists all Builds in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Build, err error) + // Get retrieves the Build from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Build, error) + BuildNamespaceListerExpansion +} + +// buildNamespaceLister implements the BuildNamespaceLister +// interface. +type buildNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Builds in the indexer for a given namespace. +func (s buildNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Build, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Build)) + }) + return ret, err +} + +// Get retrieves the Build from the indexer for a given namespace and name. +func (s buildNamespaceLister) Get(name string) (*v1alpha1.Build, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("build"), name) + } + return obj.(*v1alpha1.Build), nil +} diff --git a/pkg/client/listers/build/v1alpha1/buildrun.go b/pkg/client/listers/build/v1alpha1/buildrun.go new file mode 100644 index 0000000000..d3e84b7527 --- /dev/null +++ b/pkg/client/listers/build/v1alpha1/buildrun.go @@ -0,0 +1,82 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// BuildRunLister helps list BuildRuns. +type BuildRunLister interface { + // List lists all BuildRuns in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.BuildRun, err error) + // BuildRuns returns an object that can list and get BuildRuns. + BuildRuns(namespace string) BuildRunNamespaceLister + BuildRunListerExpansion +} + +// buildRunLister implements the BuildRunLister interface. +type buildRunLister struct { + indexer cache.Indexer +} + +// NewBuildRunLister returns a new BuildRunLister. +func NewBuildRunLister(indexer cache.Indexer) BuildRunLister { + return &buildRunLister{indexer: indexer} +} + +// List lists all BuildRuns in the indexer. +func (s *buildRunLister) List(selector labels.Selector) (ret []*v1alpha1.BuildRun, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.BuildRun)) + }) + return ret, err +} + +// BuildRuns returns an object that can list and get BuildRuns. +func (s *buildRunLister) BuildRuns(namespace string) BuildRunNamespaceLister { + return buildRunNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// BuildRunNamespaceLister helps list and get BuildRuns. +type BuildRunNamespaceLister interface { + // List lists all BuildRuns in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.BuildRun, err error) + // Get retrieves the BuildRun from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.BuildRun, error) + BuildRunNamespaceListerExpansion +} + +// buildRunNamespaceLister implements the BuildRunNamespaceLister +// interface. +type buildRunNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all BuildRuns in the indexer for a given namespace. +func (s buildRunNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.BuildRun, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.BuildRun)) + }) + return ret, err +} + +// Get retrieves the BuildRun from the indexer for a given namespace and name. +func (s buildRunNamespaceLister) Get(name string) (*v1alpha1.BuildRun, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("buildrun"), name) + } + return obj.(*v1alpha1.BuildRun), nil +} diff --git a/pkg/client/listers/build/v1alpha1/buildstrategy.go b/pkg/client/listers/build/v1alpha1/buildstrategy.go new file mode 100644 index 0000000000..658aa511ed --- /dev/null +++ b/pkg/client/listers/build/v1alpha1/buildstrategy.go @@ -0,0 +1,82 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// BuildStrategyLister helps list BuildStrategies. +type BuildStrategyLister interface { + // List lists all BuildStrategies in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.BuildStrategy, err error) + // BuildStrategies returns an object that can list and get BuildStrategies. + BuildStrategies(namespace string) BuildStrategyNamespaceLister + BuildStrategyListerExpansion +} + +// buildStrategyLister implements the BuildStrategyLister interface. +type buildStrategyLister struct { + indexer cache.Indexer +} + +// NewBuildStrategyLister returns a new BuildStrategyLister. +func NewBuildStrategyLister(indexer cache.Indexer) BuildStrategyLister { + return &buildStrategyLister{indexer: indexer} +} + +// List lists all BuildStrategies in the indexer. +func (s *buildStrategyLister) List(selector labels.Selector) (ret []*v1alpha1.BuildStrategy, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.BuildStrategy)) + }) + return ret, err +} + +// BuildStrategies returns an object that can list and get BuildStrategies. +func (s *buildStrategyLister) BuildStrategies(namespace string) BuildStrategyNamespaceLister { + return buildStrategyNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// BuildStrategyNamespaceLister helps list and get BuildStrategies. +type BuildStrategyNamespaceLister interface { + // List lists all BuildStrategies in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.BuildStrategy, err error) + // Get retrieves the BuildStrategy from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.BuildStrategy, error) + BuildStrategyNamespaceListerExpansion +} + +// buildStrategyNamespaceLister implements the BuildStrategyNamespaceLister +// interface. +type buildStrategyNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all BuildStrategies in the indexer for a given namespace. +func (s buildStrategyNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.BuildStrategy, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.BuildStrategy)) + }) + return ret, err +} + +// Get retrieves the BuildStrategy from the indexer for a given namespace and name. +func (s buildStrategyNamespaceLister) Get(name string) (*v1alpha1.BuildStrategy, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("buildstrategy"), name) + } + return obj.(*v1alpha1.BuildStrategy), nil +} diff --git a/pkg/client/listers/build/v1alpha1/clusterbuildstrategy.go b/pkg/client/listers/build/v1alpha1/clusterbuildstrategy.go new file mode 100644 index 0000000000..54df4ac7ea --- /dev/null +++ b/pkg/client/listers/build/v1alpha1/clusterbuildstrategy.go @@ -0,0 +1,53 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterBuildStrategyLister helps list ClusterBuildStrategies. +type ClusterBuildStrategyLister interface { + // List lists all ClusterBuildStrategies in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.ClusterBuildStrategy, err error) + // Get retrieves the ClusterBuildStrategy from the index for a given name. + Get(name string) (*v1alpha1.ClusterBuildStrategy, error) + ClusterBuildStrategyListerExpansion +} + +// clusterBuildStrategyLister implements the ClusterBuildStrategyLister interface. +type clusterBuildStrategyLister struct { + indexer cache.Indexer +} + +// NewClusterBuildStrategyLister returns a new ClusterBuildStrategyLister. +func NewClusterBuildStrategyLister(indexer cache.Indexer) ClusterBuildStrategyLister { + return &clusterBuildStrategyLister{indexer: indexer} +} + +// List lists all ClusterBuildStrategies in the indexer. +func (s *clusterBuildStrategyLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterBuildStrategy, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ClusterBuildStrategy)) + }) + return ret, err +} + +// Get retrieves the ClusterBuildStrategy from the index for a given name. +func (s *clusterBuildStrategyLister) Get(name string) (*v1alpha1.ClusterBuildStrategy, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("clusterbuildstrategy"), name) + } + return obj.(*v1alpha1.ClusterBuildStrategy), nil +} diff --git a/pkg/client/listers/build/v1alpha1/expansion_generated.go b/pkg/client/listers/build/v1alpha1/expansion_generated.go new file mode 100644 index 0000000000..95f4d942ef --- /dev/null +++ b/pkg/client/listers/build/v1alpha1/expansion_generated.go @@ -0,0 +1,35 @@ +// Copyright The Shipwright Contributors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// BuildListerExpansion allows custom methods to be added to +// BuildLister. +type BuildListerExpansion interface{} + +// BuildNamespaceListerExpansion allows custom methods to be added to +// BuildNamespaceLister. +type BuildNamespaceListerExpansion interface{} + +// BuildRunListerExpansion allows custom methods to be added to +// BuildRunLister. +type BuildRunListerExpansion interface{} + +// BuildRunNamespaceListerExpansion allows custom methods to be added to +// BuildRunNamespaceLister. +type BuildRunNamespaceListerExpansion interface{} + +// BuildStrategyListerExpansion allows custom methods to be added to +// BuildStrategyLister. +type BuildStrategyListerExpansion interface{} + +// BuildStrategyNamespaceListerExpansion allows custom methods to be added to +// BuildStrategyNamespaceLister. +type BuildStrategyNamespaceListerExpansion interface{} + +// ClusterBuildStrategyListerExpansion allows custom methods to be added to +// ClusterBuildStrategyLister. +type ClusterBuildStrategyListerExpansion interface{} diff --git a/test/integration/buildruns_to_taskruns_test.go b/test/integration/buildruns_to_taskruns_test.go index b027a83a4b..8c1fa0023f 100644 --- a/test/integration/buildruns_to_taskruns_test.go +++ b/test/integration/buildruns_to_taskruns_test.go @@ -35,7 +35,7 @@ var _ = Describe("Integration tests BuildRuns and TaskRuns", func() { strategyName = strategy[0] } - buildRunWitcher, err := tb.BuildClientSet.BuildV1alpha1().BuildRuns(tb.Namespace).Watch(context.TODO(), metav1.ListOptions{}) + buildRunWitcher, err := tb.BuildClientSet.ShipwrightV1alpha1().BuildRuns(tb.Namespace).Watch(context.TODO(), metav1.ListOptions{}) Expect(err).To(BeNil()) buildObject, err = tb.Catalog.LoadBuildWithNameAndStrategy(BUILD+tb.Namespace, strategyName, buildDef) diff --git a/test/utils/buildruns.go b/test/utils/buildruns.go index 6935e0967d..77aa0238ae 100644 --- a/test/utils/buildruns.go +++ b/test/utils/buildruns.go @@ -20,7 +20,7 @@ import ( // CreateBR generates a BuildRun on the current test namespace func (t *TestBuild) CreateBR(buildRun *v1alpha1.BuildRun) error { - brInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + brInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) _, err := brInterface.Create(context.TODO(), buildRun, metav1.CreateOptions{}) if err != nil { @@ -32,7 +32,7 @@ func (t *TestBuild) CreateBR(buildRun *v1alpha1.BuildRun) error { // GetBR retrieves a BuildRun from a desired namespace // Deprecated: Use LookupBuildRun instead. func (t *TestBuild) GetBR(name string) (*v1alpha1.BuildRun, error) { - brInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + brInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) br, err := brInterface.Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { @@ -43,7 +43,7 @@ func (t *TestBuild) GetBR(name string) (*v1alpha1.BuildRun, error) { // DeleteBR deletes a BuildRun from a desired namespace func (t *TestBuild) DeleteBR(name string) error { - brInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + brInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) if err := brInterface.Delete(context.TODO(), name, metav1.DeleteOptions{}); err != nil { return err @@ -69,7 +69,7 @@ func (t *TestBuild) GetBRTillCompletion(name string) (*v1alpha1.BuildRun, error) var ( pollBRTillCompletion = func() (bool, error) { - bInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + bInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) buildRun, err := bInterface.Get(context.TODO(), name, metav1.GetOptions{}) if err != nil && !apierrors.IsNotFound(err) { @@ -83,7 +83,7 @@ func (t *TestBuild) GetBRTillCompletion(name string) (*v1alpha1.BuildRun, error) } ) - brInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + brInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) err := wait.PollImmediate(t.Interval, t.TimeOut, pollBRTillCompletion) if err != nil { @@ -98,7 +98,7 @@ func (t *TestBuild) GetBRTillCompletion(name string) (*v1alpha1.BuildRun, error) // stop polling and return func (t *TestBuild) GetBRTillNotOwner(name string, owner string) (*v1alpha1.BuildRun, error) { - brInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + brInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) var ( pollBRTillNotOwner = func() (bool, error) { @@ -130,7 +130,7 @@ func (t *TestBuild) GetBRTillNotOwner(name string, owner string) (*v1alpha1.Buil // stop polling and return func (t *TestBuild) GetBRTillOwner(name string, owner string) (*v1alpha1.BuildRun, error) { - brInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + brInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) var ( pollBRTillOwner = func() (bool, error) { @@ -165,7 +165,7 @@ func (t *TestBuild) GetBRTillStartTime(name string) (*v1alpha1.BuildRun, error) var ( pollBRTillCompletion = func() (bool, error) { - bInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + bInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) buildRun, err := bInterface.Get(context.TODO(), name, metav1.GetOptions{}) if err != nil && !apierrors.IsNotFound(err) { @@ -188,7 +188,7 @@ func (t *TestBuild) GetBRTillStartTime(name string) (*v1alpha1.BuildRun, error) } ) - brInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + brInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) err := wait.PollImmediate(t.Interval, t.TimeOut, pollBRTillCompletion) if err != nil { @@ -223,7 +223,7 @@ func (t *TestBuild) GetBRTillDeletion(name string) (bool, error) { var ( pollBRTillCompletion = func() (bool, error) { - bInterface := t.BuildClientSet.BuildV1alpha1().BuildRuns(t.Namespace) + bInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildRuns(t.Namespace) _, err := bInterface.Get(context.TODO(), name, metav1.GetOptions{}) if apierrors.IsNotFound(err) { diff --git a/test/utils/builds.go b/test/utils/builds.go index 829f0907e9..a0c8f3b3b0 100644 --- a/test/utils/builds.go +++ b/test/utils/builds.go @@ -21,7 +21,7 @@ import ( // CreateBuild generates a Build on the current test namespace func (t *TestBuild) CreateBuild(build *v1alpha1.Build) error { - bInterface := t.BuildClientSet.BuildV1alpha1().Builds(t.Namespace) + bInterface := t.BuildClientSet.ShipwrightV1alpha1().Builds(t.Namespace) _, err := bInterface.Create(context.TODO(), build, metav1.CreateOptions{}) return err @@ -29,7 +29,7 @@ func (t *TestBuild) CreateBuild(build *v1alpha1.Build) error { // DeleteBuild deletes a Build on the desired namespace func (t *TestBuild) DeleteBuild(name string) error { - bInterface := t.BuildClientSet.BuildV1alpha1().Builds(t.Namespace) + bInterface := t.BuildClientSet.ShipwrightV1alpha1().Builds(t.Namespace) err := bInterface.Delete(context.TODO(), name, metav1.DeleteOptions{}) @@ -39,10 +39,8 @@ func (t *TestBuild) DeleteBuild(name string) error { // GetBuild returns a Build based on name // Deprecated: Use LookupBuild instead func (t *TestBuild) GetBuild(name string) (*v1alpha1.Build, error) { - return t.BuildClientSet. - BuildV1alpha1(). - Builds(t.Namespace). - Get(context.TODO(), name, metav1.GetOptions{}) + return t.BuildClientSet.ShipwrightV1alpha1(). + Builds(t.Namespace).Get(context.TODO(), name, metav1.GetOptions{}) } // PatchBuild patches an existing Build using the merge patch type @@ -52,7 +50,7 @@ func (t *TestBuild) PatchBuild(buildName string, data []byte) (*v1alpha1.Build, // PatchBuildWithPatchType patches an existing Build and allows specifying the patch type func (t *TestBuild) PatchBuildWithPatchType(buildName string, data []byte, pt types.PatchType) (*v1alpha1.Build, error) { - bInterface := t.BuildClientSet.BuildV1alpha1().Builds(t.Namespace) + bInterface := t.BuildClientSet.ShipwrightV1alpha1().Builds(t.Namespace) b, err := bInterface.Patch(context.TODO(), buildName, pt, data, metav1.PatchOptions{}) if err != nil { return nil, err @@ -89,7 +87,7 @@ func (t *TestBuild) GetBuildTillRegistration(name string, condition corev1.Condi var ( pollBuildTillRegistration = func() (bool, error) { - bInterface := t.BuildClientSet.BuildV1alpha1().Builds(t.Namespace) + bInterface := t.BuildClientSet.ShipwrightV1alpha1().Builds(t.Namespace) buildRun, err := bInterface.Get(context.TODO(), name, metav1.GetOptions{}) if err != nil && !apierrors.IsNotFound(err) { @@ -104,7 +102,7 @@ func (t *TestBuild) GetBuildTillRegistration(name string, condition corev1.Condi } ) - brInterface := t.BuildClientSet.BuildV1alpha1().Builds(t.Namespace) + brInterface := t.BuildClientSet.ShipwrightV1alpha1().Builds(t.Namespace) if err := wait.PollImmediate(t.Interval, t.TimeOut, pollBuildTillRegistration); err != nil { return nil, err @@ -121,7 +119,7 @@ func (t *TestBuild) GetBuildTillMessageContainsSubstring(name string, partOfMess var ( pollBuildTillMessageContainsSubString = func() (bool, error) { - bInterface := t.BuildClientSet.BuildV1alpha1().Builds(t.Namespace) + bInterface := t.BuildClientSet.ShipwrightV1alpha1().Builds(t.Namespace) buildRun, err := bInterface.Get(context.TODO(), name, metav1.GetOptions{}) if err != nil && !apierrors.IsNotFound(err) { @@ -136,7 +134,7 @@ func (t *TestBuild) GetBuildTillMessageContainsSubstring(name string, partOfMess } ) - brInterface := t.BuildClientSet.BuildV1alpha1().Builds(t.Namespace) + brInterface := t.BuildClientSet.ShipwrightV1alpha1().Builds(t.Namespace) if err := wait.PollImmediate(t.Interval, t.TimeOut, pollBuildTillMessageContainsSubString); err != nil { return nil, err diff --git a/test/utils/buildstrategies.go b/test/utils/buildstrategies.go index d2a287c195..0c3937675c 100644 --- a/test/utils/buildstrategies.go +++ b/test/utils/buildstrategies.go @@ -16,7 +16,7 @@ import ( // CreateBuildStrategy generates a BuildStrategy on the current test namespace func (t *TestBuild) CreateBuildStrategy(bs *v1alpha1.BuildStrategy) error { - bsInterface := t.BuildClientSet.BuildV1alpha1().BuildStrategies(t.Namespace) + bsInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildStrategies(t.Namespace) _, err := bsInterface.Create(context.TODO(), bs, metav1.CreateOptions{}) if err != nil { @@ -27,7 +27,7 @@ func (t *TestBuild) CreateBuildStrategy(bs *v1alpha1.BuildStrategy) error { // DeleteBuildStrategy deletes a BuildStrategy on the current test namespace func (t *TestBuild) DeleteBuildStrategy(name string) error { - bsInterface := t.BuildClientSet.BuildV1alpha1().BuildStrategies(t.Namespace) + bsInterface := t.BuildClientSet.ShipwrightV1alpha1().BuildStrategies(t.Namespace) return bsInterface.Delete(context.TODO(), name, metav1.DeleteOptions{}) } diff --git a/test/utils/clusterbuildstrategies.go b/test/utils/clusterbuildstrategies.go index 8cb3c96968..75270c875d 100644 --- a/test/utils/clusterbuildstrategies.go +++ b/test/utils/clusterbuildstrategies.go @@ -16,7 +16,7 @@ import ( // CreateClusterBuildStrategy generates a ClusterBuildStrategy on the current test namespace func (t *TestBuild) CreateClusterBuildStrategy(cbs *v1alpha1.ClusterBuildStrategy) error { - cbsInterface := t.BuildClientSet.BuildV1alpha1().ClusterBuildStrategies() + cbsInterface := t.BuildClientSet.ShipwrightV1alpha1().ClusterBuildStrategies() _, err := cbsInterface.Create(context.TODO(), cbs, metav1.CreateOptions{}) if err != nil { @@ -27,7 +27,7 @@ func (t *TestBuild) CreateClusterBuildStrategy(cbs *v1alpha1.ClusterBuildStrateg // DeleteClusterBuildStrategy deletes a ClusterBuildStrategy on the desired namespace func (t *TestBuild) DeleteClusterBuildStrategy(name string) error { - cbsInterface := t.BuildClientSet.BuildV1alpha1().ClusterBuildStrategies() + cbsInterface := t.BuildClientSet.ShipwrightV1alpha1().ClusterBuildStrategies() err := cbsInterface.Delete(context.TODO(), name, metav1.DeleteOptions{}) if err != nil { diff --git a/test/utils/environment.go b/test/utils/environment.go index 64a79cefbd..f1327e8033 100644 --- a/test/utils/environment.go +++ b/test/utils/environment.go @@ -21,7 +21,7 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" - buildClient "github.com/shipwright-io/build/pkg/client/build/clientset/versioned" + buildClient "github.com/shipwright-io/build/pkg/client/clientset/versioned" "github.com/shipwright-io/build/pkg/ctxlog" "github.com/shipwright-io/build/test" // from https://github.com/kubernetes/client-go/issues/345 diff --git a/test/utils/lookup.go b/test/utils/lookup.go index 66031c20e0..432b8fb8d6 100644 --- a/test/utils/lookup.go +++ b/test/utils/lookup.go @@ -45,10 +45,8 @@ func (t *TestBuild) LookupPod(entity types.NamespacedName) (*corev1.Pod, error) func (t *TestBuild) LookupBuild(entity types.NamespacedName) (*buildv1alpha1.Build, error) { result, err := lookupRuntimeObject(func() (runtime.Object, error) { - return t.BuildClientSet. - BuildV1alpha1(). - Builds(entity.Namespace). - Get(t.Context, entity.Name, metav1.GetOptions{}) + return t.BuildClientSet.ShipwrightV1alpha1(). + Builds(entity.Namespace).Get(t.Context, entity.Name, metav1.GetOptions{}) }) return result.(*buildv1alpha1.Build), err @@ -56,10 +54,8 @@ func (t *TestBuild) LookupBuild(entity types.NamespacedName) (*buildv1alpha1.Bui func (t *TestBuild) LookupBuildRun(entity types.NamespacedName) (*buildv1alpha1.BuildRun, error) { result, err := lookupRuntimeObject(func() (runtime.Object, error) { - return t.BuildClientSet. - BuildV1alpha1(). - BuildRuns(entity.Namespace). - Get(t.Context, entity.Name, metav1.GetOptions{}) + return t.BuildClientSet.ShipwrightV1alpha1(). + BuildRuns(entity.Namespace).Get(t.Context, entity.Name, metav1.GetOptions{}) }) return result.(*buildv1alpha1.BuildRun), err