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

Feat: add update_window to workspace_group for create/update #20

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

pbr0ck3r
Copy link
Contributor

No description provided.

@pbr0ck3r pbr0ck3r force-pushed the add-update-window-to-workspace-group-resource branch from a2d3d84 to a4e0f2c Compare June 30, 2023 14:26
@pbr0ck3r
Copy link
Contributor Author

Getting the following error when applying and assume it is because the API might not be returning update_window or allowing it to be passed in via the management.go library.

When applying changes to singlestoredb_workspace_group.this, provider "provider[\"registry.terraform.io/hashicorp/singlestoredb\"]" produced an unexpected new value: .update_window: was cty.ObjectVal(map[string]cty.Value{"day":cty.NumberIntVal(6), "hour":cty.NumberIntVal(17)}), but now null.

Copy link
Collaborator

@noprysk-ua noprysk-ua left a comment

Choose a reason for hiding this comment

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

Hi Phil,

Thank you for creating the MR that adds the update window functionality to the workspace group resource!

The current state of the MR is a solid foundation.

  1. Our team is working on setting update window details on the creation of a workspace group and this MR is blocked on the feature because, otherwise, the behavior of the provider is not consistent. E.g., an operator indicates Sunday yet gets a random day and overrides the random day only on the second terraform apply run. I'll make sure to notify you once the functionality is ready.

  2. The MR only implements updating the state, yet does not implement reading the state from remote. The function toWorkspaceGroupResourceModel is the relevant converter that should be changed. It's essential to provide proper reading as it will enable the proper resolution of deltas.

  3. By the convention of the current repository, almost all the functionality is covered by unit and integration tests. Make sure to extend the MR with both unit and integration tests. Note that it would be enough to extend tests that already exist.

Best,
Nestor

P.S. After resolving the comments, #20 (comment) should disappear. The error is because of the provider never forwards the hour and day that is read from the Management API (2).

internal/provider/workspacegroups/resource.go Outdated Show resolved Hide resolved
.tool-versions Outdated Show resolved Hide resolved
@noprysk-ua
Copy link
Collaborator

The updateWindow input for a workspace group creation is now live. Moreover, the latest version of the Golang client for the Management API is pulled to this repo.

@pbr0ck3r
Copy link
Contributor Author

pbr0ck3r commented Jul 7, 2023

The updateWindow input for a workspace group creation is now live. Moreover, the latest version of the Golang client for the Management API is pulled to this repo.

Has the operator code been deployed yet? Began adjusting tests and still receive a random day/hour.

@noprysk-ua
Copy link
Collaborator

The updateWindow input for a workspace group creation is now live. Moreover, the latest version of the Golang client for the Management API is pulled to this repo.

Has the operator code been deployed yet? Began adjusting tests and still receive a random day/hour.

Yes. The current version of the PR does not pass day and hour as input. This is a possible reason for the confusion.

I've just verified that all works fine with a curl request like this.

curl -X POST "https://api.singlestore.com/v1/workspaceGroups" -H "accept: application/json" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d "{\"adminPassword\":\"qw5erASDF19\",\"firewallRanges\":[],\"name\":\"demo-workspace-group\",\"regionID\":\"7e7ffd27-20f7-44b6-87e6-e72828a81ac7\", \"updateWindow\":{\"day\":1,\"hour\":2}}"
{"workspaceGroupID":"936580ff-215f-4e43-b0bd-2ec1a5561ddc"}
curl -X GET "https://api.singlestore.com/v1/workspaceGroups" -H "accept: application/json" -H "Authorization: Bearer $API_KEY"
[{"name":"demo-workspace-group","state":"PENDING","workspaceGroupID":"936580ff-215f-4e43-b0bd-2ec1a5561ddc","createdAt":"2023-07-07T14:53:57.007404Z","regionID":"7e7ffd27-20f7-44b6-87e6-e72828a81ac7","updateWindow":{"hour":2,"day":1}}]

Note that hour is 2, just as indicated in input and the day is 1, which is consistent with the input as well.

@pbr0ck3r pbr0ck3r force-pushed the add-update-window-to-workspace-group-resource branch from aaedb62 to 5235ab1 Compare July 20, 2023 14:28
@pbr0ck3r pbr0ck3r temporarily deployed to test July 20, 2023 14:28 — with GitHub Actions Inactive
@pbr0ck3r pbr0ck3r force-pushed the add-update-window-to-workspace-group-resource branch from fb5daec to de7b714 Compare July 20, 2023 18:51
@pbr0ck3r pbr0ck3r temporarily deployed to test July 20, 2023 18:52 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #20 (de7b714) into master (3ee4e67) will decrease coverage by 0.02%.
The diff coverage is 81.81%.

@@            Coverage Diff             @@
##           master      #20      +/-   ##
==========================================
- Coverage   73.56%   73.54%   -0.02%     
==========================================
  Files          18       18              
  Lines        1528     1561      +33     
==========================================
+ Hits         1124     1148      +24     
- Misses        335      341       +6     
- Partials       69       72       +3     
Impacted Files Coverage Δ
internal/provider/workspacegroups/resource.go 63.36% <81.81%> (+2.25%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pbr0ck3r
Copy link
Contributor Author

pbr0ck3r commented Jul 20, 2023

@noprysk-ua , went ahead and updated the tests. I can also test the helper functions toManagementUpdateWindow and toUpdateWindowResourceModel I added in a follow up PR similar to the util tests.

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.

2 participants