Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rancher: reset Id for unknown resources #11543

Merged
merged 1 commit into from
Jan 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions builtin/providers/rancher/resource_rancher_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ func resourceRancherEnvironmentRead(d *schema.ResourceData, meta interface{}) er
return err
}

if env == nil {
log.Printf("[INFO] Environment %s not found", d.Id())
d.SetId("")
return nil
}

log.Printf("[INFO] Environment Name: %s", env.Name)

d.Set("description", env.Description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ func resourceRancherRegistrationTokenRead(d *schema.ResourceData, meta interface
return err
}

if regT == nil {
log.Printf("[INFO] RegistrationToken %s not found", d.Id())
d.SetId("")
return nil
}

log.Printf("[INFO] RegistrationToken Name: %s", regT.Name)

d.Set("description", regT.Description)
Expand Down
6 changes: 6 additions & 0 deletions builtin/providers/rancher/resource_rancher_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func resourceRancherRegistryRead(d *schema.ResourceData, meta interface{}) error
return err
}

if registry == nil {
log.Printf("[INFO] Registry %s not found", d.Id())
d.SetId("")
return nil
}

log.Printf("[INFO] Registry Name: %s", registry.Name)

d.Set("description", registry.Description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ func resourceRancherRegistryCredentialRead(d *schema.ResourceData, meta interfac
return err
}

if registryCred == nil {
log.Printf("[INFO] RegistryCredential %s not found", d.Id())
d.SetId("")
return nil
}

log.Printf("[INFO] RegistryCredential Name: %s", registryCred.Name)

d.Set("description", registryCred.Description)
Expand Down
6 changes: 6 additions & 0 deletions builtin/providers/rancher/resource_rancher_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ func resourceRancherStackRead(d *schema.ResourceData, meta interface{}) error {
return err
}

if stack == nil {
log.Printf("[INFO] Stack %s not found", d.Id())
d.SetId("")
return nil
}

if stack.State == "removed" {
log.Printf("[INFO] Stack %s was removed on %v", d.Id(), stack.Removed)
d.SetId("")
Expand Down