diff --git a/pkg/addons/default/aws_node.go b/pkg/addons/default/aws_node.go index 78cac629f5..ae0e6d367d 100644 --- a/pkg/addons/default/aws_node.go +++ b/pkg/addons/default/aws_node.go @@ -45,7 +45,8 @@ func UpdateAWSNode(rawClient kubernetes.RawClientInterface, region string, plan if err != nil { return false, err } - if resource.GVK.Kind == "DaemonSet" { + switch resource.GVK.Kind { + case "DaemonSet": daemonSet, ok := resource.Info.Object.(*appsv1.DaemonSet) if !ok { return false, fmt.Errorf("expected type %T; got %T", &appsv1.Deployment{}, resource.Info.Object) @@ -67,18 +68,16 @@ func UpdateAWSNode(rawClient kubernetes.RawClientInterface, region string, plan if err != nil { return false, err } - } - - if resource.GVK.Kind == "CustomResourceDefinition" && plan { - // eniconfigs.crd.k8s.amazonaws.com CRD is only partially defined in the - // manifest, and causes a range of issue in plan mode, we can skip it - logger.Info(resource.LogAction(plan, "replaced")) - continue - } - - // Leave service account if it exists - // to avoid overwriting annotations - if resource.GVK.Kind == "ServiceAccount" { + case "CustomResourceDefinition": + if plan { + // eniconfigs.crd.k8s.amazonaws.com CRD is only partially defined in the + // manifest, and causes a range of issue in plan mode, we can skip it + logger.Info(resource.LogAction(plan, "replaced")) + continue + } + case "ServiceAccount": + // Leave service account if it exists + // to avoid overwriting annotations _, exists, err := resource.Get() if err != nil { return false, err