-
Notifications
You must be signed in to change notification settings - Fork 67
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 scheduled project trigger #620
Conversation
description: |- | ||
This resource manages External feed triggers (release creation type) in Octopus Deploy. |
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.
Was this removed unintentionally as a result of running the terraform-plugin-docs
tool?
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.
Yeah i'm guessing so, ill have a look to see why it was removed
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.
Might be because I didn't have the example listed in the examples folder with the import.sh
thing
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.
Figured it out, you have to specify the description in resource definition. Ill include this and the adding the example to the examples directory in this PR
return &schema.Resource{
CreateContext: resourceExternalFeedCreateReleaseTriggerCreate,
DeleteContext: resourceExternalFeedCreateReleaseTriggerDelete,
Description: "This resource manages External feed triggers (release creation type) in Octopus Deploy.",
Importer: getImporter(),
ReadContext: resourceExternalFeedCreateReleaseTriggerRead,
Schema: getExternalFeedCreateReleaseTriggerSchema(),
UpdateContext: resourceExternalFeedCreateReleaseTriggerUpdate,
}
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.
Nice!
@@ -80,3 +80,5 @@ Read-Only: | |||
|
|||
- `display_name` (String) | |||
- `value` (String) | |||
|
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 assume these newlines were also added automatically by the terraform-plugin-docs
tool?
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. Did it do the same thing for you when you updated the docs last time?
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.
Not for me, but we might have used different versions of the tool 🤷
@@ -0,0 +1 @@ | |||
terraform import [options] octopusdeploy_project_scheduled_trigger.<name> <trigger-id> |
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.
Oh is this how the examples in the docs are supposed to be populated by the docs generator tool?
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 i've added one for the external feed so the doc generator won't overwrite the changes again
flattenedProjectScheduledTrigger["tenant_ids"] = deployLatestReleaseAction.Tenants | ||
flattenedProjectScheduledTrigger["deploy_latest_release_action"] = []map[string]interface{}{ | ||
{ | ||
"source_environment_id": deployLatestReleaseAction.SourceEnvironments[0], |
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.
Is it expected to only take the first source environment from the list?
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.
Yeah, for some reason the API contract has SourceEnvironments as an array but it can only have one element in it otherwise it fails validation. Even on the frontend you can only select one environment. So rather than duplicating that logic on the provider I opted to just having a string property
Required: true, | ||
Type: schema.TypeString, | ||
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsNotWhiteSpace), | ||
ForceNew: true, |
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.
What do these ForceNew
attributes mean for the schema's properties?
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.
It causes the resource to be destroyed and recreated instead of updated when this property changes. So in this case if the project ID changes it will destroy it and recreate the trigger against the new project, without it will attempt to use the update endpoint which "succeeds" but the project doesn't actually change.
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.
Oh, is this a known issue with the update API then?
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.
LGTM!
Background
The terraform provider currently doesn't support scheduled project triggers
Internal Story: sc-73797
Results
fixes #607
This PR adds support for the scheduled project trigger type by adding a new resource
octopusdeploy_project_scheduled_trigger
Example
Once daily schedule
Tenanted Schedule
Runbook Schedule