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

enhancement: Reinstall agent if repo url changed #49

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
21 changes: 21 additions & 0 deletions docs/data-sources/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "plural_config Data Source - terraform-provider-plural"
subcategory: ""
description: |-
A representation of a config to authenticate to app.plural.sh
---

# plural_config (Data Source)

A representation of a config to authenticate to app.plural.sh



<!-- schema generated by tfplugindocs -->
## Schema

### Read-Only

- `email` (String) The email used to authenticate to plural.
- `token` (String) Access token used to authenticate to plural.
25 changes: 25 additions & 0 deletions docs/data-sources/group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "plural_group Data Source - terraform-provider-plural"
subcategory: ""
description: |-
A representation of a group to organize authorization in your plural console.
---

# plural_group (Data Source)

A representation of a group to organize authorization in your plural console.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Name of this group.

### Read-Only

- `description` (String) Description of this group.
- `id` (String) Internal identifier of this group.
28 changes: 28 additions & 0 deletions docs/data-sources/user.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "plural_user Data Source - terraform-provider-plural"
subcategory: ""
description: |-
A representation of a user to authenticate to your plural console.
---

# plural_user (Data Source)

A representation of a user to authenticate to your plural console.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `email` (String) Email address of this user.

### Optional

- `id` (String) Internal identifier of this user.

### Read-Only

- `name` (String) Name of the user.
31 changes: 31 additions & 0 deletions docs/resources/global_service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "plural_global_service Resource - terraform-provider-plural"
subcategory: ""
description: |-
GlobalService resource
---

# plural_global_service (Resource)

GlobalService resource



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Name of this GlobalService.
- `service_id` (String) The id of the service that will be replicated by this global service.

### Optional

- `distro` (String) Kubernetes distribution for this global servie, eg EKS, AKS, GKE, K3S.
- `provider_id` (String) Id of a CAPI provider that this global service targets.
- `tags` (Map of String) Key-value tags used to target clusters for this global service.

### Read-Only

- `id` (String) Internal identifier of this GlobalService.
28 changes: 28 additions & 0 deletions docs/resources/group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "plural_group Resource - terraform-provider-plural"
subcategory: ""
description: |-
group resource
---

# plural_group (Resource)

group resource



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Name of this group.

### Optional

- `description` (String) Description of this group.

### Read-Only

- `id` (String) Internal identifier of this group.
25 changes: 25 additions & 0 deletions docs/resources/group_member.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "plural_group_member Resource - terraform-provider-plural"
subcategory: ""
description: |-
GroupMember resource
---

# plural_group_member (Resource)

GroupMember resource



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `group_id` (String) group id for this group member.
- `user_id` (String) user id for this group member.

### Read-Only

- `id` (String) Internal identifier of this group member.
49 changes: 49 additions & 0 deletions docs/resources/rbac.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "plural_rbac Resource - terraform-provider-plural"
subcategory: ""
description: |-
A representation of rbac settings for a provider or cluster.
---

# plural_rbac (Resource)

A representation of rbac settings for a provider or cluster.



<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `bindings` (Attributes) Read and write policies of this resource. (see [below for nested schema](#nestedatt--bindings))
- `cluster_id` (String) The cluster id for these rbac settings
- `service_id` (String) The service id for these rbac settings

<a id="nestedatt--bindings"></a>
### Nested Schema for `bindings`

Optional:

- `read` (Attributes Set) Read policies of this resource. (see [below for nested schema](#nestedatt--bindings--read))
- `write` (Attributes Set) Write policies of this resource. (see [below for nested schema](#nestedatt--bindings--write))

<a id="nestedatt--bindings--read"></a>
### Nested Schema for `bindings.read`

Optional:

- `group_id` (String)
- `id` (String)
- `user_id` (String)


<a id="nestedatt--bindings--write"></a>
### Nested Schema for `bindings.write`

Optional:

- `group_id` (String)
- `id` (String)
- `user_id` (String)
21 changes: 21 additions & 0 deletions internal/resource/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/samber/lo"
"k8s.io/apimachinery/pkg/util/wait"
)

Expand Down Expand Up @@ -128,6 +129,26 @@ func (r *clusterResource) Update(ctx context.Context, req resource.UpdateRequest
return
}

if !data.HelmRepoUrl.Equal(state.HelmRepoUrl) && data.HasKubeconfig() {
clusterWithToken, err := r.client.GetClusterWithToken(ctx, data.Id.ValueStringPointer(), nil)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to fetch cluster deploy token, got error: %s", err))
return
}

handler, err := NewOperatorHandler(ctx, r.client, data.GetKubeconfig(), data.HelmRepoUrl.ValueString(), data.HelmValues.ValueStringPointer(), r.consoleUrl)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to init operator handler, got error: %s", err))
return
}

err = handler.InstallOrUpgrade(lo.FromPtr(clusterWithToken.Cluster.DeployToken))
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to install operator, got error: %s", err))
return
}
}

resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}

Expand Down
Loading