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

Update kubeconfig when invalid #627

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Fyusel
Copy link
Contributor

@Fyusel Fyusel commented Jan 15, 2025

  • kubeconfig expires
  • credentials rotation
  • cluster recreation

- kubeconfig expires
- credentials rotation
- cluster recreation

Signed-off-by: Alexander Dahmen <[email protected]>
Description: descriptions["creation_time"],
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not to sure here. Wouldn't RequiresReplace force a recreation of the cluster, when the creation time has been updated? I have'nt tested it though

@@ -246,6 +257,21 @@ func (r *kubeconfigResource) Read(ctx context.Context, req resource.ReadRequest,
ctx = tflog.SetField(ctx, "cluster_name", clusterName)
ctx = tflog.SetField(ctx, "kube_config_id", kubeconfigUUID)

cluster, err := r.client.GetClusterExecute(ctx, projectId, clusterName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend to extract helper functions for this and the following block to keep this function a little bit shorter (and facilitate testing).

return
}

creationTime, err := time.Parse("2006-01-02T15:04:05Z07:00", model.CreationTime.ValueString())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pattern is the same as time.RFC3339, we should use that one


// check credentials rotation
if cluster.Status.CredentialsRotation.LastCompletionTime != nil {
lastCompletionTime, err := time.Parse("2006-01-02T15:04:05Z07:00", *cluster.Status.CredentialsRotation.LastCompletionTime)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above, time.RFC3389


// check cluster recreation
if cluster.Status.CreationTime != nil {
clusterCreationTime, err := time.Parse("2006-01-02T15:04:05Z07:00", *cluster.Status.CreationTime)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time.RFC3389

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose to add testcases for the added functionality (which would have to extracted to dedicated functions first)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SKE: stackit_ske_kubeconfig misses relation to its stackit_ske_cluster
2 participants