Skip to content

Commit

Permalink
Merge branch 'main' into fnm/scheduled-trigger-new-client
Browse files Browse the repository at this point in the history
  • Loading branch information
bec-callow-oct committed Dec 19, 2024
2 parents 6955953 + 6643d95 commit 47eecb0
Show file tree
Hide file tree
Showing 28 changed files with 1,754 additions and 103 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/prevent-new-sdk-additions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Prevent New Terraform SDK additions

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
detect-new-sdk-files:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Check for new SDK resources or datasources
run: |
git diff --name-status origin/main..${{ vars.GITHUB_REF }} | grep '^A' | grep '^A\s\+octopusdeploy/' > new_files.txt || true
if [ -s new_files.txt ]; then
echo "New files were found in the 'octopusdeploy/' directory."
cat new_files.txt
echo "::error::We are no longer creating new Terraform SDK resources or datasources. Anything new should be added using Terraform Framework in the 'octopusdeploy_framework' folder instead."
exit 1
else
echo "::notice::No new files detected in the 'octopusdeploy/' directory."
fi
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,16 @@ Terraform will scan the local plugins folder directory structure (first) to qual

## Create a New Resource

The provider is currently undergoing migration from Terraform SDK to Terraform Plugin Framework. Ensure all **new** resources are created under the `octopusdeploy-framework` directory using existing resources within the `octopusdeploy-framework` directory as a guideline.
> [!IMPORTANT]
> We're currently migrating all resources and data sources from Terraform SDK to Terraform Plugin Framework.
>
> All new resources should be created using Framework, in the `octopusdeploy-framework` directory. [A GitHub action](.github/workflows/prevent-new-sdk-additions.yml) will detect and prevent any new additions to the old `octopusdeploy` SDK directory.
>
> When modifying an existing SDK resource, we strongly recommend migrating it to Framework first - but this might not always be feasible. We'll judge it on a case-by-case basis.
All new resources need an acceptance test that will ensure the lifecycle of the resource works correctly this includes Create, Read, Update and Delete.

Please avoid using blocks in favour of nested attribute types. Blocks are mainly used for resources migrated from SDK to maintain backwards compatability.
Please avoid using [blocks](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/blocks): these are mainly used for backwards compatability of resources migrated from SDK. Use [nested attributes](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/attributes#nested-attribute-types) instead.

## Debugging
If you want to debug the provider follow these steps!
Expand Down
51 changes: 51 additions & 0 deletions docs/data-sources/deployment_freezes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,29 @@ description: |-

Provides information about deployment freezes

## Example Usage

```terraform
data "octopusdeploy_deployment_freezes" "test_freeze" {
ids = null
partial_name = "Freeze Name"
skip = 5
take = 100
}
data "octopusdeploy_deployment_freezes" "project_freezes" {
project_ids = ["projects-1"]
skip = 0
take = 5
}
data "octopusdeploy_deployment_freezes" "tenant_freezes" {
tenant_ids = ["tenants-1"]
skip = 0
take = 10
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -25,6 +47,7 @@ Provides information about deployment freezes
- `skip` (Number) A filter to specify the number of items to skip in the response.
- `status` (String) Filter by the status of the deployment freeze, value values are Expired, Active, Scheduled (case-insensitive)
- `take` (Number) A filter to specify the number of items to take (or return) in the response.
- `tenant_ids` (List of String) A filter to search by a list of tenant IDs

### Read-Only

Expand All @@ -40,6 +63,34 @@ Read-Only:
- `id` (String) The unique ID for this resource.
- `name` (String) The name of this resource.
- `project_environment_scope` (Map of List of String) The project environment scope of the deployment freeze
- `recurring_schedule` (Attributes) (see [below for nested schema](#nestedatt--deployment_freezes--recurring_schedule))
- `start` (String) The start time of the freeze
- `tenant_project_environment_scope` (Attributes List) The tenant project environment scope of the deployment freeze (see [below for nested schema](#nestedatt--deployment_freezes--tenant_project_environment_scope))

<a id="nestedatt--deployment_freezes--recurring_schedule"></a>
### Nested Schema for `deployment_freezes.recurring_schedule`

Read-Only:

- `date_of_month` (String) The date of the month for monthly schedules
- `day_number_of_month` (String) The day number of the month for monthly schedules
- `day_of_week` (String) The day of the week for monthly schedules
- `days_of_week` (List of String) List of days of the week for weekly schedules
- `end_after_occurrences` (Number) Number of occurrences after which the schedule should end
- `end_on_date` (String) The date when the recurring schedule should end
- `end_type` (String) When the recurring schedule should end (Never, OnDate, AfterOccurrences)
- `monthly_schedule_type` (String) Type of monthly schedule (DayOfMonth, DateOfMonth)
- `type` (String) Type of recurring schedule (OnceDaily, DaysPerWeek, DaysPerMonth, Annually)
- `unit` (Number) The unit value for the schedule


<a id="nestedatt--deployment_freezes--tenant_project_environment_scope"></a>
### Nested Schema for `deployment_freezes.tenant_project_environment_scope`

Read-Only:

- `environment_id` (String) The environment ID
- `project_id` (String) The project ID
- `tenant_id` (String) The tenant ID


35 changes: 35 additions & 0 deletions docs/resources/deployment_freeze.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ resource "octopusdeploy_deployment_freeze" "freeze" {
end = "2024-12-27T00:00:00+08:00"
}
# Freeze recurring freeze yearly on Xmas
resource "octopusdeploy_deployment_freeze" "freeze" {
name = "Xmas"
start = "2024-12-25T00:00:00+10:00"
end = "2024-12-27T00:00:00+08:00"
recurring_schedule = {
type = "Annually"
unit = 1
end_type = "Never"
}
}
resource "octopusdeploy_deployment_freeze_project" "project_freeze" {
deploymentfreeze_id= octopusdeploy_deployment_freeze.freeze.id
project_id = "Projects-123"
Expand Down Expand Up @@ -69,8 +81,31 @@ resource "octopusdeploy_deployment_freeze_tenant" "tenant_freeze" {
- `name` (String) The name of this resource.
- `start` (String) The start time of the freeze, must be RFC3339 format

### Optional

- `recurring_schedule` (Attributes) (see [below for nested schema](#nestedatt--recurring_schedule))

### Read-Only

- `id` (String) The unique ID for this resource.

<a id="nestedatt--recurring_schedule"></a>
### Nested Schema for `recurring_schedule`

Required:

- `end_type` (String) When the recurring schedule should end (Never, OnDate, AfterOccurrences)
- `type` (String) Type of recurring schedule (Daily, Weekly, Monthly, Annually)
- `unit` (Number) The unit value for the schedule

Optional:

- `date_of_month` (String) The date of the month for monthly schedules
- `day_number_of_month` (String) Specifies which weekday position in the month. Valid values: 1 (First), 2 (Second), 3 (Third), 4 (Fourth), L (Last). Used with day_of_week
- `day_of_week` (String) The day of the week for monthly schedules when using DayOfMonth type
- `days_of_week` (List of String) List of days of the week for weekly schedules. Must follow order: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
- `end_after_occurrences` (Number) Number of occurrences after which the schedule should end
- `end_on_date` (String) The date when the recurring schedule should end
- `monthly_schedule_type` (String) Type of monthly schedule (DayOfMonth, DateOfMonth)


73 changes: 73 additions & 0 deletions docs/resources/git_trigger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "octopusdeploy_git_trigger Resource - terraform-provider-octopusdeploy"
subcategory: ""
description: |-
This resource manages Git triggers in Octopus Deploy
---

# octopusdeploy_git_trigger (Resource)

This resource manages Git triggers in Octopus Deploy

## Example Usage

```terraform
resource "octopusdeploy_git_trigger" "my_trigger" {
name = "My Git trigger"
space_id = "Spaces-1"
description = "My Git trigger description"
project_id = "Projects-1"
channel_id = "Channels-1"
sources {
deployment_action_slug = "deploy-action-slug"
git_dependency_name = ""
include_file_paths = [
"include/me",
"include/this/too"
]
exclude_file_paths = [
"exclude/me",
"exclude/this/too"
]
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `channel_id` (String) The ID of the channel in which the release will be created if the action type is CreateRelease.
- `name` (String) The name of this resource.
- `project_id` (String) The ID of the project to attach the trigger.
- `sources` (Attributes List) (see [below for nested schema](#nestedatt--sources))

### Optional

- `description` (String) The description of this Git trigger..
- `is_disabled` (Boolean) Disables the trigger from being run when set.
- `space_id` (String) The space ID associated with this Git trigger.

### Read-Only

- `id` (String) The unique ID for this resource.

<a id="nestedatt--sources"></a>
### Nested Schema for `sources`

Required:

- `deployment_action_slug` (String) The deployment action slug.
- `exclude_file_paths` (List of String) The file paths to exclude.
- `git_dependency_name` (String) The git dependency name.
- `include_file_paths` (List of String) The file paths to include.

## Import

Import is supported using the following syntax:

```shell
terraform import [options] octopusdeploy_git_trigger.<name> <trigger-id>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
data "octopusdeploy_deployment_freezes" "test_freeze" {
ids = null
partial_name = "Freeze Name"
skip = 5
take = 100
}


data "octopusdeploy_deployment_freezes" "project_freezes" {
project_ids = ["projects-1"]
skip = 0
take = 5
}

data "octopusdeploy_deployment_freezes" "tenant_freezes" {
tenant_ids = ["tenants-1"]
skip = 0
take = 10
}
12 changes: 12 additions & 0 deletions examples/resources/octopusdeploy_deployment_freeze/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ resource "octopusdeploy_deployment_freeze" "freeze" {
end = "2024-12-27T00:00:00+08:00"
}

# Freeze recurring freeze yearly on Xmas
resource "octopusdeploy_deployment_freeze" "freeze" {
name = "Xmas"
start = "2024-12-25T00:00:00+10:00"
end = "2024-12-27T00:00:00+08:00"
recurring_schedule = {
type = "Annually"
unit = 1
end_type = "Never"
}
}

resource "octopusdeploy_deployment_freeze_project" "project_freeze" {
deploymentfreeze_id= octopusdeploy_deployment_freeze.freeze.id
project_id = "Projects-123"
Expand Down
1 change: 1 addition & 0 deletions examples/resources/octopusdeploy_git_trigger/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import [options] octopusdeploy_git_trigger.<name> <trigger-id>
19 changes: 19 additions & 0 deletions examples/resources/octopusdeploy_git_trigger/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "octopusdeploy_git_trigger" "my_trigger" {
name = "My Git trigger"
space_id = "Spaces-1"
description = "My Git trigger description"
project_id = "Projects-1"
channel_id = "Channels-1"
sources {
deployment_action_slug = "deploy-action-slug"
git_dependency_name = ""
include_file_paths = [
"include/me",
"include/this/too"
]
exclude_file_paths = [
"exclude/me",
"exclude/this/too"
]
}
}
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/OctopusDeploy/go-octodiff v1.0.0 h1:U+ORg6azniwwYo+O44giOw6TiD5USk8S4VDhOQ0Ven0=
github.com/OctopusDeploy/go-octodiff v1.0.0/go.mod h1:Mze0+EkOWTgTmi8++fyUc6r0aLZT7qD9gX+31t8MmIU=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.63.1 h1:ShfJ3VZqNblU5V0UnA/UNjQuUrgkljZdDp9Vxh8rhcI=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.63.1/go.mod h1:ggvOXzMnq+w0pLg6C9zdjz6YBaHfO3B3tqmmB7JQdaw=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.64.0 h1:NWqQ/7JLUfEJQ8QHrkek7AfePuN121+f6+tUi3xP6vE=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.64.0/go.mod h1:ggvOXzMnq+w0pLg6C9zdjz6YBaHfO3B3tqmmB7JQdaw=
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20241206032352-dbc62b2d16cf h1:wuUJ6DbSZEHE4a3SfSJIcoeTQCSI6lbQ+i46ibY14+Q=
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v0.0.0-20241206032352-dbc62b2d16cf/go.mod h1:xVv8DvYhhwxtQUQQDfOYA6CY8KTkHXccxQ2RfRj6IJ0=
Expand Down
Loading

0 comments on commit 47eecb0

Please sign in to comment.