feat(ske): add refresh_before field to ske_kubeconfig resource (#1000)

This commit is contained in:
Maximilian Bischoff 2025-10-06 10:52:53 +02:00 committed by GitHub
parent 5f71eef4a9
commit 0763a5f01f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 64 additions and 24 deletions

View file

@ -26,14 +26,15 @@ func TestMapFields(t *testing.T) {
Kubeconfig: utils.Ptr("kubeconfig"),
},
Model{
ClusterName: types.StringValue("name"),
ProjectId: types.StringValue("pid"),
Kubeconfig: types.StringValue("kubeconfig"),
Expiration: types.Int64Null(),
Refresh: types.BoolNull(),
ExpiresAt: types.StringValue("2024-02-07T16:42:12Z"),
CreationTime: types.StringValue("2024-02-05T14:40:12Z"),
Region: types.StringValue(testRegion),
ClusterName: types.StringValue("name"),
ProjectId: types.StringValue("pid"),
Kubeconfig: types.StringValue("kubeconfig"),
Expiration: types.Int64Null(),
Refresh: types.BoolNull(),
RefreshBefore: types.Int64Null(),
ExpiresAt: types.StringValue("2024-02-07T16:42:12Z"),
CreationTime: types.StringValue("2024-02-05T14:40:12Z"),
Region: types.StringValue(testRegion),
},
true,
},
@ -169,6 +170,17 @@ func TestCheckHasExpired(t *testing.T) {
expected: false,
expectedError: false,
},
{
description: "not expired but refresh_before reached",
inputModel: &Model{
Refresh: types.BoolValue(true),
RefreshBefore: types.Int64Value(int64(time.Hour.Seconds())),
ExpiresAt: types.StringValue(time.Now().Add(1 * time.Hour).Format(time.RFC3339)), // in one hour
},
currentTime: time.Now(),
expected: true,
expectedError: false,
},
{
description: "invalid time",
inputModel: &Model{