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

Add a limited generic YAML resource to the provider #195

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix typo in error messages
lawrencegripper committed Oct 26, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 17762f7429060b0d72b7236946c1620a1139162c
12 changes: 6 additions & 6 deletions kubernetes/resource_kubernetes_yaml.go
Original file line number Diff line number Diff line change
@@ -96,14 +96,14 @@ func resourceKubernetesYAMLCreate(d *schema.ResourceData, meta interface{}) erro
// defined in the YAML
client, absPath, rawObj, err := getRestClientFromYaml(yaml, meta.(KubeProvider))
if err != nil {
return fmt.Errorf("failed to create kuberentes rest client for resource: %+v", err)
return fmt.Errorf("failed to create kubernetes rest client for resource: %+v", err)
}
metaObj := &meta_v1beta1.PartialObjectMetadata{}

// Create the resource in Kubernetes
err = client.Post().AbsPath(absPath["POST"]).Body(rawObj).Do().Into(metaObj)
if err != nil {
return fmt.Errorf("failed to create resource in kuberentes: %+v", err)
return fmt.Errorf("failed to create resource in kubernetes: %+v", err)
}

d.SetId(metaObj.GetSelfLink())
@@ -123,7 +123,7 @@ func resourceKubernetesYAMLRead(d *schema.ResourceData, meta interface{}) error
// defined in the YAML
client, absPaths, _, err := getRestClientFromYaml(yaml, meta.(KubeProvider))
if err != nil {
return fmt.Errorf("failed to create kuberentes rest client for resource: %+v", err)
return fmt.Errorf("failed to create kubernetes rest client for resource: %+v", err)
}

// Get the resource from Kubernetes
@@ -151,13 +151,13 @@ func resourceKubernetesYAMLDelete(d *schema.ResourceData, meta interface{}) erro

client, absPaths, _, err := getRestClientFromYaml(yaml, meta.(KubeProvider))
if err != nil {
return fmt.Errorf("failed to create kuberentes rest client for resource: %+v", err)
return fmt.Errorf("failed to create kubernetes rest client for resource: %+v", err)
}

metaObj := &meta_v1beta1.PartialObjectMetadata{}
err = client.Delete().AbsPath(absPaths["DELETE"]).Do().Into(metaObj)
if err != nil {
return fmt.Errorf("failed to delete kuberentes resource '%s': %+v", metaObj.SelfLink, err)
return fmt.Errorf("failed to delete kubernetes resource '%s': %+v", metaObj.SelfLink, err)
}

// Success remove it from state
@@ -179,7 +179,7 @@ func resourceKubernetesYAMLExists(d *schema.ResourceData, meta interface{}) (boo

client, absPaths, _, err := getRestClientFromYaml(yaml, meta.(KubeProvider))
if err != nil {
return false, fmt.Errorf("failed to create kuberentes rest client for resource: %+v", err)
return false, fmt.Errorf("failed to create kubernetes rest client for resource: %+v", err)
}

metaObj, exists, err := getResourceFromK8s(client, absPaths)