|
8 | 8 | "encoding/json" |
9 | 9 | "errors" |
10 | 10 | "fmt" |
| 11 | + "strconv" |
11 | 12 |
|
12 | 13 | ujconfig "github.com/crossplane/upjet/v2/pkg/config" |
13 | 14 | "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" |
@@ -77,6 +78,100 @@ func configureCloud(p *ujconfig.Provider) { |
77 | 78 | GetIDFn: ujconfig.ExternalNameAsID, |
78 | 79 | DisableNameInitializer: true, |
79 | 80 | } |
| 81 | + r.Sensitive.AdditionalConnectionDetailsFn = func(attr map[string]interface{}) (map[string][]byte, error) { |
| 82 | + conn := map[string][]byte{} |
| 83 | + for _, key := range []string{ |
| 84 | + "alertmanager_ip_allow_list_cname", |
| 85 | + "alertmanager_name", |
| 86 | + "alertmanager_status", |
| 87 | + "alertmanager_url", |
| 88 | + "cluster_name", |
| 89 | + "cluster_slug", |
| 90 | + "description", |
| 91 | + "fleet_management_name", |
| 92 | + "fleet_management_private_connectivity_info_private_dns", |
| 93 | + "fleet_management_private_connectivity_info_service_name", |
| 94 | + "fleet_management_status", |
| 95 | + "fleet_management_url", |
| 96 | + "grafanas_ip_allow_list_cname", |
| 97 | + "graphite_ip_allow_list_cname", |
| 98 | + "graphite_name", |
| 99 | + "graphite_private_connectivity_info_private_dns", |
| 100 | + "graphite_private_connectivity_info_service_name", |
| 101 | + "graphite_status", |
| 102 | + "graphite_url", |
| 103 | + "influx_url", |
| 104 | + "logs_ip_allow_list_cname", |
| 105 | + "logs_name", |
| 106 | + "logs_private_connectivity_info_private_dns", |
| 107 | + "logs_private_connectivity_info_service_name", |
| 108 | + "logs_status", |
| 109 | + "logs_url", |
| 110 | + "name", |
| 111 | + "oncall_api_url", |
| 112 | + "org_name", |
| 113 | + "org_slug", |
| 114 | + "otlp_private_connectivity_info_private_dns", |
| 115 | + "otlp_private_connectivity_info_service_name", |
| 116 | + "otlp_url", |
| 117 | + "pdc_api_private_connectivity_info_private_dns", |
| 118 | + "pdc_api_private_connectivity_info_service_name", |
| 119 | + "pdc_gateway_private_connectivity_info_private_dns", |
| 120 | + "pdc_gateway_private_connectivity_info_service_name", |
| 121 | + "profiles_ip_allow_list_cname", |
| 122 | + "profiles_name", |
| 123 | + "profiles_private_connectivity_info_private_dns", |
| 124 | + "profiles_private_connectivity_info_service_name", |
| 125 | + "profiles_status", |
| 126 | + "profiles_url", |
| 127 | + "prometheus_ip_allow_list_cname", |
| 128 | + "prometheus_name", |
| 129 | + "prometheus_private_connectivity_info_private_dns", |
| 130 | + "prometheus_private_connectivity_info_service_name", |
| 131 | + "prometheus_remote_endpoint", |
| 132 | + "prometheus_remote_write_endpoint", |
| 133 | + "prometheus_status", |
| 134 | + "prometheus_url", |
| 135 | + "region_slug", |
| 136 | + "slug", |
| 137 | + "status", |
| 138 | + "traces_ip_allow_list_cname", |
| 139 | + "traces_name", |
| 140 | + "traces_private_connectivity_info_private_dns", |
| 141 | + "traces_private_connectivity_info_service_name", |
| 142 | + "traces_status", |
| 143 | + "traces_url", |
| 144 | + "url", |
| 145 | + "wait_for_readiness_timeout", |
| 146 | + } { |
| 147 | + if v, ok := attr[key].(string); ok && v != "" { |
| 148 | + conn[key] = []byte(v) |
| 149 | + } |
| 150 | + } |
| 151 | + for _, key := range []string{ |
| 152 | + "alertmanager_user_id", |
| 153 | + "fleet_management_user_id", |
| 154 | + "graphite_user_id", |
| 155 | + "logs_user_id", |
| 156 | + "org_id", |
| 157 | + "profiles_user_id", |
| 158 | + "prometheus_user_id", |
| 159 | + "traces_user_id", |
| 160 | + } { |
| 161 | + switch v := attr[key].(type) { |
| 162 | + case float64: |
| 163 | + conn[key] = []byte(strconv.FormatFloat(v, 'f', -1, 64)) |
| 164 | + case int: |
| 165 | + conn[key] = []byte(strconv.Itoa(v)) |
| 166 | + } |
| 167 | + } |
| 168 | + // Export the stack ID (TF uses "id" but ProviderConfig expects "stack_id") |
| 169 | + if v, ok := attr["id"].(string); ok && v != "" { |
| 170 | + conn["id"] = []byte(v) |
| 171 | + } |
| 172 | + return conn, nil |
| 173 | + } |
| 174 | + |
80 | 175 | r.TerraformCustomDiff = func(diff *terraform.InstanceDiff, state *terraform.InstanceState, config *terraform.ResourceConfig) (*terraform.InstanceDiff, error) { |
81 | 176 | // skip diff customization on create |
82 | 177 | if state == nil || state.Empty() { |
|
0 commit comments