Skip to content

ephemeral: add ephemeral_google_service_account_jwt #12142

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

35 changes: 0 additions & 35 deletions mmv1/third_party/terraform/fwvalidators/framework_validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,38 +206,3 @@ func (v BoundedDuration) ValidateString(ctx context.Context, req validator.Strin
)
}
}

// Positive Integer Validator
var _ validator.Int64 = positiveIntegerValidator{}

// positiveIntegerValidator validates that an Int64 Attribute's value is greater than 0.
type positiveIntegerValidator struct {
}

// Description describes the validation in plain text formatting.
func (v positiveIntegerValidator) Description(_ context.Context) string {
return "value must be greater than 0"
}

// MarkdownDescription describes the validation in Markdown formatting.
func (v positiveIntegerValidator) MarkdownDescription(ctx context.Context) string {
return v.Description(ctx)
}

// ValidateInt64 performs the validation.
func (v positiveIntegerValidator) ValidateInt64(ctx context.Context, request validator.Int64Request, response *validator.Int64Response) {
if request.ConfigValue.IsNull() || request.ConfigValue.IsUnknown() {
return
}

if request.ConfigValue.ValueInt64() <= 0 {
response.Diagnostics.AddError(
"Invalid Integer Value",
fmt.Sprintf("Value must be greater than 0, got: %d", request.ConfigValue.ValueInt64()),
)
}
}

func PositiveIntegerValidator() validator.Int64 {
return positiveIntegerValidator{}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
"github.com/hashicorp/terraform-plugin-framework/ephemeral"
"github.com/hashicorp/terraform-plugin-framework/ephemeral/schema"
Expand Down Expand Up @@ -51,7 +52,7 @@ func (p *googleEphemeralServiceAccountJwt) Schema(ctx context.Context, req ephem
Optional: true,
Description: "Number of seconds until the JWT expires. If set and non-zero an `exp` claim will be added to the payload derived from the current timestamp plus expires_in seconds.",
Validators: []validator.Int64{
fwvalidators.PositiveIntegerValidator(),
int64validator.AtLeast(0),
},
},
"target_service_account": schema.StringAttribute{
Expand Down
Loading