diff --git a/docs/data-sources/consumer.md b/docs/data-sources/consumer.md index 394e090..f0cca4a 100644 --- a/docs/data-sources/consumer.md +++ b/docs/data-sources/consumer.md @@ -5,20 +5,20 @@ subcategory: "Runtime Configuration" Represents a consumer ## Example usage ```hcl -data "konnect_runtime_group" "RuntimeGroup" { - name = "TestRuntimeGroup" +data "konnect_control_plane" "ControlPlane" { + name = "TestControlPlane" } data "konnect_consumer" "example" { - runtime_group_id = data.konnect_runtime_group.RuntimeGroup.id + control_plane_id = data.konnect_control_plane.ControlPlane.id search_username = "Bob" } ``` ## Argument Reference -* `runtime_group_id` - **(Required, String)** The id of the runtime group containing consumer +* `control_plane_id` - **(Required, String)** The id of the control plane containing consumer * `search_username` - **(Optional, String)** The search string to apply to the username of the consumer. Uses contains. * `username` - **(Optional, String)** The filter string to apply to the username of the consumer. Uses equality. * `search_custom_id` - **(Optional, String)** The search string to apply to the custom_id of the consumer. Uses contains. * `custom_id` - **(Optional, String)** The filter string to apply to the custom_id of the consumer. Uses equality. ## Attribute Reference -* `id` - **(String)** Same as `runtime_group_id`:`consumer_id` +* `id` - **(String)** Same as `control_plane_id`:`consumer_id` * `consumer_id` - **(String)** Id of the consumer alone diff --git a/docs/data-sources/nodes.md b/docs/data-sources/nodes.md index 7d3a3db..a0bdebd 100644 --- a/docs/data-sources/nodes.md +++ b/docs/data-sources/nodes.md @@ -2,21 +2,21 @@ subcategory: "Runtime Configuration" --- # Data Source: konnect_nodes -Represents all nodes of a runtime group +Represents all nodes of a control plane ## Example usage ```hcl -data "konnect_runtime_group" "RuntimeGroup" { - name = "TestRuntimeGroup" +data "konnect_control_plane" "ControlPlane" { + name = "TestControlPlane" } data "konnect_nodes" "example" { - runtime_group_id = data.konnect_runtime_group.RuntimeGroup.id + control_plane_id = data.konnect_control_plane.ControlPlane.id } ``` ## Argument Reference -* `runtime_group_id` - **(Required, String)** The id of the parent runtime group. +* `control_plane_id` - **(Required, String)** The id of the parent control plane. ## Attribute Reference -* `id` - **(String)** Same as `runtime_group_id` -* `nodes` - **(set{node})** Set of nodes belonging to runtime group +* `id` - **(String)** Same as `control_plane_id` +* `nodes` - **(set{node})** Set of nodes belonging to control plane ### node * `id` - **(String)** Id of node. * `version` - **(String)** Version of node. @@ -24,4 +24,4 @@ data "konnect_nodes" "example" { * `last_ping` - **(Integer)** Last time of ping of node. * `type` - **(String)** Type of node. * `config_hash` - **(String)** Hash of the current configuration state of node. -* `data_plane_cert_id` - **(String)** Id of certificate used in communication between node and runtime group. +* `data_plane_cert_id` - **(String)** Id of certificate used in communication between node and control plane. diff --git a/docs/data-sources/role.md b/docs/data-sources/role.md index cf7ba28..104d9b3 100644 --- a/docs/data-sources/role.md +++ b/docs/data-sources/role.md @@ -6,12 +6,12 @@ Represents a role ## Example usage ```hcl data "konnect_role" "example" { - entity_type_display_name = "Runtime Groups" + entity_type_display_name = "Control Planes" display_name = "Admin" } ``` ## Argument Reference -* `entity_type_display_name` - **(Required, String)** The display name of the role entity type. Must be `Runtime Groups` or `Services` +* `entity_type_display_name` - **(Required, String)** The display name of the role entity type. Must be `Control Planes` or `Services` * `display_name` - **(Required, String)** The display name of the Role. Uses equality. ## Attribute Reference * `id` - **(String)** Same as `entity_type_name`:`name` diff --git a/docs/data-sources/runtime_group.md b/docs/data-sources/runtime_group.md index c314dea..aab024d 100644 --- a/docs/data-sources/runtime_group.md +++ b/docs/data-sources/runtime_group.md @@ -1,20 +1,20 @@ --- subcategory: "Runtime Configuration" --- -# Data Source: konnect_runtime_group -Represents a runtime group +# Data Source: konnect_control_plane +Represents a control plane ## Example usage ```hcl -data "konnect_runtime_group" "example" { - name = "TestRuntimeGroup" +data "konnect_control_plane" "example" { + name = "TestControlPlane" } ``` ## Argument Reference -* `search_name` - **(Optional, String)** The search string to apply to the name of the runtime group. Uses contains. -* `name` - **(Optional, String)** The filter string to apply to the name of the runtime group. Uses equality. +* `search_name` - **(Optional, String)** The search string to apply to the name of the control plane. Uses contains. +* `name` - **(Optional, String)** The filter string to apply to the name of the control plane. Uses equality. ## Attribute Reference * `id` - **(String)** Guid -* `description` - **(String)** The description of the runtime group. -* `cluster_type` - **(String)** The cluster type of the runtime group. -* `control_plane_endpoint` - **(String)** The control plane endpoint URL of the runtime group. -* `telemetry_endpoint` - **(String)** The telemetry endpoint URL of the runtime group. +* `description` - **(String)** The description of the control plane. +* `cluster_type` - **(String)** The cluster type of the control plane. +* `control_plane_endpoint` - **(String)** The control plane endpoint URL of the control plane. +* `telemetry_endpoint` - **(String)** The telemetry endpoint URL of the control plane. diff --git a/docs/data-sources/team_role.md b/docs/data-sources/team_role.md index 4c0be2e..e0c3a3b 100644 --- a/docs/data-sources/team_role.md +++ b/docs/data-sources/team_role.md @@ -10,15 +10,15 @@ data "konnect_team" "Team" { } data "konnect_team_role" "example" { team_id = data.konnect_team.Team.id - entity_type_display_name = "Runtime Groups" + entity_type_display_name = "Control Planes" } ``` ## Argument Reference * `team_id` - **(Required, String)** The id of the team assigned the role * `search_role_display_name` - **(Optional, String)** The search string to apply to the display name of the role. Uses contains. * `role_display_name` - **(Optional, String)** The filter string to apply to the display name of the role. Uses equality. -* `search_entity_type_display_name` - **(Optional, String)** The search string to apply to the display name of the entity type, like `Runtime Groups` or `Services`. Uses contains. -* `entity_type_display_name` - **(Optional, String)** The filter string to apply to the display name of the entity type. Must be `Runtime Groups` or `Services`. Uses equality. +* `search_entity_type_display_name` - **(Optional, String)** The search string to apply to the display name of the entity type, like `Control Planes` or `Services`. Uses contains. +* `entity_type_display_name` - **(Optional, String)** The filter string to apply to the display name of the entity type. Must be `Control Planes` or `Services`. Uses equality. ## Attribute Reference * `id` - **(String)** Same as `team_id`:`Guid of role assignment` * `entity_id` - **(String)** The id of the entity for which the role applies. diff --git a/docs/data-sources/user_role.md b/docs/data-sources/user_role.md index e744873..f5a7d6f 100644 --- a/docs/data-sources/user_role.md +++ b/docs/data-sources/user_role.md @@ -10,15 +10,15 @@ data "konnect_user" "User" { } data "konnect_user_role" "example" { user_id = data.konnect_user.User.id - entity_type_display_name = "Runtime Groups" + entity_type_display_name = "Control Planes" } ``` ## Argument Reference * `user_id` - **(Required, String)** The id of the user assigned the role * `search_role_display_name` - **(Optional, String)** The search string to apply to the display name of the role. Uses contains. * `role_display_name` - **(Optional, String)** The filter string to apply to the display name of the role. Uses equality. -* `search_entity_type_display_name` - **(Optional, String)** The search string to apply to the display name of the entity type, like `Runtime Groups` or `Services`. Uses contains. -* `entity_type_display_name` - **(Optional, String)** The filter string to apply to the display name of the entity type. Must be `Runtime Groups` or `Services`. Uses equality. +* `search_entity_type_display_name` - **(Optional, String)** The search string to apply to the display name of the entity type, like `Control Planes` or `Services`. Uses contains. +* `entity_type_display_name` - **(Optional, String)** The filter string to apply to the display name of the entity type. Must be `Control Planes` or `Services`. Uses equality. ## Attribute Reference * `id` - **(String)** Same as `user_id`:`Guid of role assignment` * `entity_id` - **(String)** The id of the entity for which the role applies. diff --git a/docs/resources/consumer.md b/docs/resources/consumer.md index 448afdb..64c450d 100644 --- a/docs/resources/consumer.md +++ b/docs/resources/consumer.md @@ -2,24 +2,24 @@ subcategory: "Runtime Configuration" --- # Resource: konnect_consumer -Represents a consumer within a runtime group +Represents a consumer within a control plane ## Example usage ```hcl -data "konnect_runtime_group" "RuntimeGroup" { - name = "TestRuntimeGroup" +data "konnect_control_plane" "ControlPlane" { + name = "TestControlPlane" } resource "konnect_consumer" "example" { - runtime_group_id = data.konnect_runtime_group.RuntimeGroup.id + control_plane_id = data.konnect_control_plane.ControlPlane.id username = "testuser" custom_id = "testcustom" } ``` ## Argument Reference -* `runtime_group_id` - **(Required, String)** The id of the runtime group. +* `control_plane_id` - **(Required, String)** The id of the control plane. * `username` - **(Optional, String)** The unique username of the Consumer. * `custom_id` - **(Optional, String)** Field for storing an existing unique ID for the Consumer. ## Attribute Reference -* `id` - **(String)** Same as `runtime_group_id`:`consumer_id` +* `id` - **(String)** Same as `control_plane_id`:`consumer_id` * `consumer_id` - **(String)** Id of the consumer alone ## Import Consumers can be imported using a proper value of `id` as described above diff --git a/docs/resources/plugin.md b/docs/resources/plugin.md index 261d872..8dd95fc 100644 --- a/docs/resources/plugin.md +++ b/docs/resources/plugin.md @@ -2,14 +2,14 @@ subcategory: "Runtime Configuration" --- # Resource: konnect_plugin -Represents a plugin within a runtime group +Represents a plugin within a control plane ## Example usage ```hcl -data "konnect_runtime_group" "RuntimeGroup" { - name = "TestRuntimeGroup" +data "konnect_control_plane" "ControlPlane" { + name = "TestControlPlane" } resource "konnect_plugin" "example" { - runtime_group_id = data.konnect_runtime_group.RuntimeGroup.id + control_plane_id = data.konnect_control_plane.ControlPlane.id name = "rate-limiting" config_json = < 1 { + numControlPlanes := len(retVals.ControlPlanes) + if numControlPlanes > 1 { d.SetId("") - return diag.FromErr(fmt.Errorf("Filter criteria does not result in a single runtime group")) - } else if numRuntimeGroups != 1 { + return diag.FromErr(fmt.Errorf("Filter criteria does not result in a single control plane")) + } else if numControlPlanes != 1 { d.SetId("") - return diag.FromErr(fmt.Errorf("No runtime group exists with that filter criteria")) + return diag.FromErr(fmt.Errorf("No control plane exists with that filter criteria")) } - retVal := retVals.RuntimeGroups[0] + retVal := retVals.ControlPlanes[0] d.Set("name", retVal.Name) d.Set("description", retVal.Description) d.Set("cluster_type", retVal.Config.ClusterType) diff --git a/konnect/data_source_nodes.go b/konnect/data_source_nodes.go index e2d1759..73caed4 100644 --- a/konnect/data_source_nodes.go +++ b/konnect/data_source_nodes.go @@ -15,7 +15,7 @@ func dataSourceNodes() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceNodesRead, Schema: map[string]*schema.Schema{ - "runtime_group_id": { + "control_plane_id": { Type: schema.TypeString, Required: true, }, @@ -62,8 +62,8 @@ func dataSourceNodes() *schema.Resource { func dataSourceNodesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics c := m.(*client.Client) - runtimeGroupId := d.Get("runtime_group_id").(string) - requestPath := fmt.Sprintf(client.NodePath, runtimeGroupId) + controlPlaneId := d.Get("control_plane_id").(string) + requestPath := fmt.Sprintf(client.NodePath, controlPlaneId) body, err := c.HttpRequest(ctx, true, http.MethodGet, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { d.SetId("") @@ -88,6 +88,6 @@ func dataSourceNodesRead(ctx context.Context, d *schema.ResourceData, m interfac nodes = append(nodes, itemMap) } d.Set("nodes", nodes) - d.SetId(runtimeGroupId) + d.SetId(controlPlaneId) return diags } diff --git a/konnect/data_source_role.go b/konnect/data_source_role.go index dcbf3da..b8a7634 100644 --- a/konnect/data_source_role.go +++ b/konnect/data_source_role.go @@ -19,7 +19,7 @@ func dataSourceRole() *schema.Resource { "entity_type_display_name": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{client.RuntimeGroupsDisplayName, client.ServicesDisplayName}, false), + ValidateFunc: validation.StringInSlice([]string{client.ControlPlanesDisplayName, client.ServicesDisplayName}, false), }, "display_name": { Type: schema.TypeString, diff --git a/konnect/data_source_team_role.go b/konnect/data_source_team_role.go index 1641e1e..d770ec7 100644 --- a/konnect/data_source_team_role.go +++ b/konnect/data_source_team_role.go @@ -36,7 +36,7 @@ func dataSourceTeamRole() *schema.Resource { "entity_type_display_name": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringInSlice([]string{client.RuntimeGroupsDisplayName, client.ServicesDisplayName}, false), + ValidateFunc: validation.StringInSlice([]string{client.ControlPlanesDisplayName, client.ServicesDisplayName}, false), }, "entity_id": { Type: schema.TypeString, diff --git a/konnect/data_source_user_role.go b/konnect/data_source_user_role.go index 147234f..0d0da7f 100644 --- a/konnect/data_source_user_role.go +++ b/konnect/data_source_user_role.go @@ -36,7 +36,7 @@ func dataSourceUserRole() *schema.Resource { "entity_type_display_name": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringInSlice([]string{client.RuntimeGroupsDisplayName, client.ServicesDisplayName}, false), + ValidateFunc: validation.StringInSlice([]string{client.ControlPlanesDisplayName, client.ServicesDisplayName}, false), }, "entity_id": { Type: schema.TypeString, diff --git a/konnect/provider.go b/konnect/provider.go index c3dc125..4d7cdf4 100644 --- a/konnect/provider.go +++ b/konnect/provider.go @@ -31,7 +31,7 @@ func Provider() *schema.Provider { //}, }, ResourcesMap: map[string]*schema.Resource{ - "konnect_runtime_group": resourceRuntimeGroup(), + "konnect_control_plane": resourceControlPlane(), "konnect_authentication_settings": resourceAuthenticationSettings(), "konnect_identity_provider": resourceIdentityProvider(), "konnect_user": resourceUser(), @@ -46,7 +46,7 @@ func Provider() *schema.Provider { "konnect_plugin": resourcePlugin(), }, DataSourcesMap: map[string]*schema.Resource{ - "konnect_runtime_group": dataSourceRuntimeGroup(), + "konnect_control_plane": dataSourceControlPlane(), "konnect_user": dataSourceUser(), "konnect_team": dataSourceTeam(), "konnect_role": dataSourceRole(), diff --git a/konnect/resource_consumer.go b/konnect/resource_consumer.go index c94af42..340b276 100644 --- a/konnect/resource_consumer.go +++ b/konnect/resource_consumer.go @@ -22,7 +22,7 @@ func resourceConsumer() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ - "runtime_group_id": { + "control_plane_id": { Type: schema.TypeString, Required: true, }, @@ -45,7 +45,7 @@ func resourceConsumer() *schema.Resource { } func fillConsumer(c *client.Consumer, d *schema.ResourceData) { - c.RuntimeGroupId = d.Get("runtime_group_id").(string) + c.ControlPlaneId = d.Get("control_plane_id").(string) username, ok := d.GetOk("username") if ok { c.Username = username.(string) @@ -57,7 +57,7 @@ func fillConsumer(c *client.Consumer, d *schema.ResourceData) { } func fillResourceDataFromConsumer(c *client.Consumer, d *schema.ResourceData) { - d.Set("runtime_group_id", c.RuntimeGroupId) + d.Set("control_plane_id", c.ControlPlaneId) d.Set("username", c.Username) d.Set("custom_id", c.CustomId) d.Set("consumer_id", c.Id) @@ -74,7 +74,7 @@ func resourceConsumerCreate(ctx context.Context, d *schema.ResourceData, m inter d.SetId("") return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.ConsumerPath, newConsumer.RuntimeGroupId) + requestPath := fmt.Sprintf(client.ConsumerPath, newConsumer.ControlPlaneId) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -89,7 +89,7 @@ func resourceConsumerCreate(ctx context.Context, d *schema.ResourceData, m inter d.SetId("") return diag.FromErr(err) } - retVal.RuntimeGroupId = newConsumer.RuntimeGroupId + retVal.ControlPlaneId = newConsumer.ControlPlaneId d.SetId(retVal.ConsumerEncodeId()) fillResourceDataFromConsumer(retVal, d) return diags @@ -97,9 +97,9 @@ func resourceConsumerCreate(ctx context.Context, d *schema.ResourceData, m inter func resourceConsumerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.ConsumerDecodeId(d.Id()) + controlPlaneId, id := client.ConsumerDecodeId(d.Id()) c := m.(*client.Client) - requestPath := fmt.Sprintf(client.ConsumerPathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.ConsumerPathGet, controlPlaneId, id) body, err := c.HttpRequest(ctx, true, http.MethodGet, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { d.SetId("") @@ -115,14 +115,14 @@ func resourceConsumerRead(ctx context.Context, d *schema.ResourceData, m interfa d.SetId("") return diag.FromErr(err) } - retVal.RuntimeGroupId = runtimeGroupId + retVal.ControlPlaneId = controlPlaneId fillResourceDataFromConsumer(retVal, d) return diags } func resourceConsumerUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.ConsumerDecodeId(d.Id()) + controlPlaneId, id := client.ConsumerDecodeId(d.Id()) c := m.(*client.Client) buf := bytes.Buffer{} upConsumer := client.Consumer{} @@ -133,7 +133,7 @@ func resourceConsumerUpdate(ctx context.Context, d *schema.ResourceData, m inter if err != nil { return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.ConsumerPathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.ConsumerPathGet, controlPlaneId, id) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -146,16 +146,16 @@ func resourceConsumerUpdate(ctx context.Context, d *schema.ResourceData, m inter if err != nil { return diag.FromErr(err) } - retVal.RuntimeGroupId = runtimeGroupId + retVal.ControlPlaneId = controlPlaneId fillResourceDataFromConsumer(retVal, d) return diags } func resourceConsumerDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.ConsumerDecodeId(d.Id()) + controlPlaneId, id := client.ConsumerDecodeId(d.Id()) c := m.(*client.Client) - requestPath := fmt.Sprintf(client.ConsumerPathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.ConsumerPathGet, controlPlaneId, id) _, err := c.HttpRequest(ctx, true, http.MethodDelete, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { return diag.FromErr(err) diff --git a/konnect/resource_runtime_group.go b/konnect/resource_control_plane.go similarity index 70% rename from konnect/resource_runtime_group.go rename to konnect/resource_control_plane.go index e0e3702..263f3f6 100644 --- a/konnect/resource_runtime_group.go +++ b/konnect/resource_control_plane.go @@ -14,12 +14,12 @@ import ( "net/http" ) -func resourceRuntimeGroup() *schema.Resource { +func resourceControlPlane() *schema.Resource { return &schema.Resource{ - CreateContext: resourceRuntimeGroupCreate, - ReadContext: resourceRuntimeGroupRead, - UpdateContext: resourceRuntimeGroupUpdate, - DeleteContext: resourceRuntimeGroupDelete, + CreateContext: resourceControlPlaneCreate, + ReadContext: resourceControlPlaneRead, + UpdateContext: resourceControlPlaneUpdate, + DeleteContext: resourceControlPlaneDelete, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, @@ -49,7 +49,7 @@ func resourceRuntimeGroup() *schema.Resource { } } -func fillRuntimeGroup(c *client.RuntimeGroup, d *schema.ResourceData) { +func fillControlPlane(c *client.ControlPlane, d *schema.ResourceData) { c.Name = d.Get("name").(string) description, ok := d.GetOk("description") if ok { @@ -57,7 +57,7 @@ func fillRuntimeGroup(c *client.RuntimeGroup, d *schema.ResourceData) { } } -func fillResourceDataFromRuntimeGroup(c *client.RuntimeGroup, d *schema.ResourceData) { +func fillResourceDataFromControlPlane(c *client.ControlPlane, d *schema.ResourceData) { d.Set("name", c.Name) d.Set("description", c.Description) d.Set("cluster_type", c.Config.ClusterType) @@ -65,18 +65,18 @@ func fillResourceDataFromRuntimeGroup(c *client.RuntimeGroup, d *schema.Resource d.Set("telemetry_endpoint", c.Config.TelemetryEndpoint) } -func resourceRuntimeGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceControlPlaneCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics c := m.(*client.Client) buf := bytes.Buffer{} - newRuntimeGroup := client.RuntimeGroup{} - fillRuntimeGroup(&newRuntimeGroup, d) - err := json.NewEncoder(&buf).Encode(newRuntimeGroup) + newControlPlane := client.ControlPlane{} + fillControlPlane(&newControlPlane, d) + err := json.NewEncoder(&buf).Encode(newControlPlane) if err != nil { d.SetId("") return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.RuntimeGroupPath) + requestPath := fmt.Sprintf(client.ControlPlanePath) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -85,21 +85,21 @@ func resourceRuntimeGroupCreate(ctx context.Context, d *schema.ResourceData, m i d.SetId("") return diag.FromErr(err) } - retVal := &client.RuntimeGroup{} + retVal := &client.ControlPlane{} err = json.NewDecoder(body).Decode(retVal) if err != nil { d.SetId("") return diag.FromErr(err) } d.SetId(retVal.Id) - fillResourceDataFromRuntimeGroup(retVal, d) + fillResourceDataFromControlPlane(retVal, d) return diags } -func resourceRuntimeGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceControlPlaneRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics c := m.(*client.Client) - requestPath := fmt.Sprintf(client.RuntimeGroupPathGet, d.Id()) + requestPath := fmt.Sprintf(client.ControlPlanePathGet, d.Id()) body, err := c.HttpRequest(ctx, true, http.MethodGet, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { d.SetId("") @@ -109,27 +109,27 @@ func resourceRuntimeGroupRead(ctx context.Context, d *schema.ResourceData, m int } return diag.FromErr(err) } - retVal := &client.RuntimeGroup{} + retVal := &client.ControlPlane{} err = json.NewDecoder(body).Decode(retVal) if err != nil { d.SetId("") return diag.FromErr(err) } - fillResourceDataFromRuntimeGroup(retVal, d) + fillResourceDataFromControlPlane(retVal, d) return diags } -func resourceRuntimeGroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceControlPlaneUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics c := m.(*client.Client) buf := bytes.Buffer{} - upRuntimeGroup := client.RuntimeGroup{} - fillRuntimeGroup(&upRuntimeGroup, d) - err := json.NewEncoder(&buf).Encode(upRuntimeGroup) + upControlPlane := client.ControlPlane{} + fillControlPlane(&upControlPlane, d) + err := json.NewEncoder(&buf).Encode(upControlPlane) if err != nil { return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.RuntimeGroupPathGet, d.Id()) + requestPath := fmt.Sprintf(client.ControlPlanePathGet, d.Id()) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -137,19 +137,19 @@ func resourceRuntimeGroupUpdate(ctx context.Context, d *schema.ResourceData, m i if err != nil { return diag.FromErr(err) } - retVal := &client.RuntimeGroup{} + retVal := &client.ControlPlane{} err = json.NewDecoder(body).Decode(retVal) if err != nil { return diag.FromErr(err) } - fillResourceDataFromRuntimeGroup(retVal, d) + fillResourceDataFromControlPlane(retVal, d) return diags } -func resourceRuntimeGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceControlPlaneDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics c := m.(*client.Client) - requestPath := fmt.Sprintf(client.RuntimeGroupPathGet, d.Id()) + requestPath := fmt.Sprintf(client.ControlPlanePathGet, d.Id()) _, err := c.HttpRequest(ctx, true, http.MethodDelete, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { return diag.FromErr(err) diff --git a/konnect/resource_plugin.go b/konnect/resource_plugin.go index d391628..56c839b 100644 --- a/konnect/resource_plugin.go +++ b/konnect/resource_plugin.go @@ -25,7 +25,7 @@ func resourcePlugin() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ - "runtime_group_id": { + "control_plane_id": { Type: schema.TypeString, Required: true, }, @@ -85,7 +85,7 @@ func resourcePlugin() *schema.Resource { } func fillPlugin(c *client.Plugin, d *schema.ResourceData) { - c.RuntimeGroupId = d.Get("runtime_group_id").(string) + c.ControlPlaneId = d.Get("control_plane_id").(string) c.Enabled = d.Get("enabled").(bool) name, ok := d.GetOk("name") if ok { @@ -137,7 +137,7 @@ func fillResourceDataFromPlugin(ctx context.Context, c *client.Plugin, d *schema break } } - d.Set("runtime_group_id", c.RuntimeGroupId) + d.Set("control_plane_id", c.ControlPlaneId) d.Set("name", c.Name) d.Set("instance_name", c.InstanceName) d.Set("protocols", c.Protocols) @@ -202,8 +202,8 @@ func areConfigValuesEqual(ctx context.Context, key string, configValue interface return configValueString == schemaFieldString } -func getPluginSchema(ctx context.Context, c *client.Client, runtimeGroupId string, pluginName string) (*client.PluginSchema, error) { - requestPath := fmt.Sprintf(client.PluginSchemaPath, runtimeGroupId, pluginName) +func getPluginSchema(ctx context.Context, c *client.Client, controlPlaneId string, pluginName string) (*client.PluginSchema, error) { + requestPath := fmt.Sprintf(client.PluginSchemaPath, controlPlaneId, pluginName) body, err := c.HttpRequest(ctx, true, http.MethodGet, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { return nil, err @@ -227,7 +227,7 @@ func resourcePluginCreate(ctx context.Context, d *schema.ResourceData, m interfa d.SetId("") return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.PluginPath, newPlugin.RuntimeGroupId) + requestPath := fmt.Sprintf(client.PluginPath, newPlugin.ControlPlaneId) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -242,13 +242,13 @@ func resourcePluginCreate(ctx context.Context, d *schema.ResourceData, m interfa d.SetId("") return diag.FromErr(err) } - pluginSchema, err := getPluginSchema(ctx, c, newPlugin.RuntimeGroupId, retVal.Name) + pluginSchema, err := getPluginSchema(ctx, c, newPlugin.ControlPlaneId, retVal.Name) if err != nil { d.SetId("") return diag.FromErr(err) } retVal.ConfigAll = copyMapByJSON(retVal.Config) - retVal.RuntimeGroupId = newPlugin.RuntimeGroupId + retVal.ControlPlaneId = newPlugin.ControlPlaneId d.SetId(retVal.PluginEncodeId()) fillResourceDataFromPlugin(ctx, retVal, d, pluginSchema) return diags @@ -256,9 +256,9 @@ func resourcePluginCreate(ctx context.Context, d *schema.ResourceData, m interfa func resourcePluginRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.PluginDecodeId(d.Id()) + controlPlaneId, id := client.PluginDecodeId(d.Id()) c := m.(*client.Client) - requestPath := fmt.Sprintf(client.PluginPathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.PluginPathGet, controlPlaneId, id) body, err := c.HttpRequest(ctx, true, http.MethodGet, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { d.SetId("") @@ -274,20 +274,20 @@ func resourcePluginRead(ctx context.Context, d *schema.ResourceData, m interface d.SetId("") return diag.FromErr(err) } - pluginSchema, err := getPluginSchema(ctx, c, runtimeGroupId, retVal.Name) + pluginSchema, err := getPluginSchema(ctx, c, controlPlaneId, retVal.Name) if err != nil { d.SetId("") return diag.FromErr(err) } retVal.ConfigAll = copyMapByJSON(retVal.Config) - retVal.RuntimeGroupId = runtimeGroupId + retVal.ControlPlaneId = controlPlaneId fillResourceDataFromPlugin(ctx, retVal, d, pluginSchema) return diags } func resourcePluginUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.PluginDecodeId(d.Id()) + controlPlaneId, id := client.PluginDecodeId(d.Id()) c := m.(*client.Client) buf := bytes.Buffer{} upPlugin := client.Plugin{} @@ -296,7 +296,7 @@ func resourcePluginUpdate(ctx context.Context, d *schema.ResourceData, m interfa if err != nil { return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.PluginPathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.PluginPathGet, controlPlaneId, id) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -309,21 +309,21 @@ func resourcePluginUpdate(ctx context.Context, d *schema.ResourceData, m interfa if err != nil { return diag.FromErr(err) } - pluginSchema, err := getPluginSchema(ctx, c, runtimeGroupId, retVal.Name) + pluginSchema, err := getPluginSchema(ctx, c, controlPlaneId, retVal.Name) if err != nil { return diag.FromErr(err) } retVal.ConfigAll = copyMapByJSON(retVal.Config) - retVal.RuntimeGroupId = runtimeGroupId + retVal.ControlPlaneId = controlPlaneId fillResourceDataFromPlugin(ctx, retVal, d, pluginSchema) return diags } func resourcePluginDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.PluginDecodeId(d.Id()) + controlPlaneId, id := client.PluginDecodeId(d.Id()) c := m.(*client.Client) - requestPath := fmt.Sprintf(client.PluginPathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.PluginPathGet, controlPlaneId, id) _, err := c.HttpRequest(ctx, true, http.MethodDelete, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { return diag.FromErr(err) diff --git a/konnect/resource_route.go b/konnect/resource_route.go index 561d433..9064501 100644 --- a/konnect/resource_route.go +++ b/konnect/resource_route.go @@ -23,7 +23,7 @@ func resourceRoute() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ - "runtime_group_id": { + "control_plane_id": { Type: schema.TypeString, Required: true, }, @@ -130,7 +130,7 @@ func resourceRoute() *schema.Resource { } func fillRoute(c *client.Route, d *schema.ResourceData) { - c.RuntimeGroupId = d.Get("runtime_group_id").(string) + c.ControlPlaneId = d.Get("control_plane_id").(string) c.StripPath = d.Get("strip_path").(bool) c.PreserveHost = d.Get("preserve_host").(bool) c.RequestBuffering = d.Get("request_buffering").(bool) @@ -191,7 +191,7 @@ func fillRoute(c *client.Route, d *schema.ResourceData) { } func fillResourceDataFromRoute(c *client.Route, d *schema.ResourceData) { - d.Set("runtime_group_id", c.RuntimeGroupId) + d.Set("control_plane_id", c.ControlPlaneId) d.Set("name", c.Name) d.Set("protocols", c.Protocols) d.Set("methods", c.Methods) @@ -234,7 +234,7 @@ func resourceRouteCreate(ctx context.Context, d *schema.ResourceData, m interfac d.SetId("") return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.RoutePath, newRoute.RuntimeGroupId) + requestPath := fmt.Sprintf(client.RoutePath, newRoute.ControlPlaneId) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -249,7 +249,7 @@ func resourceRouteCreate(ctx context.Context, d *schema.ResourceData, m interfac d.SetId("") return diag.FromErr(err) } - retVal.RuntimeGroupId = newRoute.RuntimeGroupId + retVal.ControlPlaneId = newRoute.ControlPlaneId d.SetId(retVal.RouteEncodeId()) fillResourceDataFromRoute(retVal, d) return diags @@ -257,9 +257,9 @@ func resourceRouteCreate(ctx context.Context, d *schema.ResourceData, m interfac func resourceRouteRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.RouteDecodeId(d.Id()) + controlPlaneId, id := client.RouteDecodeId(d.Id()) c := m.(*client.Client) - requestPath := fmt.Sprintf(client.RoutePathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.RoutePathGet, controlPlaneId, id) body, err := c.HttpRequest(ctx, true, http.MethodGet, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { d.SetId("") @@ -275,14 +275,14 @@ func resourceRouteRead(ctx context.Context, d *schema.ResourceData, m interface{ d.SetId("") return diag.FromErr(err) } - retVal.RuntimeGroupId = runtimeGroupId + retVal.ControlPlaneId = controlPlaneId fillResourceDataFromRoute(retVal, d) return diags } func resourceRouteUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.RouteDecodeId(d.Id()) + controlPlaneId, id := client.RouteDecodeId(d.Id()) c := m.(*client.Client) buf := bytes.Buffer{} upRoute := client.Route{} @@ -293,7 +293,7 @@ func resourceRouteUpdate(ctx context.Context, d *schema.ResourceData, m interfac if err != nil { return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.RoutePathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.RoutePathGet, controlPlaneId, id) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -306,16 +306,16 @@ func resourceRouteUpdate(ctx context.Context, d *schema.ResourceData, m interfac if err != nil { return diag.FromErr(err) } - retVal.RuntimeGroupId = runtimeGroupId + retVal.ControlPlaneId = controlPlaneId fillResourceDataFromRoute(retVal, d) return diags } func resourceRouteDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.RouteDecodeId(d.Id()) + controlPlaneId, id := client.RouteDecodeId(d.Id()) c := m.(*client.Client) - requestPath := fmt.Sprintf(client.RoutePathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.RoutePathGet, controlPlaneId, id) _, err := c.HttpRequest(ctx, true, http.MethodDelete, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { return diag.FromErr(err) diff --git a/konnect/resource_service.go b/konnect/resource_service.go index 26aff30..045238c 100644 --- a/konnect/resource_service.go +++ b/konnect/resource_service.go @@ -23,7 +23,7 @@ func resourceService() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ - "runtime_group_id": { + "control_plane_id": { Type: schema.TypeString, Required: true, }, @@ -89,7 +89,7 @@ func resourceService() *schema.Resource { } func fillService(c *client.Service, d *schema.ResourceData) { - c.RuntimeGroupId = d.Get("runtime_group_id").(string) + c.ControlPlaneId = d.Get("control_plane_id").(string) c.Host = d.Get("host").(string) c.Enabled = d.Get("enabled").(bool) name, ok := d.GetOk("name") @@ -127,7 +127,7 @@ func fillService(c *client.Service, d *schema.ResourceData) { } func fillResourceDataFromService(c *client.Service, d *schema.ResourceData) { - d.Set("runtime_group_id", c.RuntimeGroupId) + d.Set("control_plane_id", c.ControlPlaneId) d.Set("host", c.Host) d.Set("name", c.Name) d.Set("retries", c.Retries) @@ -152,7 +152,7 @@ func resourceServiceCreate(ctx context.Context, d *schema.ResourceData, m interf d.SetId("") return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.ServicePath, newService.RuntimeGroupId) + requestPath := fmt.Sprintf(client.ServicePath, newService.ControlPlaneId) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -167,7 +167,7 @@ func resourceServiceCreate(ctx context.Context, d *schema.ResourceData, m interf d.SetId("") return diag.FromErr(err) } - retVal.RuntimeGroupId = newService.RuntimeGroupId + retVal.ControlPlaneId = newService.ControlPlaneId d.SetId(retVal.ServiceEncodeId()) fillResourceDataFromService(retVal, d) return diags @@ -175,9 +175,9 @@ func resourceServiceCreate(ctx context.Context, d *schema.ResourceData, m interf func resourceServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.ServiceDecodeId(d.Id()) + controlPlaneId, id := client.ServiceDecodeId(d.Id()) c := m.(*client.Client) - requestPath := fmt.Sprintf(client.ServicePathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.ServicePathGet, controlPlaneId, id) body, err := c.HttpRequest(ctx, true, http.MethodGet, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { d.SetId("") @@ -193,14 +193,14 @@ func resourceServiceRead(ctx context.Context, d *schema.ResourceData, m interfac d.SetId("") return diag.FromErr(err) } - retVal.RuntimeGroupId = runtimeGroupId + retVal.ControlPlaneId = controlPlaneId fillResourceDataFromService(retVal, d) return diags } func resourceServiceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.ServiceDecodeId(d.Id()) + controlPlaneId, id := client.ServiceDecodeId(d.Id()) c := m.(*client.Client) buf := bytes.Buffer{} upService := client.Service{} @@ -211,7 +211,7 @@ func resourceServiceUpdate(ctx context.Context, d *schema.ResourceData, m interf if err != nil { return diag.FromErr(err) } - requestPath := fmt.Sprintf(client.ServicePathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.ServicePathGet, controlPlaneId, id) requestHeaders := http.Header{ headers.ContentType: []string{client.ApplicationJson}, } @@ -224,16 +224,16 @@ func resourceServiceUpdate(ctx context.Context, d *schema.ResourceData, m interf if err != nil { return diag.FromErr(err) } - retVal.RuntimeGroupId = runtimeGroupId + retVal.ControlPlaneId = controlPlaneId fillResourceDataFromService(retVal, d) return diags } func resourceServiceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { var diags diag.Diagnostics - runtimeGroupId, id := client.ServiceDecodeId(d.Id()) + controlPlaneId, id := client.ServiceDecodeId(d.Id()) c := m.(*client.Client) - requestPath := fmt.Sprintf(client.ServicePathGet, runtimeGroupId, id) + requestPath := fmt.Sprintf(client.ServicePathGet, controlPlaneId, id) _, err := c.HttpRequest(ctx, true, http.MethodDelete, requestPath, nil, nil, &bytes.Buffer{}) if err != nil { return diag.FromErr(err) diff --git a/konnect/resource_team_role.go b/konnect/resource_team_role.go index d743366..fbaeb8e 100644 --- a/konnect/resource_team_role.go +++ b/konnect/resource_team_role.go @@ -36,7 +36,7 @@ func resourceTeamRole() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{client.RuntimeGroupsDisplayName, client.ServicesDisplayName}, false), + ValidateFunc: validation.StringInSlice([]string{client.ControlPlanesDisplayName, client.ServicesDisplayName}, false), }, "entity_id": { Type: schema.TypeString, diff --git a/konnect/resource_user_role.go b/konnect/resource_user_role.go index 7326dce..f7d6e00 100644 --- a/konnect/resource_user_role.go +++ b/konnect/resource_user_role.go @@ -36,7 +36,7 @@ func resourceUserRole() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{client.RuntimeGroupsDisplayName, client.ServicesDisplayName}, false), + ValidateFunc: validation.StringInSlice([]string{client.ControlPlanesDisplayName, client.ServicesDisplayName}, false), }, "entity_id": { Type: schema.TypeString, diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..f044d4a --- /dev/null +++ b/notes.txt @@ -0,0 +1,14 @@ +Read must fill in all fields except for Id +- Id is not required because it is already known in order to call the Read function in the first place +- All fields need to be set as the read could be done as part of an import where only the id is known (UNLESS a custom import function is provided to fill in the other id related fields before the Read is called) +- Don't have to decode http response if all fields can be accessed from required input fields or decoding id + +Create must set Id and computed values + +Delete must set Id to empty string + +Update must set Id IF a property used to create Id has been changed + +Building: + mv ~/terraformrc ~/.terraformrc + go build -o ~/.go/bin/terraform-provider-konnect diff --git a/test/main.tf b/test/main.tf index b8ee37a..b7ce6db 100644 --- a/test/main.tf +++ b/test/main.tf @@ -10,7 +10,7 @@ provider "konnect" { } #resource "konnect_plugin" "P" { -# runtime_group_id = data.konnect_runtime_group.RG.id +# control_plane_id = data.konnect_control_plane.RG.id # name = "rate-limiting" # protocols = [ # "grpc", @@ -27,19 +27,19 @@ provider "konnect" { #} #resource "konnect_consumer" "C" { -# runtime_group_id = data.konnect_runtime_group.RG.id +# control_plane_id = data.konnect_control_plane.RG.id # username = "Shawn" # custom_id = "Bob" #} #resource "konnect_service" "S" { -# runtime_group_id = data.konnect_runtime_group.RG.id +# control_plane_id = data.konnect_control_plane.RG.id # host = "mockbin.org" # name = "TFTest" #} #resource "konnect_route" "R" { -# runtime_group_id = data.konnect_runtime_group.RG.id +# control_plane_id = data.konnect_control_plane.RG.id # name = "TFRoute" # protocols = ["http"] # methods = ["GET"] @@ -52,24 +52,24 @@ provider "konnect" { #} #data "konnect_nodes" "Ns" { -# runtime_group_id = data.konnect_runtime_group.RG.id +# control_plane_id = data.konnect_control_plane.RG.id #} #resource "konnect_user_role" "UR" { # user_id = data.konnect_user.U.id -# entity_id = data.konnect_runtime_group.RG.id -# entity_type_display_name = "Runtime Groups" +# entity_id = data.konnect_control_plane.RG.id +# entity_type_display_name = "Control Planes" # entity_region = "us" # role_display_name = data.konnect_role.R.display_name #} #data "konnect_team_role" "TR" { # team_id = data.konnect_team.T.id -# entity_type_display_name = "Runtime Groups" +# entity_type_display_name = "Control Planes" #} #data "konnect_role" "R" { -# group_display_name = "Runtime Groups" +# group_display_name = "Control Planes" # display_name = "Admin" #} @@ -80,8 +80,8 @@ provider "konnect" { #resource "konnect_team_role" "TR" { # team_id = konnect_team.T.id -# entity_id = konnect_runtime_group.RG.id -# entity_type_display_name = "Runtime Groups" +# entity_id = konnect_control_plane.RG.id +# entity_type_display_name = "Control Planes" # entity_region = "us" # role_display_name = data.konnect_role.R.display_name #} @@ -126,17 +126,17 @@ provider "konnect" { # konnect_mapping_enabled = true #} -#resource "konnect_runtime_group" "RG" { +#resource "konnect_control_plane" "RG" { # name = "ShawnRG" # description = "testing" #} -data "konnect_runtime_group" "RG" { +data "konnect_control_plane" "RG" { name = "development" } data "konnect_consumer" "C" { - runtime_group_id = data.konnect_runtime_group.RG.id - search_username = "a" + control_plane_id = data.konnect_control_plane.RG.id + search_username = "web" # search_custom_id = null } \ No newline at end of file