forked from hashicorp/terraform-provider-chef
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad6dba0
commit d340de4
Showing
77 changed files
with
1,297 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "chef_node Data Source - terraform-provider-chef" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# chef_node (Data Source) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) | ||
|
||
### Read-Only | ||
|
||
- `automatic_attributes_json` (String) | ||
- `default_attributes_json` (String) | ||
- `environment_name` (String) | ||
- `id` (String) The ID of this resource. | ||
- `normal_attributes_json` (String) | ||
- `override_attributes_json` (String) | ||
- `run_list` (List of String) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package provider | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataChefNode() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: ReadNode, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"name": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"environment_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"automatic_attributes_json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"normal_attributes_json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"default_attributes_json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"override_attributes_json": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"run_list": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
StateFunc: runListEntryStateFunc, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package provider | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"testing" | ||
|
||
chefc "github.com/go-chef/chef" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
) | ||
|
||
func TestAccDataNode_basic(t *testing.T) { | ||
var node chefc.Node | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: providerFactories, | ||
CheckDestroy: testAccNodeCheckDestroy(&node), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataNodeConfig_basic, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccNodeCheckExists("data.chef_node.test", &node), | ||
func(s *terraform.State) error { | ||
|
||
if expected := "terraform-acc-test-basic"; node.Name != expected { | ||
return fmt.Errorf("wrong name; expected %v, got %v", expected, node.Name) | ||
} | ||
if expected := "terraform-acc-test-node-basic"; node.Environment != expected { | ||
return fmt.Errorf("wrong environment; expected %v, got %v", expected, node.Environment) | ||
} | ||
|
||
expectedRunList := []string{ | ||
"recipe[[email protected]]", | ||
"recipe[consul]", | ||
"role[foo]", | ||
} | ||
if !reflect.DeepEqual(node.RunList, expectedRunList) { | ||
return fmt.Errorf("wrong runlist; expected %#v, got %#v", expectedRunList, node.RunList) | ||
} | ||
|
||
expectedAttributes := map[string]interface{}{ | ||
"terraform_acc_test": true, | ||
} | ||
if !reflect.DeepEqual(node.AutomaticAttributes, expectedAttributes) { | ||
return fmt.Errorf("wrong automatic attributes; expected %#v, got %#v", expectedAttributes, node.AutomaticAttributes) | ||
} | ||
if !reflect.DeepEqual(node.NormalAttributes, expectedAttributes) { | ||
return fmt.Errorf("wrong normal attributes; expected %#v, got %#v", expectedAttributes, node.NormalAttributes) | ||
} | ||
if !reflect.DeepEqual(node.DefaultAttributes, expectedAttributes) { | ||
return fmt.Errorf("wrong default attributes; expected %#v, got %#v", expectedAttributes, node.DefaultAttributes) | ||
} | ||
if !reflect.DeepEqual(node.OverrideAttributes, expectedAttributes) { | ||
return fmt.Errorf("wrong override attributes; expected %#v, got %#v", expectedAttributes, node.OverrideAttributes) | ||
} | ||
|
||
return nil | ||
}, | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccDataNodeConfig_basic = ` | ||
resource "chef_node" "test" { | ||
name = "terraform-acc-test-basic" | ||
environment_name = "terraform-acc-test-node-basic" | ||
automatic_attributes_json = <<EOT | ||
{ | ||
"terraform_acc_test": true | ||
} | ||
EOT | ||
normal_attributes_json = <<EOT | ||
{ | ||
"terraform_acc_test": true | ||
} | ||
EOT | ||
default_attributes_json = <<EOT | ||
{ | ||
"terraform_acc_test": true | ||
} | ||
EOT | ||
override_attributes_json = <<EOT | ||
{ | ||
"terraform_acc_test": true | ||
} | ||
EOT | ||
run_list = ["[email protected]", "recipe[consul]", "role[foo]"] | ||
} | ||
data "chef_node" "test" { | ||
name = chef_node.test.id | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.