Skip to content

Commit

Permalink
fix(org): make the organisation parameter optional
Browse files Browse the repository at this point in the history
this will allow to pass the parameter as an environment variable
  • Loading branch information
juwit committed Jan 2, 2025
1 parent 08147d8 commit 0020e63
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/provider/impl/provider_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest,
} else {
p.organization = config.Organisation.ValueString()
}
if p.organization == "" {
resp.Diagnostics.AddError("Invalid provider configuration", "Organisation should be set by either the organisation parameter or by the CC_ORGANISATION environment variable")
return
}

// Allow to get creds from CLI config directory or by injected variables
if config.Secret.IsUnknown() ||
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/impl/provider_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (p *Provider) Schema(_ context.Context, req provider.SchemaRequest, res *pr
},
"organisation": schema.StringAttribute{
Sensitive: true,
Required: true,
Optional: true, // can be read from environment variable
MarkdownDescription: "CleverCloud organisation, can be either orga_xxx, or user_xxx for personal spaces. This parameter can also be provided via CC_ORGANISATION environment variable.",
Validators: []validator.String{
pkg.NewValidatorRegex("valid owner name", regexp.MustCompile(`^(user|orga)_.{36}`)),
Expand Down

0 comments on commit 0020e63

Please sign in to comment.