-
Notifications
You must be signed in to change notification settings - Fork 16
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
base: main
Are you sure you want to change the base?
Conversation
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(), |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time.RFC3389
There was a problem hiding this comment.
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)