@@ -120,14 +120,14 @@ func (o *Options) approveCSR(kubeClient *kubernetes.Clientset, clusterName strin
120120 }
121121 //Check if already approved or denied
122122 approved , denied := GetCertApprovalCondition (& item .Status )
123- if approved {
124- fmt .Printf ("CSR %s already approved\n " , item .Name )
125- }
123+ //if alreaady denied, then nothing to do
126124 if denied {
127125 fmt .Printf ("CSR %s already denied\n " , item .Name )
126+ return true , nil
128127 }
129- //if alreaady approved or denied, then nothing to do
130- if approved || denied {
128+ //if alreaady approved, then nothing to do
129+ if approved {
130+ fmt .Printf ("CSR %s already approved\n " , item .Name )
131131 return true , nil
132132 }
133133 csr = & item
@@ -178,17 +178,20 @@ func (o *Options) updateManagedCluster(clusterClient *clusterclientset.Clientset
178178 }
179179 return false , err
180180 }
181+ if mc .Spec .HubAcceptsClient {
182+ fmt .Printf ("httpAcceptsClient already set for cluster %s\n " , clusterName )
183+ return true , nil
184+ }
185+ if o .ClusteradmFlags .DryRun {
186+ return true , nil
187+ }
181188 if ! mc .Spec .HubAcceptsClient {
182- if ! o .ClusteradmFlags .DryRun {
183- mc .Spec .HubAcceptsClient = true
184- _ , err = clusterClient .ClusterV1 ().ManagedClusters ().Update (context .TODO (), mc , metav1.UpdateOptions {})
185- if err != nil {
186- return false , err
187- }
188- fmt .Printf ("set httpAcceptsClient to true for cluster %s\n " , clusterName )
189+ mc .Spec .HubAcceptsClient = true
190+ _ , err = clusterClient .ClusterV1 ().ManagedClusters ().Update (context .TODO (), mc , metav1.UpdateOptions {})
191+ if err != nil {
192+ return false , err
189193 }
190- } else {
191- fmt .Printf ("httpAcceptsClient already set for cluster %s\n " , clusterName )
194+ fmt .Printf ("set httpAcceptsClient to true for cluster %s\n " , clusterName )
192195 }
193196 return true , nil
194197}
0 commit comments