-
Notifications
You must be signed in to change notification settings - Fork 151
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
Add Org and Workspace Run Tasks resources #488
Conversation
9c47d6d
to
c00e85c
Compare
Org. Run Tasks
Workspace Run Tasks
|
4790231
to
ba6ed79
Compare
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.
We'll need some docs created under website/docs
for the new resources/data sources
5891ecc
to
3d2f497
Compare
Lint errors fixed...now for docs |
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.
Overall things are looking good. I'm going to need to give it a second pass and make sure I didn't overlook any of the fine print! 😆 Hopefully I have given you enough to chew on!
One really important thing to mention is to include the documentation pages as well!
85eb2c2
to
a4dcdec
Compare
Yup I know... |
2921bcd
to
8aa922b
Compare
This commit removes redundant trailing whitespace.
Some tests require an actual Run Tasks service to be running for acceptance tests to complete. This commit adds a new environment variable `RUN_TASKS_URL` which will be used when creating legitimate Run Tasks. This commit also adds a testing helper method to skip tests that require the URL if it is not set.
This commit adds a helper functions `fetchOrganizationRunTask` and `fetchWorkspaceRunTask` which will be used in later commits to be able to find a Run Task by name in an organization or workspace. This commit also adds unit tests for helper and uses uses the mocking provided by the go-tfe module. Later commits will migrate the rest of the project to gomocks.
This commit adds the `data.tfe_organization_run_task` and `resource.tfe_organization_run_task` resources to the provider. These resources will be able to manage Organizational level Run Tasks. This commit also includes acceptance tests for these new resources.
This commit adds the `data.tfe_workspace_run_task` and `resource.tfe_workspace_run_task` resources to the provider. These resources will be able to manage Workspace level Run Tasks. This commit also includes acceptance tests for these new resources.
This commit updates the Run Tasks additional code with fixes for multiple linting errors.
Previously the URL was not validated at TF run time. This commit adds a basic validator to the URL and adds unit tests to confirm the validation.
8aa922b
to
d7e87d7
Compare
@sebasslash All ready for re-review |
d7e87d7
to
bddbe6f
Compare
CI is now running the Run Task acceptance tests e.g.
|
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.
We're in the last stretch of the race! Implementation and testing looks really solid; really neat to see the go-tfe mocks in use. Some minor things below on the documentation! Once addressed, this PR has my approval.
environment: | ||
# Note that https://httpstat.us/200 is enough to test CRUD operations on Run Tasks | ||
# themselves BUT any Runs that use the Run Task will timeout and error | ||
RUN_TASKS_URL: "https://httpstat.us/200" |
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.
🔥 So awesome. Thanks for this Glenn
"url": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ValidateFunc: validation.IsURLWithHTTPorHTTPS, |
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.
Also really nice, I believe in another PR i had suggested url.Parse()
as the validation mechanism for URLs, did not know it was included in SDKv2.
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.
Yup, behind the scenes it's just url.parse. But I'd rather use a SDK helper 😃
|
||
[Run tasks](https://www.terraform.io/cloud-docs/workspaces/settings/run-tasks) allow Terraform Cloud to interact with external systems at specific points in the Terraform Cloud run lifecycle. Run tasks are reusable configurations that you can attach to any workspace in an organization | ||
|
||
The tfe_organization_run_task resource creates, updates and destroys Run tasks. |
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 rephrase this. Typically we give a little more context about the resource if necessary. In this case, we should make the logical distinction between what a Workspace and Organization run task are.
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.
So rather than that, I've adding links to our documentation as it's always up to date and there's a lot of context there which is too big for the provider docs.
This commit adds documentation for the newly provider data and resource objects.
This commit adds the required Environment Variable to the CI Pipeline which will then execute the Run Task tests in CI. Note that https://httpstat.us/200 is enough to test CRUD operations on Run Tasks themselves BUT any Runs that use the Run Task will timeout and error.
ed1d583
to
9526da7
Compare
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.
🚀 🎸 🔥
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.
Just one question about hmac-key. I'm running through some smoke tests now
"hmac_key": { | ||
Type: schema.TypeString, | ||
Sensitive: true, | ||
Default: "", |
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.
Noticing that the API has auditing conditions to handle a nil hmac_key (also nil is allowed in the db). Should the default be nil instead?
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've done some digging and I don't think I can. In the TF provider SDK, the TypeString type always returns a string. And seems to consider a nil/null value as ""
e.g. a zero or nil value for a TypeString is ""
https://github.com/hashicorp/terraform-plugin-sdk/blob/main/helper/schema/schema.go#L2351
So end result is, even if I set hmac_key => nil
or use the default as nil
, it always converts that an empty string and there's nothing I can do about it.
This isn't the fault of the API or go-tfe, but rather TF internals.
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 question is then asked... if TypeString is not correct, what type should I be using? the answer is, I don't think there is a better option. The only one that supports nil-able is TypeSet.
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.
Smoke tested ✅
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.
@glennsarti I think I made a mistake with how rails is handling this because hmac_key appears to be nil unless I set it to an actual string. Thanks for entertaining my ideas, nonetheless!
Description
This PR adds the
data.tfe_workspace_run_task
andresource.tfe_workspace_run_task
resources to the provider. Theseresources will be able to manage Workspace level Run Tasks.
This PR adds the
data.tfe_organization_run_task
andresource.tfe_organization_run_task
resources to the provider. Theseresources will be able to manage Organizational level Run Tasks.
Testing plan
N/A Included Acceptance Tests
External links
Output from acceptance tests
Acceptance TFC instance isn't setup for Run Tasks yet. Manual tests against my local environment are detailed in the commentsIt is is now!