-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
f10e589
commit c4fc230
Showing
5 changed files
with
132 additions
and
6 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,41 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "gocd_plugin_setting Data Source - terraform-provider-gocd" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# gocd_plugin_setting (Data Source) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `configuration` (Block List) List of configuration required to configure the plugin settings. (see [below for nested schema](#nestedblock--configuration)) | ||
- `etag` (String) Etag used to track the cluster profile | ||
- `plugin_id` (String) The plugin identifier of the cluster profile. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
<a id="nestedblock--configuration"></a> | ||
### Nested Schema for `configuration` | ||
|
||
Required: | ||
|
||
- `key` (String) the name of the property key. | ||
|
||
Optional: | ||
|
||
- `encrypted_value` (String) The encrypted value of the property | ||
- `is_secure` (Boolean) Specify whether the given property is secure or not. If true and encrypted_value is not specified, GoCD will store the value in encrypted format. | ||
- `value` (String) The value of the property | ||
|
||
|
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
//resource "gocd_plugin_setting" "yaml_plugin_settings" { | ||
// plugin_id = "yaml.config.plugin" | ||
// plugin_configurations { | ||
// key = "file_pattern" | ||
// key = "file_pattern" | ||
// value = "*.gocd.yaml" | ||
// } | ||
// plugin_configurations { | ||
// key = "file_pattern" | ||
// key = "file_pattern" | ||
// value = "*.gocd.yam" | ||
// } | ||
//} | ||
//} | ||
|
||
data "gocd_plugin_setting" "yaml_plugin_settings" { | ||
plugin_id = "yaml.config.plugin" | ||
} |
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,76 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/nikhilsbhat/gocd-sdk-go" | ||
"github.com/nikhilsbhat/terraform-provider-gocd/pkg/utils" | ||
) | ||
|
||
func dataSourcePluginsSetting() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: dataSourcePluginsSettingRead, | ||
Schema: map[string]*schema.Schema{ | ||
"plugin_id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Optional: true, | ||
Required: false, | ||
Description: "The plugin identifier of the cluster profile.", | ||
}, | ||
"configuration": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Optional: true, | ||
Description: "List of configuration required to configure the plugin settings.", | ||
Elem: propertiesSchemaData(), | ||
}, | ||
"etag": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Optional: true, | ||
Description: "Etag used to track the cluster profile", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourcePluginsSettingRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
defaultConfig := meta.(gocd.GoCd) | ||
|
||
id := d.Id() | ||
|
||
if len(id) == 0 { | ||
newID, err := utils.GetRandomID() | ||
if err != nil { | ||
d.SetId("") | ||
|
||
return diag.Errorf("errored while fetching randomID %v", err) | ||
} | ||
id = newID | ||
} | ||
|
||
pluginID := utils.String(d.Get(utils.TerraformPluginID)) | ||
|
||
response, err := defaultConfig.GetPluginSettings(pluginID) | ||
if err != nil { | ||
return diag.Errorf("getting cluster profile %s errored with: %v", pluginID, err) | ||
} | ||
|
||
flattenedConfiguration, err := utils.MapSlice(response.Configuration) | ||
if err != nil { | ||
d.SetId("") | ||
|
||
return diag.Errorf("errored while flattening Configuration obtained: %v", err) | ||
} | ||
|
||
if err = d.Set(utils.TerraformResourceConfiguration, flattenedConfiguration); err != nil { | ||
return diag.Errorf("setting '%s' errored with %v", err, utils.TerraformResourceConfiguration) | ||
} | ||
|
||
d.SetId(id) | ||
|
||
return nil | ||
} |
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