@@ -15,79 +15,85 @@ type Provider struct {
1515 CloudSettings ProviderCloudSettings `tfsdk:"cloud_settings"`
1616}
1717
18+ func (p * Provider ) Attributes () console.ClusterProviderAttributes {
19+ return console.ClusterProviderAttributes {
20+ Name : p .Name .ValueString (),
21+ Namespace : p .Namespace .ValueStringPointer (),
22+ Cloud : p .Cloud .ValueStringPointer (),
23+ CloudSettings : p .CloudSettings .Attributes (),
24+ }
25+ }
26+
27+ func (p * Provider ) UpdateAttributes () console.ClusterProviderUpdateAttributes {
28+ return console.ClusterProviderUpdateAttributes {
29+ CloudSettings : p .CloudSettings .Attributes (),
30+ }
31+ }
32+
33+ func (p * Provider ) From (cp * console.ClusterProviderFragment ) {
34+ p .Id = types .StringValue (cp .ID )
35+ p .Name = types .StringValue (cp .Name )
36+ p .Namespace = types .StringValue (cp .Namespace )
37+ p .Editable = types .BoolPointerValue (cp .Editable )
38+ p .Cloud = types .StringValue (cp .Cloud )
39+ }
40+
1841type ProviderCloudSettings struct {
1942 AWS * ProviderCloudSettingsAWS `tfsdk:"aws"`
2043 Azure * ProviderCloudSettingsAzure `tfsdk:"azure"`
2144 GCP * ProviderCloudSettingsGCP `tfsdk:"gcp"`
2245}
2346
47+ func (p * ProviderCloudSettings ) Attributes () * console.CloudProviderSettingsAttributes {
48+ if p .GCP != nil {
49+ return & console.CloudProviderSettingsAttributes {Aws : p .AWS .Attributes ()}
50+ }
51+
52+ if p .Azure != nil {
53+ return & console.CloudProviderSettingsAttributes {Azure : p .Azure .Attributes ()}
54+ }
55+
56+ if p .GCP != nil {
57+ return & console.CloudProviderSettingsAttributes {Gcp : p .GCP .Attributes ()}
58+ }
59+
60+ return nil
61+ }
62+
2463type ProviderCloudSettingsAWS struct {
2564 AccessKeyId types.String `tfsdk:"access_key_id"`
2665 SecretAccessKey types.String `tfsdk:"secret_access_key"`
2766}
2867
68+ func (p * ProviderCloudSettingsAWS ) Attributes () * console.AwsSettingsAttributes {
69+ return & console.AwsSettingsAttributes {
70+ AccessKeyID : p .AccessKeyId .ValueString (),
71+ SecretAccessKey : p .SecretAccessKey .ValueString (),
72+ }
73+ }
74+
2975type ProviderCloudSettingsAzure struct {
3076 SubscriptionId types.String `tfsdk:"subscription_id"`
3177 TenantId types.String `tfsdk:"tenant_id"`
3278 ClientId types.String `tfsdk:"client_id"`
3379 ClientSecret types.String `tfsdk:"client_secret"`
3480}
3581
36- type ProviderCloudSettingsGCP struct {
37- Credentials types.String `tfsdk:"credentials"`
38- }
39-
40- func (p * Provider ) CloudProviderSettingsAttributes () * console.CloudProviderSettingsAttributes {
41- if IsCloud (p .Cloud .ValueString (), CloudAWS ) {
42- return & console.CloudProviderSettingsAttributes {
43- Aws : & console.AwsSettingsAttributes {
44- AccessKeyID : p .CloudSettings .AWS .AccessKeyId .ValueString (),
45- SecretAccessKey : p .CloudSettings .AWS .SecretAccessKey .ValueString (),
46- },
47- }
48- }
49-
50- if IsCloud (p .Cloud .ValueString (), CloudAzure ) {
51- return & console.CloudProviderSettingsAttributes {
52- Azure : & console.AzureSettingsAttributes {
53- SubscriptionID : p .CloudSettings .Azure .SubscriptionId .ValueString (),
54- TenantID : p .CloudSettings .Azure .TenantId .ValueString (),
55- ClientID : p .CloudSettings .Azure .ClientId .ValueString (),
56- ClientSecret : p .CloudSettings .Azure .ClientSecret .ValueString (),
57- },
58- }
82+ func (p * ProviderCloudSettingsAzure ) Attributes () * console.AzureSettingsAttributes {
83+ return & console.AzureSettingsAttributes {
84+ SubscriptionID : p .SubscriptionId .ValueString (),
85+ TenantID : p .TenantId .ValueString (),
86+ ClientID : p .ClientId .ValueString (),
87+ ClientSecret : p .ClientSecret .ValueString (),
5988 }
60-
61- if IsCloud (p .Cloud .ValueString (), CloudGCP ) {
62- return & console.CloudProviderSettingsAttributes {
63- Gcp : & console.GcpSettingsAttributes {
64- ApplicationCredentials : p .CloudSettings .GCP .Credentials .ValueString (),
65- },
66- }
67- }
68-
69- return nil
7089}
7190
72- func (p * Provider ) CreateAttributes () console.ClusterProviderAttributes {
73- return console.ClusterProviderAttributes {
74- Name : p .Name .ValueString (),
75- Namespace : p .Namespace .ValueStringPointer (),
76- Cloud : p .Cloud .ValueStringPointer (),
77- CloudSettings : p .CloudProviderSettingsAttributes (),
78- }
91+ type ProviderCloudSettingsGCP struct {
92+ Credentials types.String `tfsdk:"credentials"`
7993}
8094
81- func (p * Provider ) UpdateAttributes () console.ClusterProviderUpdateAttributes {
82- return console.ClusterProviderUpdateAttributes {
83- CloudSettings : p .CloudProviderSettingsAttributes (),
95+ func (p * ProviderCloudSettingsGCP ) Attributes () * console.GcpSettingsAttributes {
96+ return & console.GcpSettingsAttributes {
97+ ApplicationCredentials : p .Credentials . ValueString (),
8498 }
8599}
86-
87- func (p * Provider ) From (cp * console.ClusterProviderFragment ) {
88- p .Id = types .StringValue (cp .ID )
89- p .Name = types .StringValue (cp .Name )
90- p .Namespace = types .StringValue (cp .Namespace )
91- p .Editable = types .BoolPointerValue (cp .Editable )
92- p .Cloud = types .StringValue (cp .Cloud )
93- }
0 commit comments