mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
Install and codegen support for cluster CRD
This commit is contained in:
parent
70f6c37ca0
commit
c2379a3e8b
27 changed files with 768 additions and 15 deletions
4
Makefile
4
Makefile
|
|
@ -45,6 +45,10 @@ all: argocd server
|
|||
protogen:
|
||||
./hack/generate-proto.sh
|
||||
|
||||
.PHONY: codegen
|
||||
codegen: protogen
|
||||
./hack/update-codegen.sh
|
||||
|
||||
.PHONY: argocd
|
||||
argocd: protogen
|
||||
CGO_ENABLED=0 go build -v -i -ldflags '${LDFLAGS} -extldflags "-static"' -o ${DIST_DIR}/argocd ./cmd/argocd
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/argoproj/argo-cd/pkg/apis/application"
|
||||
appv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/pkg/apis/cluster"
|
||||
"github.com/ghodss/yaml"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -34,7 +35,8 @@ func NewInstallCommand(globalArgs *globalFlags) *cobra.Command {
|
|||
Run: func(c *cobra.Command, args []string) {
|
||||
client := getKubeClient(globalArgs.kubeConfigPath, globalArgs.kubeConfigOverrides)
|
||||
extensionsClient := apiextensionsclient.NewForConfigOrDie(getKubeConfig(globalArgs.kubeConfigPath, globalArgs.kubeConfigOverrides))
|
||||
installCRD(client, extensionsClient, installArgs)
|
||||
installAppCRD(client, extensionsClient, installArgs)
|
||||
installClusterCRD(client, extensionsClient, installArgs)
|
||||
},
|
||||
}
|
||||
command.Flags().BoolVar(&installArgs.DryRun, "dry-run", false, "print the kubernetes manifests to stdout instead of installing")
|
||||
|
|
@ -42,7 +44,7 @@ func NewInstallCommand(globalArgs *globalFlags) *cobra.Command {
|
|||
return command
|
||||
}
|
||||
|
||||
func installCRD(clientset *kubernetes.Clientset, extensionsClient *apiextensionsclient.Clientset, args InstallFlags) {
|
||||
func installAppCRD(clientset *kubernetes.Clientset, extensionsClient *apiextensionsclient.Clientset, args InstallFlags) {
|
||||
applicationCRD := apiextensionsv1beta1.CustomResourceDefinition{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "apiextensions.k8s.io/v1alpha1",
|
||||
|
|
@ -62,22 +64,47 @@ func installCRD(clientset *kubernetes.Clientset, extensionsClient *apiextensions
|
|||
},
|
||||
},
|
||||
}
|
||||
if args.DryRun {
|
||||
printYAML(applicationCRD)
|
||||
createCRDHelper(clientset, extensionsClient, applicationCRD, args.DryRun)
|
||||
}
|
||||
|
||||
func installClusterCRD(clientset *kubernetes.Clientset, extensionsClient *apiextensionsclient.Clientset, args InstallFlags) {
|
||||
clusterCRD := apiextensionsv1beta1.CustomResourceDefinition{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "apiextensions.k8s.io/v1alpha1",
|
||||
Kind: "CustomResourceDefinition",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: cluster.FullName,
|
||||
},
|
||||
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
|
||||
Group: cluster.Group,
|
||||
Version: appv1.SchemeGroupVersion.Version,
|
||||
Scope: apiextensionsv1beta1.NamespaceScoped,
|
||||
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
|
||||
Plural: cluster.Plural,
|
||||
Kind: cluster.Kind,
|
||||
ShortNames: []string{cluster.ShortName},
|
||||
},
|
||||
},
|
||||
}
|
||||
createCRDHelper(clientset, extensionsClient, clusterCRD, args.DryRun)
|
||||
}
|
||||
|
||||
func createCRDHelper(clientset *kubernetes.Clientset, extensionsClient *apiextensionsclient.Clientset, crd apiextensionsv1beta1.CustomResourceDefinition, dryRun bool) {
|
||||
if dryRun {
|
||||
printYAML(crd)
|
||||
return
|
||||
}
|
||||
|
||||
_, err := extensionsClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(&applicationCRD)
|
||||
_, err := extensionsClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(&crd)
|
||||
if err != nil {
|
||||
if !apierr.IsAlreadyExists(err) {
|
||||
log.Fatalf("Failed to create CustomResourceDefinition: %v", err)
|
||||
}
|
||||
fmt.Printf("CustomResourceDefinition '%s' already exists\n", application.FullName)
|
||||
fmt.Printf("CustomResourceDefinition '%s' already exists\n", crd.ObjectMeta.Name)
|
||||
}
|
||||
// wait for CRD being established
|
||||
var crd *apiextensionsv1beta1.CustomResourceDefinition
|
||||
err = wait.Poll(500*time.Millisecond, 60*time.Second, func() (bool, error) {
|
||||
crd, err = extensionsClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(application.FullName, metav1.GetOptions{})
|
||||
_, err = extensionsClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(crd.ObjectMeta.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,5 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-ge
|
|||
|
||||
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
|
||||
github.com/argoproj/argo-cd/pkg/client github.com/argoproj/argo-cd/pkg/apis \
|
||||
application:v1alpha1 \
|
||||
"application:v1alpha1 cluster:v1alpha1" \
|
||||
--go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt
|
||||
|
|
|
|||
11
pkg/apis/cluster/register.go
Normal file
11
pkg/apis/cluster/register.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package cluster
|
||||
|
||||
// Application constants
|
||||
const (
|
||||
Kind string = "Cluster"
|
||||
Group string = "argoproj.io"
|
||||
Singular string = "cluster"
|
||||
Plural string = "clusters"
|
||||
ShortName string = "cluster"
|
||||
FullName string = Plural + "." + Group
|
||||
)
|
||||
5
pkg/apis/cluster/v1alpha1/doc.go
Normal file
5
pkg/apis/cluster/v1alpha1/doc.go
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Package v1alpha1 is the v1alpha1 version of the API.
|
||||
// +groupName=argoproj.io
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:openapi-gen=true
|
||||
package v1alpha1
|
||||
|
|
@ -11,6 +11,9 @@ import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
|
|||
option go_package = "v1alpha1";
|
||||
|
||||
// Cluster is the definition of a cluster resource
|
||||
// +genclient
|
||||
// +genclient:noStatus
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
message Cluster {
|
||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
|
||||
|
||||
|
|
@ -18,6 +21,7 @@ message Cluster {
|
|||
}
|
||||
|
||||
// ClusterList is a collection of Clusters.
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
message ClusterList {
|
||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
|
||||
|
||||
|
|
@ -26,6 +30,7 @@ message ClusterList {
|
|||
|
||||
// ClusterSpec is the cluster specification
|
||||
message ClusterSpec {
|
||||
// Server is the API server URL of the Kubernetes cluster
|
||||
optional string server = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,20 +5,25 @@ import (
|
|||
)
|
||||
|
||||
// Cluster is the definition of a cluster resource
|
||||
// +genclient
|
||||
// +genclient:noStatus
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type Cluster struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"`
|
||||
Spec ClusterSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
|
||||
}
|
||||
|
||||
// ClusterSpec is the cluster specification
|
||||
type ClusterSpec struct {
|
||||
Server string `json:"server" protobuf:"bytes,1,req,name=server"`
|
||||
}
|
||||
|
||||
// ClusterList is a collection of Clusters.
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type ClusterList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||
Items []Cluster `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||
}
|
||||
|
||||
// ClusterSpec is the cluster specification
|
||||
type ClusterSpec struct {
|
||||
// Server is the API server URL of the Kubernetes cluster
|
||||
Server string `json:"server" protobuf:"bytes,1,req,name=server"`
|
||||
}
|
||||
|
|
|
|||
85
pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go
Normal file
85
pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
// +build !ignore_autogenerated
|
||||
|
||||
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Cluster) DeepCopyInto(out *Cluster) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Cluster.
|
||||
func (in *Cluster) DeepCopy() *Cluster {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Cluster)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *Cluster) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterList) DeepCopyInto(out *ClusterList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]Cluster, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterList.
|
||||
func (in *ClusterList) DeepCopy() *ClusterList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ClusterList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSpec.
|
||||
func (in *ClusterSpec) DeepCopy() *ClusterSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package versioned
|
|||
|
||||
import (
|
||||
argoprojv1alpha1 "github.com/argoproj/argo-cd/pkg/client/clientset/versioned/typed/application/v1alpha1"
|
||||
argoprojv1alpha1 "github.com/argoproj/argo-cd/pkg/client/clientset/versioned/typed/cluster/v1alpha1"
|
||||
glog "github.com/golang/glog"
|
||||
discovery "k8s.io/client-go/discovery"
|
||||
rest "k8s.io/client-go/rest"
|
||||
|
|
@ -13,6 +14,9 @@ type Interface interface {
|
|||
ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface
|
||||
// Deprecated: please explicitly pick a version if possible.
|
||||
Argoproj() argoprojv1alpha1.ArgoprojV1alpha1Interface
|
||||
ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface
|
||||
// Deprecated: please explicitly pick a version if possible.
|
||||
Argoproj() argoprojv1alpha1.ArgoprojV1alpha1Interface
|
||||
}
|
||||
|
||||
// Clientset contains the clients for groups. Each group has exactly one
|
||||
|
|
@ -20,6 +24,18 @@ type Interface interface {
|
|||
type Clientset struct {
|
||||
*discovery.DiscoveryClient
|
||||
argoprojV1alpha1 *argoprojv1alpha1.ArgoprojV1alpha1Client
|
||||
argoprojV1alpha1 *argoprojv1alpha1.ArgoprojV1alpha1Client
|
||||
}
|
||||
|
||||
// ArgoprojV1alpha1 retrieves the ArgoprojV1alpha1Client
|
||||
func (c *Clientset) ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface {
|
||||
return c.argoprojV1alpha1
|
||||
}
|
||||
|
||||
// Deprecated: Argoproj retrieves the default version of ArgoprojClient.
|
||||
// Please explicitly pick a version.
|
||||
func (c *Clientset) Argoproj() argoprojv1alpha1.ArgoprojV1alpha1Interface {
|
||||
return c.argoprojV1alpha1
|
||||
}
|
||||
|
||||
// ArgoprojV1alpha1 retrieves the ArgoprojV1alpha1Client
|
||||
|
|
@ -53,6 +69,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cs.argoprojV1alpha1, err = argoprojv1alpha1.NewForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
|
||||
if err != nil {
|
||||
|
|
@ -67,6 +87,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) {
|
|||
func NewForConfigOrDie(c *rest.Config) *Clientset {
|
||||
var cs Clientset
|
||||
cs.argoprojV1alpha1 = argoprojv1alpha1.NewForConfigOrDie(c)
|
||||
cs.argoprojV1alpha1 = argoprojv1alpha1.NewForConfigOrDie(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
|
||||
return &cs
|
||||
|
|
@ -76,6 +97,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset {
|
|||
func New(c rest.Interface) *Clientset {
|
||||
var cs Clientset
|
||||
cs.argoprojV1alpha1 = argoprojv1alpha1.New(c)
|
||||
cs.argoprojV1alpha1 = argoprojv1alpha1.New(c)
|
||||
|
||||
cs.DiscoveryClient = discovery.NewDiscoveryClient(c)
|
||||
return &cs
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import (
|
|||
clientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned"
|
||||
argoprojv1alpha1 "github.com/argoproj/argo-cd/pkg/client/clientset/versioned/typed/application/v1alpha1"
|
||||
fakeargoprojv1alpha1 "github.com/argoproj/argo-cd/pkg/client/clientset/versioned/typed/application/v1alpha1/fake"
|
||||
argoprojv1alpha1 "github.com/argoproj/argo-cd/pkg/client/clientset/versioned/typed/cluster/v1alpha1"
|
||||
fakeargoprojv1alpha1 "github.com/argoproj/argo-cd/pkg/client/clientset/versioned/typed/cluster/v1alpha1/fake"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/discovery"
|
||||
|
|
@ -53,3 +55,13 @@ func (c *Clientset) ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interfac
|
|||
func (c *Clientset) Argoproj() argoprojv1alpha1.ArgoprojV1alpha1Interface {
|
||||
return &fakeargoprojv1alpha1.FakeArgoprojV1alpha1{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// ArgoprojV1alpha1 retrieves the ArgoprojV1alpha1Client
|
||||
func (c *Clientset) ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface {
|
||||
return &fakeargoprojv1alpha1.FakeArgoprojV1alpha1{Fake: &c.Fake}
|
||||
}
|
||||
|
||||
// Argoproj retrieves the ArgoprojV1alpha1Client
|
||||
func (c *Clientset) Argoproj() argoprojv1alpha1.ArgoprojV1alpha1Interface {
|
||||
return &fakeargoprojv1alpha1.FakeArgoprojV1alpha1{Fake: &c.Fake}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,5 +33,6 @@ func init() {
|
|||
// correctly.
|
||||
func AddToScheme(scheme *runtime.Scheme) {
|
||||
argoprojv1alpha1.AddToScheme(scheme)
|
||||
argoprojv1alpha1.AddToScheme(scheme)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,5 +33,6 @@ func init() {
|
|||
// correctly.
|
||||
func AddToScheme(scheme *runtime.Scheme) {
|
||||
argoprojv1alpha1.AddToScheme(scheme)
|
||||
argoprojv1alpha1.AddToScheme(scheme)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,67 @@
|
|||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/pkg/client/clientset/versioned/scheme"
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type ArgoprojV1alpha1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
}
|
||||
|
||||
// ArgoprojV1alpha1Client is used to interact with features provided by the argoproj.io group.
|
||||
type ArgoprojV1alpha1Client struct {
|
||||
restClient rest.Interface
|
||||
}
|
||||
|
||||
// NewForConfig creates a new ArgoprojV1alpha1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*ArgoprojV1alpha1Client, error) {
|
||||
config := *c
|
||||
if err := setConfigDefaults(&config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, err := rest.RESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ArgoprojV1alpha1Client{client}, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new ArgoprojV1alpha1Client for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *ArgoprojV1alpha1Client {
|
||||
client, err := NewForConfig(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// New creates a new ArgoprojV1alpha1Client for the given RESTClient.
|
||||
func New(c rest.Interface) *ArgoprojV1alpha1Client {
|
||||
return &ArgoprojV1alpha1Client{c}
|
||||
}
|
||||
|
||||
func setConfigDefaults(config *rest.Config) error {
|
||||
gv := v1alpha1.SchemeGroupVersion
|
||||
config.GroupVersion = &gv
|
||||
config.APIPath = "/apis"
|
||||
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
|
||||
|
||||
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 *ArgoprojV1alpha1Client) RESTClient() rest.Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.restClient
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,17 @@
|
|||
package fake
|
||||
|
||||
import (
|
||||
rest "k8s.io/client-go/rest"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
type FakeArgoprojV1alpha1 struct {
|
||||
*testing.Fake
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakeArgoprojV1alpha1) RESTClient() rest.Interface {
|
||||
var ret *rest.RESTClient
|
||||
return ret
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/pkg/client/clientset/versioned/scheme"
|
||||
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
type ArgoprojV1alpha1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
}
|
||||
|
||||
// ArgoprojV1alpha1Client is used to interact with features provided by the argoproj.io group.
|
||||
type ArgoprojV1alpha1Client struct {
|
||||
restClient rest.Interface
|
||||
}
|
||||
|
||||
// NewForConfig creates a new ArgoprojV1alpha1Client for the given config.
|
||||
func NewForConfig(c *rest.Config) (*ArgoprojV1alpha1Client, error) {
|
||||
config := *c
|
||||
if err := setConfigDefaults(&config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client, err := rest.RESTClientFor(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ArgoprojV1alpha1Client{client}, nil
|
||||
}
|
||||
|
||||
// NewForConfigOrDie creates a new ArgoprojV1alpha1Client for the given config and
|
||||
// panics if there is an error in the config.
|
||||
func NewForConfigOrDie(c *rest.Config) *ArgoprojV1alpha1Client {
|
||||
client, err := NewForConfig(c)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
// New creates a new ArgoprojV1alpha1Client for the given RESTClient.
|
||||
func New(c rest.Interface) *ArgoprojV1alpha1Client {
|
||||
return &ArgoprojV1alpha1Client{c}
|
||||
}
|
||||
|
||||
func setConfigDefaults(config *rest.Config) error {
|
||||
gv := v1alpha1.SchemeGroupVersion
|
||||
config.GroupVersion = &gv
|
||||
config.APIPath = "/apis"
|
||||
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
|
||||
|
||||
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 *ArgoprojV1alpha1Client) RESTClient() rest.Interface {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.restClient
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
// This package has the automatically generated typed clients.
|
||||
package v1alpha1
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
// Package fake has the automatically generated clients.
|
||||
package fake
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package fake
|
||||
|
||||
import (
|
||||
rest "k8s.io/client-go/rest"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
type FakeArgoprojV1alpha1 struct {
|
||||
*testing.Fake
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakeArgoprojV1alpha1) RESTClient() rest.Interface {
|
||||
var ret *rest.RESTClient
|
||||
return ret
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
package v1alpha1
|
||||
30
pkg/client/informers/externalversions/cluster/interface.go
Normal file
30
pkg/client/informers/externalversions/cluster/interface.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// This file was automatically generated by informer-gen
|
||||
|
||||
package argoproj
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/argoproj/argo-cd/pkg/client/informers/externalversions/cluster/v1alpha1"
|
||||
internalinterfaces "github.com/argoproj/argo-cd/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)
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
// This file was automatically generated by informer-gen
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
cluster_v1alpha1 "github.com/argoproj/argo-cd/pkg/apis/cluster/v1alpha1"
|
||||
versioned "github.com/argoproj/argo-cd/pkg/client/clientset/versioned"
|
||||
internalinterfaces "github.com/argoproj/argo-cd/pkg/client/informers/externalversions/internalinterfaces"
|
||||
v1alpha1 "github.com/argoproj/argo-cd/pkg/client/listers/cluster/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"
|
||||
)
|
||||
|
||||
// ClusterInformer provides access to a shared informer and lister for
|
||||
// Clusters.
|
||||
type ClusterInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1alpha1.ClusterLister
|
||||
}
|
||||
|
||||
type clusterInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewClusterInformer constructs a new informer for Cluster 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 NewClusterInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredClusterInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredClusterInformer constructs a new informer for Cluster 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 NewFilteredClusterInformer(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.ArgoprojV1alpha1().Clusters(namespace).List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.ArgoprojV1alpha1().Clusters(namespace).Watch(options)
|
||||
},
|
||||
},
|
||||
&cluster_v1alpha1.Cluster{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *clusterInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredClusterInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *clusterInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&cluster_v1alpha1.Cluster{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *clusterInformer) Lister() v1alpha1.ClusterLister {
|
||||
return v1alpha1.NewClusterLister(f.Informer().GetIndexer())
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// This file was automatically generated by informer-gen
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
internalinterfaces "github.com/argoproj/argo-cd/pkg/client/informers/externalversions/internalinterfaces"
|
||||
)
|
||||
|
||||
// Interface provides access to all the informers in this group version.
|
||||
type Interface interface {
|
||||
// Clusters returns a ClusterInformer.
|
||||
Clusters() ClusterInformer
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
||||
|
||||
// Clusters returns a ClusterInformer.
|
||||
func (v *version) Clusters() ClusterInformer {
|
||||
return &clusterInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
115
pkg/client/informers/externalversions/factory.go
Normal file
115
pkg/client/informers/externalversions/factory.go
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
// This file was automatically generated by informer-gen
|
||||
|
||||
package externalversions
|
||||
|
||||
import (
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
time "time"
|
||||
|
||||
versioned "github.com/argoproj/argo-cd/pkg/client/clientset/versioned"
|
||||
cluster "github.com/argoproj/argo-cd/pkg/client/informers/externalversions/cluster"
|
||||
internalinterfaces "github.com/argoproj/argo-cd/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"
|
||||
)
|
||||
|
||||
type sharedInformerFactory struct {
|
||||
client versioned.Interface
|
||||
namespace string
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
lock sync.Mutex
|
||||
defaultResync 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
|
||||
}
|
||||
|
||||
// NewSharedInformerFactory constructs a new instance of sharedInformerFactory
|
||||
func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory {
|
||||
return NewFilteredSharedInformerFactory(client, defaultResync, v1.NamespaceAll, nil)
|
||||
}
|
||||
|
||||
// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory.
|
||||
// Listers obtained via this SharedInformerFactory will be subject to the same filters
|
||||
// as specified here.
|
||||
func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory {
|
||||
return &sharedInformerFactory{
|
||||
client: client,
|
||||
namespace: namespace,
|
||||
tweakListOptions: tweakListOptions,
|
||||
defaultResync: defaultResync,
|
||||
informers: make(map[reflect.Type]cache.SharedIndexInformer),
|
||||
startedInformers: make(map[reflect.Type]bool),
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
informer = newFunc(f.client, f.defaultResync)
|
||||
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
|
||||
|
||||
Argoproj() cluster.Interface
|
||||
}
|
||||
|
||||
func (f *sharedInformerFactory) Argoproj() cluster.Interface {
|
||||
return cluster.New(f, f.namespace, f.tweakListOptions)
|
||||
}
|
||||
46
pkg/client/informers/externalversions/generic.go
Normal file
46
pkg/client/informers/externalversions/generic.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// This file was automatically generated by informer-gen
|
||||
|
||||
package externalversions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
v1alpha1 "github.com/argoproj/argo-cd/pkg/apis/cluster/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=argoproj.io, Version=v1alpha1
|
||||
case v1alpha1.SchemeGroupVersion.WithResource("clusters"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Argoproj().V1alpha1().Clusters().Informer()}, nil
|
||||
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("no informer found for %v", resource)
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// This file was automatically generated by informer-gen
|
||||
|
||||
package internalinterfaces
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
versioned "github.com/argoproj/argo-cd/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"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
type TweakListOptionsFunc func(*v1.ListOptions)
|
||||
78
pkg/client/listers/cluster/v1alpha1/cluster.go
Normal file
78
pkg/client/listers/cluster/v1alpha1/cluster.go
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
// This file was automatically generated by lister-gen
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/argoproj/argo-cd/pkg/apis/cluster/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// ClusterLister helps list Clusters.
|
||||
type ClusterLister interface {
|
||||
// List lists all Clusters in the indexer.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.Cluster, err error)
|
||||
// Clusters returns an object that can list and get Clusters.
|
||||
Clusters(namespace string) ClusterNamespaceLister
|
||||
ClusterListerExpansion
|
||||
}
|
||||
|
||||
// clusterLister implements the ClusterLister interface.
|
||||
type clusterLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewClusterLister returns a new ClusterLister.
|
||||
func NewClusterLister(indexer cache.Indexer) ClusterLister {
|
||||
return &clusterLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all Clusters in the indexer.
|
||||
func (s *clusterLister) List(selector labels.Selector) (ret []*v1alpha1.Cluster, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.Cluster))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Clusters returns an object that can list and get Clusters.
|
||||
func (s *clusterLister) Clusters(namespace string) ClusterNamespaceLister {
|
||||
return clusterNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
}
|
||||
|
||||
// ClusterNamespaceLister helps list and get Clusters.
|
||||
type ClusterNamespaceLister interface {
|
||||
// List lists all Clusters in the indexer for a given namespace.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.Cluster, err error)
|
||||
// Get retrieves the Cluster from the indexer for a given namespace and name.
|
||||
Get(name string) (*v1alpha1.Cluster, error)
|
||||
ClusterNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// clusterNamespaceLister implements the ClusterNamespaceLister
|
||||
// interface.
|
||||
type clusterNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all Clusters in the indexer for a given namespace.
|
||||
func (s clusterNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Cluster, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.Cluster))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the Cluster from the indexer for a given namespace and name.
|
||||
func (s clusterNamespaceLister) Get(name string) (*v1alpha1.Cluster, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1alpha1.Resource("cluster"), name)
|
||||
}
|
||||
return obj.(*v1alpha1.Cluster), nil
|
||||
}
|
||||
11
pkg/client/listers/cluster/v1alpha1/expansion_generated.go
Normal file
11
pkg/client/listers/cluster/v1alpha1/expansion_generated.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// This file was automatically generated by lister-gen
|
||||
|
||||
package v1alpha1
|
||||
|
||||
// ClusterListerExpansion allows custom methods to be added to
|
||||
// ClusterLister.
|
||||
type ClusterListerExpansion interface{}
|
||||
|
||||
// ClusterNamespaceListerExpansion allows custom methods to be added to
|
||||
// ClusterNamespaceLister.
|
||||
type ClusterNamespaceListerExpansion interface{}
|
||||
Loading…
Reference in a new issue