@@ -411,20 +411,31 @@ func createOrUpdateArgoCD(client dynamic.Interface, fullClient kubernetes.Interf
411411
412412 if ! haveArgo (client , name , namespace ) {
413413 // create it
414- obj , _ := runtime .DefaultUnstructuredConverter .ToUnstructured (argo )
414+ obj , errConvert := runtime .DefaultUnstructuredConverter .ToUnstructured (argo )
415+ if errConvert != nil {
416+ return fmt .Errorf ("failed to convert ArgoCD to unstructured for create: %v" , errConvert )
417+ }
415418 newArgo := & unstructured.Unstructured {Object : obj }
416419 _ , err = client .Resource (gvr ).Namespace (namespace ).Create (context .TODO (), newArgo , metav1.CreateOptions {})
417420 } else { // update it
418- oldArgo , _ := getArgoCD (client , name , namespace )
421+ oldArgo , errGet := getArgoCDFunc (client , name , namespace )
422+ if errGet != nil {
423+ return fmt .Errorf ("failed to get existing ArgoCD %s/%s: %v" , namespace , name , errGet )
424+ }
419425 argo .SetResourceVersion (oldArgo .GetResourceVersion ())
420- obj , _ := runtime .DefaultUnstructuredConverter .ToUnstructured (argo )
426+ obj , errConvert := runtime .DefaultUnstructuredConverter .ToUnstructured (argo )
427+ if errConvert != nil {
428+ return fmt .Errorf ("failed to convert ArgoCD to unstructured for update: %v" , errConvert )
429+ }
421430 newArgo := & unstructured.Unstructured {Object : obj }
422431
423432 _ , err = client .Resource (gvr ).Namespace (namespace ).Update (context .TODO (), newArgo , metav1.UpdateOptions {})
424433 }
425434 return err
426435}
427436
437+ var getArgoCDFunc = getArgoCD
438+
428439func getArgoCD (client dynamic.Interface , name , namespace string ) (* argooperator.ArgoCD , error ) {
429440 gvr := schema.GroupVersionResource {Group : ArgoCDGroup , Version : ArgoCDVersion , Resource : ArgoCDResource }
430441 argo := & argooperator.ArgoCD {}
@@ -705,9 +716,10 @@ func commonApplicationSourceHelm(p *api.Pattern, prefix string) *argoapi.Applica
705716 valueFiles := newApplicationValueFiles (p , prefix )
706717 sharedValueFiles , err := getSharedValueFiles (p , prefix )
707718 if err != nil {
708- fmt .Printf ("Could not fetch sharedValueFiles: %s" , err )
719+ log .Printf ("Could not fetch sharedValueFiles: %s" , err )
720+ } else {
721+ valueFiles = append (valueFiles , sharedValueFiles ... )
709722 }
710- valueFiles = append (valueFiles , sharedValueFiles ... )
711723
712724 return & argoapi.ApplicationSourceHelm {
713725 ValueFiles : valueFiles ,
@@ -910,9 +922,12 @@ func getApplication(client argoclient.Interface, name, namespace string) (*argoa
910922
911923func createApplication (client argoclient.Interface , app * argoapi.Application , namespace string ) error {
912924 saved , err := client .ArgoprojV1alpha1 ().Applications (namespace ).Create (context .Background (), app , metav1.CreateOptions {})
925+ if err != nil {
926+ return err
927+ }
913928 yamlOutput , _ := objectYaml (saved )
914929 log .Printf ("Created: %s\n " , yamlOutput )
915- return err
930+ return nil
916931}
917932
918933func updateApplication (client argoclient.Interface , target , current * argoapi.Application , namespace string ) (bool , error ) {
0 commit comments