github.com/argoproj-labs/argocd-operator@v0.10.0/controllers/argocdexport/reconcile.go (about)

     1  // Copyright 2019 ArgoCD Operator Developers
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  // 	http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package argocdexport
    16  
    17  import (
    18  	batchv1 "k8s.io/api/batch/v1"
    19  	corev1 "k8s.io/api/core/v1"
    20  	"sigs.k8s.io/controller-runtime/pkg/builder"
    21  
    22  	argoproj "github.com/argoproj-labs/argocd-operator/api/v1alpha1"
    23  )
    24  
    25  // reconcileArgoCDExportResources will reconcile all ArgoCDExport resources for the give CR.
    26  func (r *ReconcileArgoCDExport) reconcileArgoCDExportResources(cr *argoproj.ArgoCDExport) error {
    27  	if err := r.validateExport(cr); err != nil {
    28  		return err
    29  	}
    30  
    31  	if err := r.reconcileStorage(cr); err != nil {
    32  		return err
    33  	}
    34  
    35  	if err := r.reconcileExport(cr); err != nil {
    36  		return err
    37  	}
    38  	return nil
    39  }
    40  
    41  // setResourceWatches will register Watches for each of the supported Resources.
    42  func setResourceWatches(bld *builder.Builder) *builder.Builder {
    43  	// Watch for changes to primary resource ArgoCDExport
    44  	bld.For(&argoproj.ArgoCDExport{})
    45  
    46  	// Watch for changes to CronJob sub-resources owned by ArgoCDExport instances.
    47  	bld.Owns(&batchv1.CronJob{})
    48  
    49  	// Watch for changes to Job sub-resources owned by ArgoCD instances.
    50  	bld.Owns(&batchv1.Job{})
    51  
    52  	// Watch for changes to PersistentVolumeClaim sub-resources owned by ArgoCD instances.
    53  	bld.Owns(&corev1.PersistentVolumeClaim{})
    54  
    55  	// Watch for changes to Secret sub-resources owned by ArgoCD instances.
    56  	bld.Owns(&corev1.Secret{})
    57  
    58  	return bld
    59  }