You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Downstream in Terraform Provider SDKs such as terraform-plugin-go, terraform-plugin-framework, and terraform-plugin-sdk, it would be great if we could verify provider developer defined strings that should only contain a full provider address, e.g. "registry.terraform.io/hashicorp/example". We want to ensure a full provider address is submitted as this value can eventually wind up in Terraform reattach configurations.
This module currently provides the ParseAndInferProviderSourceString() and ParseRawProviderSourceString() functions, however they allow a few things we don't desire:
Missing hostname
Missing namespace
Namespace being - (which is valid for legacy reasons when the hostname is registry.terraform.io, but not something we want to allow for this use case)
Attempted Solutions
Manual logic:
// Validate a given provider address. This is only used for the Address field// to preserve backwards compatibility for the Name field.//// This logic is manually implemented over importing// github.com/hashicorp/terraform-registry-address as its functionality such as// ParseAndInferProviderSourceString and ParseRawProviderSourceString allow// shorter address formats, which would then require post-validation anyways.func (optsServeOpts) validateAddress(_ context.Context) error {
addressParts:=strings.Split(opts.Address, "/")
formatErr:=fmt.Errorf("expected hostname/namespace/type format, got: %s", opts.Address)
iflen(addressParts) !=3 {
returnformatErr
}
ifaddressParts[0] ==""||addressParts[1] ==""||addressParts[2] =="" {
returnformatErr
}
returnnil
}
Proposal
Implement a function in this Go module similar to the above, potentially with better validation. 😄 e.g.
If there are any restrictions on provider type names in general (or really, any part of the address), such as disallowed characters, it'd definitely be good to validate that as well. It might be good to separate the hostname/namespace/type validations into their own functions, which this one can call after checking the overall format.
Use Case
Downstream in Terraform Provider SDKs such as terraform-plugin-go, terraform-plugin-framework, and terraform-plugin-sdk, it would be great if we could verify provider developer defined strings that should only contain a full provider address, e.g.
"registry.terraform.io/hashicorp/example"
. We want to ensure a full provider address is submitted as this value can eventually wind up in Terraform reattach configurations.This module currently provides the
ParseAndInferProviderSourceString()
andParseRawProviderSourceString()
functions, however they allow a few things we don't desire:-
(which is valid for legacy reasons when the hostname isregistry.terraform.io
, but not something we want to allow for this use case)Attempted Solutions
Manual logic:
Proposal
Implement a function in this Go module similar to the above, potentially with better validation. 😄 e.g.
References
The text was updated successfully, but these errors were encountered: