-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCM-6031 | feat: allow to edit component routes of ingress
- Loading branch information
Showing
5 changed files
with
176 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package defaultingress | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/attr" | ||
"github.com/hashicorp/terraform-plugin-framework/diag" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes" | ||
) | ||
|
||
type ComponentRoute struct { | ||
Hostname types.String `tfsdk:"hostname"` | ||
TlsSecretRef types.String `tfsdk:"tls_secret_ref"` | ||
} | ||
|
||
var ComponentRouteAttributeTypes = map[string]attr.Type{ | ||
"hostname": types.StringType, | ||
"tls_secret_ref": types.StringType, | ||
} | ||
|
||
func FlattenComponentRoute(hostname, tlsSecretRef string) types.Object { | ||
if hostname == "" && tlsSecretRef == "" { | ||
return types.ObjectNull(ComponentRouteAttributeTypes) | ||
} | ||
|
||
attrs := map[string]attr.Value{ | ||
"hostname": types.StringValue(hostname), | ||
"tls_secret_ref": types.StringValue(tlsSecretRef), | ||
} | ||
|
||
return types.ObjectValueMust(ComponentRouteAttributeTypes, attrs) | ||
} | ||
|
||
func ExpandComponentRoute(ctx context.Context, | ||
object types.Object, diags diag.Diagnostics) (string, string) { | ||
if object.IsNull() { | ||
return "", "" | ||
} | ||
|
||
var componentRoute ComponentRoute | ||
diags.Append(object.As(ctx, &componentRoute, basetypes.ObjectAsOptions{})...) | ||
if diags.HasError() { | ||
return "", "" | ||
} | ||
|
||
return componentRoute.Hostname.ValueString(), componentRoute.TlsSecretRef.ValueString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters