Skip to content

Commit

Permalink
Merge pull request #89 from kbst/fix-import-terminating
Browse files Browse the repository at this point in the history
Refuse to import resources without LastAppliedConfigAnnotation fix #85
  • Loading branch information
pst authored Feb 25, 2021
2 parents 2e47161 + 350e56e commit 39ed0e8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion kustomize/resource_kustomization.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,14 @@ func kustomizationResourceImport(d *schema.ResourceData, m interface{}) ([]*sche
id := string(resp.GetUID())
d.SetId(id)

d.Set("manifest", getLastAppliedConfig(resp))
lac := getLastAppliedConfig(resp)
if lac == "" {
return nil, logError(
fmt.Errorf("apiVersion: %q, kind: %q, namespace: %q, name: %q: can not import resources without %q annotation", gvk.GroupVersion(), gvk.Kind, namespace, name, lastAppliedConfig),
)
}

d.Set("manifest", lac)

return []*schema.ResourceData{d}, nil
}

0 comments on commit 39ed0e8

Please sign in to comment.