-
Notifications
You must be signed in to change notification settings - Fork 41
chore(logs): sdk migration #1444
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
base: main
Are you sure you want to change the base?
Changes from all commits
1372252
38ff1d3
5447fbb
8ef4d89
4098401
0828dcc
d49c4d6
d5a7dea
ec6d17b
90cbdf5
7a771cb
8e40ee0
9598563
ac06109
32cb71a
d0aaf17
9c616a0
2de621d
d69ef93
12550ad
7628620
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,7 @@ import ( | |||||||
| "github.com/google/go-cmp/cmp" | ||||||||
| "github.com/google/go-cmp/cmp/cmpopts" | ||||||||
| "github.com/google/uuid" | ||||||||
| "github.com/stackitcloud/stackit-sdk-go/services/logs" | ||||||||
| logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" | ||||||||
| ) | ||||||||
|
|
||||||||
| const ( | ||||||||
|
|
@@ -26,7 +26,7 @@ type testCtxKey struct{} | |||||||
|
|
||||||||
| var ( | ||||||||
| testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") | ||||||||
| testClient = &logs.APIClient{} | ||||||||
| testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} | ||||||||
| testProjectId = uuid.NewString() | ||||||||
| testInstanceId = uuid.NewString() | ||||||||
| ) | ||||||||
|
|
@@ -59,7 +59,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { | |||||||
| InstanceId: testInstanceId, | ||||||||
| Description: utils.Ptr(testDescription), | ||||||||
| DisplayName: testDisplayName, | ||||||||
| Lifetime: utils.Ptr(int64(0)), | ||||||||
| Lifetime: utils.Ptr(int32(0)), | ||||||||
| Permissions: []string{ | ||||||||
| "read", | ||||||||
| "write", | ||||||||
|
|
@@ -72,7 +72,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { | |||||||
| } | ||||||||
|
|
||||||||
| func fixtureRequest(mods ...func(request *logs.ApiCreateAccessTokenRequest)) logs.ApiCreateAccessTokenRequest { | ||||||||
| request := testClient.CreateAccessToken(testCtx, testProjectId, testRegion, testInstanceId) | ||||||||
| request := testClient.DefaultAPI.CreateAccessToken(testCtx, testProjectId, testRegion, testInstanceId) | ||||||||
| request = request.CreateAccessTokenPayload(fixturePayload()) | ||||||||
| for _, mod := range mods { | ||||||||
| mod(&request) | ||||||||
|
|
@@ -82,13 +82,13 @@ func fixtureRequest(mods ...func(request *logs.ApiCreateAccessTokenRequest)) log | |||||||
|
|
||||||||
| func fixturePayload(mods ...func(payload *logs.CreateAccessTokenPayload)) logs.CreateAccessTokenPayload { | ||||||||
| payload := logs.CreateAccessTokenPayload{ | ||||||||
| DisplayName: utils.Ptr(testDisplayName), | ||||||||
| DisplayName: testDisplayName, | ||||||||
| Description: utils.Ptr(testDescription), | ||||||||
| Lifetime: utils.Ptr(int64(0)), | ||||||||
| Permissions: utils.Ptr([]string{ | ||||||||
| Lifetime: utils.Ptr(int32(0)), | ||||||||
| Permissions: []logs.PermissionsInner{ | ||||||||
| "read", | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Why not use the constants? |
||||||||
| "write", | ||||||||
| }), | ||||||||
| }, | ||||||||
| } | ||||||||
| for _, mod := range mods { | ||||||||
| mod(&payload) | ||||||||
|
|
@@ -216,6 +216,8 @@ func TestBuildRequest(t *testing.T) { | |||||||
| diff := cmp.Diff(tt.expectedRequest, request, | ||||||||
| cmp.AllowUnexported(tt.expectedRequest), | ||||||||
| cmpopts.EquateComparable(testCtx), | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
and then remove the line below cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), |
||||||||
| cmpopts.IgnoreFields(tt.expectedRequest, "ApiService"), | ||||||||
| cmpopts.EquateEmpty(), | ||||||||
| ) | ||||||||
| if diff != "" { | ||||||||
| t.Fatalf("Data does not match: %s", diff) | ||||||||
|
|
@@ -240,16 +242,16 @@ func TestOutputResult(t *testing.T) { | |||||||
| args: args{ | ||||||||
| instanceLabel: "", | ||||||||
| accessToken: utils.Ptr(logs.AccessToken{ | ||||||||
| Id: utils.Ptr(uuid.NewString()), | ||||||||
| Permissions: utils.Ptr([]string{ | ||||||||
| Id: uuid.NewString(), | ||||||||
| Permissions: []logs.PermissionsInner{ | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||||||||
| "read", | ||||||||
| "write", | ||||||||
| }), | ||||||||
| DisplayName: utils.Ptr("Token"), | ||||||||
| }, | ||||||||
| DisplayName: "Token", | ||||||||
| AccessToken: utils.Ptr("Secret access token"), | ||||||||
| Creator: utils.Ptr(uuid.NewString()), | ||||||||
| Expires: utils.Ptr(false), | ||||||||
| Status: utils.Ptr(logs.ACCESSTOKENSTATUS_ACTIVE), | ||||||||
| Creator: uuid.NewString(), | ||||||||
| Expires: false, | ||||||||
| Status: logs.ACCESSTOKENSTATUS_ACTIVE, | ||||||||
| }), | ||||||||
| }, | ||||||||
| wantErr: false, | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,7 +10,7 @@ import ( | |||||
| "github.com/google/go-cmp/cmp" | ||||||
| "github.com/google/go-cmp/cmp/cmpopts" | ||||||
| "github.com/google/uuid" | ||||||
| "github.com/stackitcloud/stackit-sdk-go/services/logs" | ||||||
| logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" | ||||||
| ) | ||||||
|
|
||||||
| const ( | ||||||
|
|
@@ -21,7 +21,7 @@ type testCtxKey struct{} | |||||
|
|
||||||
| var ( | ||||||
| testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") | ||||||
| testClient = &logs.APIClient{} | ||||||
| testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} | ||||||
|
|
||||||
| testProjectId = uuid.NewString() | ||||||
| testInstanceId = uuid.NewString() | ||||||
|
|
@@ -69,7 +69,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { | |||||
| } | ||||||
|
|
||||||
| func fixtureRequest(mods ...func(request *logs.ApiDeleteAccessTokenRequest)) logs.ApiDeleteAccessTokenRequest { | ||||||
| request := testClient.DeleteAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId) | ||||||
| request := testClient.DefaultAPI.DeleteAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId) | ||||||
| for _, mod := range mods { | ||||||
| mod(&request) | ||||||
| } | ||||||
|
|
@@ -197,7 +197,7 @@ func TestBuildRequest(t *testing.T) { | |||||
|
|
||||||
| diff := cmp.Diff(request, tt.expectedRequest, | ||||||
| cmp.AllowUnexported(tt.expectedRequest), | ||||||
| cmpopts.EquateComparable(testCtx), | ||||||
| cmpopts.EquateComparable(testCtx, tt.expectedRequest), | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is that change needed? 😅
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's the same as above, the thing you aim to do should look like this
Suggested change
|
||||||
| ) | ||||||
| if diff != "" { | ||||||
| t.Fatalf("Data does not match: %s", diff) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ import ( | |
| "github.com/google/go-cmp/cmp" | ||
| "github.com/google/go-cmp/cmp/cmpopts" | ||
| "github.com/google/uuid" | ||
| "github.com/stackitcloud/stackit-sdk-go/services/logs" | ||
| logs "github.com/stackitcloud/stackit-sdk-go/services/logs/v1api" | ||
| ) | ||
|
|
||
| const ( | ||
|
|
@@ -21,7 +21,7 @@ type testCtxKey struct{} | |
|
|
||
| var ( | ||
| testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo") | ||
| testClient = &logs.APIClient{} | ||
| testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}} | ||
|
|
||
| testProjectId = uuid.NewString() | ||
| testInstanceId = uuid.NewString() | ||
|
|
@@ -57,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel { | |
| } | ||
|
|
||
| func fixtureRequest(mods ...func(request *logs.ApiDeleteAllAccessTokensRequest)) logs.ApiDeleteAllAccessTokensRequest { | ||
| request := testClient.DeleteAllAccessTokens(testCtx, testProjectId, testRegion, testInstanceId) | ||
| request := testClient.DefaultAPI.DeleteAllAccessTokens(testCtx, testProjectId, testRegion, testInstanceId) | ||
| for _, mod := range mods { | ||
| mod(&request) | ||
| } | ||
|
|
@@ -153,7 +153,7 @@ func TestBuildRequest(t *testing.T) { | |
|
|
||
| diff := cmp.Diff(request, tt.expectedRequest, | ||
| cmp.AllowUnexported(tt.expectedRequest), | ||
| cmpopts.EquateComparable(testCtx), | ||
| cmpopts.EquateComparable(testCtx, tt.expectedRequest), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| ) | ||
| if diff != "" { | ||
| t.Fatalf("Data does not match: %s", diff) | ||
|
|
||
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 suggest you copy that map function to our CLI (if not already present, pls check): https://github.com/stackitcloud/terraform-provider-stackit/blob/ffa60e66b90353ccdc074632a90c76bc3fe9cb0a/stackit/internal/utils/utils.go#L222-L229
Then it's just an inline call which is needed, see below