Skip to content

Commit 59a0567

Browse files
committed
Make release_id required for pipeline promotions
- Change release_id from Optional to Required in schema - Remove conditional logic in Create function since release_id is always present - Update documentation to reflect required field - Update unit test to validate release_id as required field - Simplify examples and descriptions to focus on specific release promotion - This provides clearer, more predictable behavior for users
1 parent dbd04cc commit 59a0567

File tree

3 files changed

+15
-39
lines changed

3 files changed

+15
-39
lines changed

docs/resources/pipeline_promotion.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,15 @@ description: |-
1111
Provides a [Heroku Pipeline Promotion](https://devcenter.heroku.com/articles/pipelines)
1212
resource.
1313

14-
A pipeline promotion allows you to deploy releases from one app to other apps within the same
14+
A pipeline promotion allows you to deploy a specific release from one app to other apps within the same
1515
pipeline. This enables infrastructure-as-code workflow for promoting code between pipeline stages
1616
such as staging to production.
1717

18-
You can promote either the latest release from the source app, or specify a particular release by ID.
19-
2018
## Example Usage
2119

2220
```hcl
23-
# Basic promotion from staging to production (latest release)
21+
# Basic promotion from staging to production
2422
resource "heroku_pipeline_promotion" "staging_to_prod" {
25-
pipeline = heroku_pipeline.my_app.id
26-
source_app_id = heroku_app.staging.id
27-
targets = [heroku_app.production.id]
28-
}
29-
30-
# Promotion of a specific release
31-
resource "heroku_pipeline_promotion" "specific_release" {
3223
pipeline = heroku_pipeline.my_app.id
3324
source_app_id = heroku_app.staging.id
3425
release_id = "01234567-89ab-cdef-0123-456789abcdef"
@@ -39,6 +30,7 @@ resource "heroku_pipeline_promotion" "specific_release" {
3930
resource "heroku_pipeline_promotion" "staging_to_multiple" {
4031
pipeline = heroku_pipeline.my_app.id
4132
source_app_id = heroku_app.staging.id
33+
release_id = "01234567-89ab-cdef-0123-456789abcdef"
4234
targets = [
4335
heroku_app.production.id,
4436
heroku_app.demo.id
@@ -53,7 +45,7 @@ The following arguments are supported:
5345
* `pipeline` - (Required) The UUID of the pipeline containing the apps.
5446
* `source_app_id` - (Required) The UUID of the source app to promote from.
5547
* `targets` - (Required) Set of UUIDs of target apps to promote to.
56-
* `release_id` - (Optional) The UUID of a specific release to promote. If not specified, promotes the latest release from the source app.
48+
* `release_id` - (Required) The UUID of the specific release to promote.
5749

5850
## Attributes Reference
5951

@@ -69,6 +61,6 @@ The following attributes are exported:
6961
* Pipeline promotions are immutable - they cannot be updated or modified after creation.
7062
* All apps (source and targets) must be in the same pipeline.
7163
* All apps must have the same generation (Cedar or Fir). See [`heroku_pipeline`](./pipeline.html) for generation compatibility requirements.
72-
* The source app must have at least one release to promote.
73-
* Promotions copy either the latest release (if no `release_id` specified) or the specified release to all target apps.
64+
* The specified release must exist on the source app.
65+
* Promotions copy the specified release to all target apps.
7466

heroku/resource_heroku_pipeline_promotion.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ func resourceHerokuPipelinePromotion() *schema.Resource {
3939

4040
"release_id": {
4141
Type: schema.TypeString,
42-
Optional: true,
42+
Required: true,
4343
ForceNew: true,
4444
ValidateFunc: validation.IsUUID,
45-
Description: "Specific release ID to promote (optional, defaults to latest release)",
45+
Description: "Release ID to promote to target apps",
4646
},
4747

4848
"targets": {
@@ -94,14 +94,12 @@ func resourceHerokuPipelinePromotionCreate(d *schema.ResourceData, meta interfac
9494
ID *string `json:"id,omitempty" url:"id,omitempty,key"`
9595
}{ID: &sourceAppID}
9696

97-
// Add release_id if specified
98-
if releaseID, ok := d.GetOk("release_id"); ok {
99-
releaseIDStr := releaseID.(string)
100-
opts.Source.Release = &struct {
101-
ID *string `json:"id,omitempty" url:"id,omitempty,key"`
102-
}{ID: &releaseIDStr}
103-
log.Printf("[DEBUG] Promoting specific release: %s", releaseIDStr)
104-
}
97+
// Set required release_id
98+
releaseIDStr := d.Get("release_id").(string)
99+
opts.Source.Release = &struct {
100+
ID *string `json:"id,omitempty" url:"id,omitempty,key"`
101+
}{ID: &releaseIDStr}
102+
log.Printf("[DEBUG] Promoting release: %s", releaseIDStr)
105103

106104
// Convert targets set to slice
107105
for _, target := range targets.List() {

heroku/resource_heroku_pipeline_promotion_test.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func TestResourceHerokuPipelinePromotion_Schema(t *testing.T) {
1010
resource := resourceHerokuPipelinePromotion()
1111

1212
// Test required fields
13-
requiredFields := []string{"pipeline", "source_app_id", "targets"}
13+
requiredFields := []string{"pipeline", "source_app_id", "targets", "release_id"}
1414
for _, field := range requiredFields {
1515
if _, ok := resource.Schema[field]; !ok {
1616
t.Errorf("Required field %s not found in schema", field)
@@ -23,20 +23,6 @@ func TestResourceHerokuPipelinePromotion_Schema(t *testing.T) {
2323
}
2424
}
2525

26-
// Test optional fields
27-
optionalFields := []string{"release_id"}
28-
for _, field := range optionalFields {
29-
if _, ok := resource.Schema[field]; !ok {
30-
t.Errorf("Optional field %s not found in schema", field)
31-
}
32-
if !resource.Schema[field].Optional {
33-
t.Errorf("Field %s should be optional", field)
34-
}
35-
if !resource.Schema[field].ForceNew {
36-
t.Errorf("Field %s should be ForceNew", field)
37-
}
38-
}
39-
4026
// Test computed fields
4127
computedFields := []string{"status", "created_at", "promoted_release_id"}
4228
for _, field := range computedFields {

0 commit comments

Comments
 (0)