github.com/argoproj/argo-cd/v3@v3.2.1/server/application/deepinformer.go (about)

     1  package application
     2  
     3  import (
     4  	"context"
     5  
     6  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     7  	"k8s.io/client-go/rest"
     8  
     9  	"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
    10  	appclientset "github.com/argoproj/argo-cd/v3/pkg/client/clientset/versioned"
    11  	argoprojv1alpha1 "github.com/argoproj/argo-cd/v3/pkg/client/clientset/versioned/typed/application/v1alpha1"
    12  	applisters "github.com/argoproj/argo-cd/v3/pkg/client/listers/application/v1alpha1"
    13  	"github.com/argoproj/argo-cd/v3/util"
    14  
    15  	"k8s.io/apimachinery/pkg/labels"
    16  )
    17  
    18  // deepCopyApplicationLister wraps an ApplicationLister and returns deep copies of the applications.
    19  type deepCopyApplicationLister struct {
    20  	applisters.ApplicationLister
    21  }
    22  
    23  // List lists all Applications in the indexer and returns deep copies.
    24  func (d *deepCopyApplicationLister) List(selector labels.Selector) ([]*v1alpha1.Application, error) {
    25  	apps, err := d.ApplicationLister.List(selector)
    26  	if err != nil {
    27  		return nil, err
    28  	}
    29  	deepCopiedApps := util.SliceCopy(apps)
    30  	return deepCopiedApps, nil
    31  }
    32  
    33  // Applications return an object that can list and get Applications and returns deep copies.
    34  func (d *deepCopyApplicationLister) Applications(namespace string) applisters.ApplicationNamespaceLister {
    35  	return &deepCopyApplicationNamespaceLister{
    36  		ApplicationNamespaceLister: d.ApplicationLister.Applications(namespace),
    37  	}
    38  }
    39  
    40  // deepCopyApplicationNamespaceLister wraps an ApplicationNamespaceLister and returns deep copies of the applications.
    41  type deepCopyApplicationNamespaceLister struct {
    42  	applisters.ApplicationNamespaceLister
    43  }
    44  
    45  // List lists all Applications in the indexer for a given namespace and returns deep copies.
    46  func (d *deepCopyApplicationNamespaceLister) List(selector labels.Selector) ([]*v1alpha1.Application, error) {
    47  	apps, err := d.ApplicationNamespaceLister.List(selector)
    48  	if err != nil {
    49  		return nil, err
    50  	}
    51  	deepCopiedApps := util.SliceCopy(apps)
    52  	return deepCopiedApps, nil
    53  }
    54  
    55  // Get retrieves the Application from the indexer for a given namespace and name and returns a deep copy.
    56  func (d *deepCopyApplicationNamespaceLister) Get(name string) (*v1alpha1.Application, error) {
    57  	app, err := d.ApplicationNamespaceLister.Get(name)
    58  	if err != nil {
    59  		return nil, err
    60  	}
    61  	return app.DeepCopy(), nil
    62  }
    63  
    64  type deepCopyAppClientset struct {
    65  	appclientset.Interface
    66  }
    67  
    68  func (d *deepCopyAppClientset) ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface {
    69  	return &deepCopyArgoprojV1alpha1Client{
    70  		ArgoprojV1alpha1Interface: d.Interface.ArgoprojV1alpha1(),
    71  	}
    72  }
    73  
    74  // GetUnderlyingClientSet returns the underlying clientset.Interface.
    75  // Unit tests should only call this
    76  func (d *deepCopyAppClientset) GetUnderlyingClientSet() appclientset.Interface {
    77  	return d.Interface
    78  }
    79  
    80  type deepCopyArgoprojV1alpha1Client struct {
    81  	argoprojv1alpha1.ArgoprojV1alpha1Interface
    82  }
    83  
    84  func (d *deepCopyArgoprojV1alpha1Client) RESTClient() rest.Interface {
    85  	return d.ArgoprojV1alpha1Interface.RESTClient()
    86  }
    87  
    88  func (d *deepCopyArgoprojV1alpha1Client) AppProjects(namespace string) argoprojv1alpha1.AppProjectInterface {
    89  	return &deepCopyAppProjectClient{
    90  		AppProjectInterface: d.ArgoprojV1alpha1Interface.AppProjects(namespace),
    91  	}
    92  }
    93  
    94  func (d *deepCopyArgoprojV1alpha1Client) ApplicationSets(namespace string) argoprojv1alpha1.ApplicationSetInterface {
    95  	return &deepCopyApplicationSetClient{
    96  		ApplicationSetInterface: d.ArgoprojV1alpha1Interface.ApplicationSets(namespace),
    97  	}
    98  }
    99  
   100  func (d *deepCopyArgoprojV1alpha1Client) Applications(namespace string) argoprojv1alpha1.ApplicationInterface {
   101  	return &deepCopyApplicationClient{
   102  		ApplicationInterface: d.ArgoprojV1alpha1Interface.Applications(namespace),
   103  	}
   104  }
   105  
   106  type deepCopyApplicationClient struct {
   107  	argoprojv1alpha1.ApplicationInterface
   108  }
   109  
   110  func (d *deepCopyApplicationClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*v1alpha1.Application, error) {
   111  	app, err := d.ApplicationInterface.Get(ctx, name, options)
   112  	if err != nil {
   113  		return nil, err
   114  	}
   115  	return app.DeepCopy(), nil
   116  }
   117  
   118  func (d *deepCopyApplicationClient) List(ctx context.Context, opts metav1.ListOptions) (*v1alpha1.ApplicationList, error) {
   119  	appList, err := d.ApplicationInterface.List(ctx, opts)
   120  	if err != nil {
   121  		return nil, err
   122  	}
   123  	return appList.DeepCopy(), nil
   124  }
   125  
   126  type deepCopyAppProjectClient struct {
   127  	argoprojv1alpha1.AppProjectInterface
   128  }
   129  
   130  func (d *deepCopyAppProjectClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*v1alpha1.AppProject, error) {
   131  	appProject, err := d.AppProjectInterface.Get(ctx, name, options)
   132  	if err != nil {
   133  		return nil, err
   134  	}
   135  	return appProject.DeepCopy(), nil
   136  }
   137  
   138  func (d *deepCopyAppProjectClient) List(ctx context.Context, opts metav1.ListOptions) (*v1alpha1.AppProjectList, error) {
   139  	appProjectList, err := d.AppProjectInterface.List(ctx, opts)
   140  	if err != nil {
   141  		return nil, err
   142  	}
   143  	return appProjectList.DeepCopy(), nil
   144  }
   145  
   146  type deepCopyApplicationSetClient struct {
   147  	argoprojv1alpha1.ApplicationSetInterface
   148  }
   149  
   150  func (d *deepCopyApplicationSetClient) Get(ctx context.Context, name string, options metav1.GetOptions) (*v1alpha1.ApplicationSet, error) {
   151  	appSet, err := d.ApplicationSetInterface.Get(ctx, name, options)
   152  	if err != nil {
   153  		return nil, err
   154  	}
   155  	return appSet.DeepCopy(), nil
   156  }
   157  
   158  func (d *deepCopyApplicationSetClient) List(ctx context.Context, opts metav1.ListOptions) (*v1alpha1.ApplicationSetList, error) {
   159  	appSetList, err := d.ApplicationSetInterface.List(ctx, opts)
   160  	if err != nil {
   161  		return nil, err
   162  	}
   163  	return appSetList.DeepCopy(), nil
   164  }