terraform-provider: fix parsing api_server_cert_sans (#2758)

* tf: don't double quote cert sans

* tf: improve provider examples
This commit is contained in:
3u13r 2023-12-27 17:04:35 +01:00 committed by GitHub
parent 2ce73c19dc
commit 2f10223682
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 14 deletions

View file

@ -685,9 +685,10 @@ func (r *ClusterResource) apply(ctx context.Context, data *ClusterResourceModel,
}
// parse API server certificate SANs
apiServerCertSANs := make([]string, 0, len(data.APIServerCertSANs.Elements()))
for _, san := range data.APIServerCertSANs.Elements() {
apiServerCertSANs = append(apiServerCertSANs, san.String())
apiServerCertSANs, convertDiags := r.getAPIServerCertSANs(ctx, data)
diags.Append(convertDiags...)
if diags.HasError() {
return diags
}
// parse network config
@ -1210,6 +1211,15 @@ func (r *ClusterResource) getNetworkConfig(ctx context.Context, data *ClusterRes
return networkCfg, diags
}
func (r *ClusterResource) getAPIServerCertSANs(ctx context.Context, data *ClusterResourceModel) ([]string, diag.Diagnostics) {
if data.APIServerCertSANs.IsNull() {
return nil, nil
}
apiServerCertSANs := make([]string, 0, len(data.APIServerCertSANs.Elements()))
diags := data.APIServerCertSANs.ElementsAs(ctx, &apiServerCertSANs, false)
return apiServerCertSANs, diags
}
// tfContextLogger is a logging adapter between the tflog package and
// Constellation's logger.
type tfContextLogger struct {