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

Fix namespacing on kubernetes_priority_class #682

Merged
merged 1 commit into from
Nov 11, 2019
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
28 changes: 8 additions & 20 deletions kubernetes/resource_kubernetes_priority_class.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,15 @@ func resourceKubernetesPriorityClassCreate(d *schema.ResourceData, meta interfac
return fmt.Errorf("Failed to create priority class: %s", err)
}
log.Printf("[INFO] Submitted new priority class: %#v", out)
d.SetId(buildId(out.ObjectMeta))
d.SetId(out.ObjectMeta.Name)

return resourceKubernetesPriorityClassRead(d, meta)
}

func resourceKubernetesPriorityClassRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*KubeClientsets).MainClientset

_, name, err := idParts(d.Id())
if err != nil {
return err
}
name := d.Id()

log.Printf("[INFO] Reading priority class %s", name)
priorityClass, err := conn.SchedulingV1().PriorityClasses().Get(name, meta_v1.GetOptions{})
Expand Down Expand Up @@ -114,10 +111,7 @@ func resourceKubernetesPriorityClassRead(d *schema.ResourceData, meta interface{
func resourceKubernetesPriorityClassUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*KubeClientsets).MainClientset

_, name, err := idParts(d.Id())
if err != nil {
return err
}
name := d.Id()

ops := patchMetadata("metadata.0.", "/metadata/", d)

Expand Down Expand Up @@ -147,21 +141,18 @@ func resourceKubernetesPriorityClassUpdate(d *schema.ResourceData, meta interfac
return fmt.Errorf("Failed to update priority class: %s", err)
}
log.Printf("[INFO] Submitted updated priority class: %#v", out)
d.SetId(buildId(out.ObjectMeta))
d.SetId(out.ObjectMeta.Name)

return resourceKubernetesPriorityClassRead(d, meta)
}

func resourceKubernetesPriorityClassDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*KubeClientsets).MainClientset

_, name, err := idParts(d.Id())
if err != nil {
return err
}
name := d.Id()

log.Printf("[INFO] Deleting priority class: %#v", name)
err = conn.SchedulingV1().PriorityClasses().Delete(name, &meta_v1.DeleteOptions{})
err := conn.SchedulingV1().PriorityClasses().Delete(name, &meta_v1.DeleteOptions{})
if err != nil {
return err
}
Expand All @@ -175,13 +166,10 @@ func resourceKubernetesPriorityClassDelete(d *schema.ResourceData, meta interfac
func resourceKubernetesPriorityClassExists(d *schema.ResourceData, meta interface{}) (bool, error) {
conn := meta.(*KubeClientsets).MainClientset

_, name, err := idParts(d.Id())
if err != nil {
return false, err
}
name := d.Id()

log.Printf("[INFO] Checking priority class %s", name)
_, err = conn.SchedulingV1().PriorityClasses().Get(name, meta_v1.GetOptions{})
_, err := conn.SchedulingV1().PriorityClasses().Get(name, meta_v1.GetOptions{})
if err != nil {
if statusErr, ok := err.(*errors.StatusError); ok && statusErr.ErrStatus.Code == 404 {
return false, nil
Expand Down
10 changes: 2 additions & 8 deletions kubernetes/resource_kubernetes_priority_class_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ func testAccCheckKubernetesPriorityClassDestroy(s *terraform.State) error {
continue
}

_, name, err := idParts(rs.Primary.ID)
if err != nil {
return err
}
name := rs.Primary.ID

resp, err := conn.SchedulingV1().PriorityClasses().Get(name, meta_v1.GetOptions{})
if err == nil {
Expand All @@ -169,10 +166,7 @@ func testAccCheckKubernetesPriorityClassExists(n string, obj *api.PriorityClass)

conn := testAccProvider.Meta().(*KubeClientsets).MainClientset

_, name, err := idParts(rs.Primary.ID)
if err != nil {
return err
}
name := rs.Primary.ID

out, err := conn.SchedulingV1().PriorityClasses().Get(name, meta_v1.GetOptions{})
if err != nil {
Expand Down