Skip to content

Commit 2eceed8

Browse files
authored
Merge pull request #290 from ANUGRAHG/main
feat: support of stopped argument for cloudfoundry application
2 parents 919d290 + c800c64 commit 2eceed8

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

cloudfoundry/provider/resource_app.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ func (r *appResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *
200200
},
201201
},
202202
},
203+
"stopped": schema.BoolAttribute{
204+
MarkdownDescription: "Whether the application is started or stopped after creation. By default, this value is false, meaning the application will be started automatically after creation.",
205+
Optional: true,
206+
},
203207
"environment": schema.MapAttribute{
204208
MarkdownDescription: "Key/value pairs of custom environment variables to set in your app. Does not include any system or service variables.",
205209
Optional: true,
@@ -514,6 +518,7 @@ func (r *appResource) upsert(ctx context.Context, reqPlan *tfsdk.Plan, reqState
514518
plan, diags := mapAppValuesToType(ctx, manifest.Applications[0], appResp, &desiredState, sshResp)
515519
respDiags.Append(diags...)
516520
plan.CopyConfigAttributes(&desiredState)
521+
plan.Stopped = desiredState.Stopped
517522
respDiags.Append(respState.Set(ctx, &plan)...)
518523
}
519524
func (r *appResource) push(appType AppType, appManifestValue *cfv3operation.AppManifest, ctx context.Context) (*cfv3resource.App, error) {
@@ -538,6 +543,9 @@ func (r *appResource) push(appType AppType, appManifestValue *cfv3operation.AppM
538543
}
539544
manifestOp.WithStrategy(sm)
540545
}
546+
if appType.Stopped.ValueBool() {
547+
manifestOp.WithNoStart(true)
548+
}
541549
appResp, err := manifestOp.Push(ctx, appManifestValue, file)
542550
if err != nil {
543551
return nil, err

cloudfoundry/provider/types_app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type AppType struct {
3434
Strategy types.String `tfsdk:"strategy"`
3535
ServiceBindings types.Set `tfsdk:"service_bindings"`
3636
Routes types.Set `tfsdk:"routes"`
37+
Stopped types.Bool `tfsdk:"stopped"`
3738
Environment types.Map `tfsdk:"environment"`
3839
HealthCheckInterval types.Int64 `tfsdk:"health_check_interval"`
3940
ReadinessHealthCheckType types.String `tfsdk:"readiness_health_check_type"`

docs/resources/app.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ resource "cloudfoundry_app" "http-bin-sidecar" {
162162
- `sidecars` (Attributes Set) The attribute specifies additional processes to run in the same container as your app (see [below for nested schema](#nestedatt--sidecars))
163163
- `source_code_hash` (String) Used to trigger updates. Must be set to a base64-encoded SHA256 hash of the path specified.
164164
- `stack` (String) The base operating system and file system that your application will execute in. Please refer to the [docs](https://v3-apidocs.cloudfoundry.org/version/3.155.0/index.html#stacks) for more information
165+
- `stopped` (Boolean) Whether the application is started or stopped after creation. By default, this value is false, meaning the application will be started automatically after creation.
165166
- `strategy` (String) The deployment strategy to use when deploying the application. Valid values are 'none', 'rolling', and 'blue-green', defaults to 'none'.
166167
- `timeout` (Number) Time in seconds at which the health-check will report failure.
167168

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
gopkg.in/yaml.v2 v2.4.0
2222
)
2323

24-
replace github.com/cloudfoundry/go-cfclient/v3 v3.0.0-alpha.11.0.20250320145327-6946bc732186 => github.com/ANUGRAHG/go-cfclient/v3 v3.0.0-20250715085712-0c590acfa414
24+
replace github.com/cloudfoundry/go-cfclient/v3 v3.0.0-alpha.11.0.20250320145327-6946bc732186 => github.com/ANUGRAHG/go-cfclient/v3 v3.0.0-20250829074936-932b4cc9affd
2525

2626
require (
2727
code.cloudfoundry.org/cf-networking-helpers v0.58.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
1212
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
1313
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
1414
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
15-
github.com/ANUGRAHG/go-cfclient/v3 v3.0.0-20250715085712-0c590acfa414 h1:HKM4l1w496sABMBkAtEqLiB7CBD88sT1N36nFWStjeQ=
16-
github.com/ANUGRAHG/go-cfclient/v3 v3.0.0-20250715085712-0c590acfa414/go.mod h1:+sY77PKx6xxDyApQ07webuPs80UMefAOTMPFuwXUerM=
15+
github.com/ANUGRAHG/go-cfclient/v3 v3.0.0-20250829074936-932b4cc9affd h1:cqFNXTGTkrrJTxs+1SpRGT8UG5gOTKHpYnEJAnItpWQ=
16+
github.com/ANUGRAHG/go-cfclient/v3 v3.0.0-20250829074936-932b4cc9affd/go.mod h1:dJA5Y5hjlv1rwBN8dXZqY4GP/xfDsXLwuhYGOgW7s2s=
1717
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
1818
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
1919
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=

0 commit comments

Comments
 (0)