| 175 | } |
| 176 | |
| 177 | func convertDataSources(dataSources []*storepb.DataSource) []*v1pb.DataSource { |
| 178 | var v1DataSources []*v1pb.DataSource |
| 179 | for _, ds := range dataSources { |
| 180 | externalSecret := convertDataSourceExternalSecret(ds.GetExternalSecret()) |
| 181 | |
| 182 | dataSourceType := v1pb.DataSourceType_DATA_SOURCE_UNSPECIFIED |
| 183 | switch ds.GetType() { |
| 184 | case storepb.DataSourceType_ADMIN: |
| 185 | dataSourceType = v1pb.DataSourceType_ADMIN |
| 186 | case storepb.DataSourceType_READ_ONLY: |
| 187 | dataSourceType = v1pb.DataSourceType_READ_ONLY |
| 188 | default: |
| 189 | } |
| 190 | |
| 191 | authenticationType := v1pb.DataSource_AUTHENTICATION_UNSPECIFIED |
| 192 | switch ds.GetAuthenticationType() { |
| 193 | case storepb.DataSource_AUTHENTICATION_UNSPECIFIED, storepb.DataSource_PASSWORD: |
| 194 | authenticationType = v1pb.DataSource_PASSWORD |
| 195 | case storepb.DataSource_GOOGLE_CLOUD_SQL_IAM: |
| 196 | authenticationType = v1pb.DataSource_GOOGLE_CLOUD_SQL_IAM |
| 197 | case storepb.DataSource_AWS_RDS_IAM: |
| 198 | authenticationType = v1pb.DataSource_AWS_RDS_IAM |
| 199 | case storepb.DataSource_AZURE_IAM: |
| 200 | authenticationType = v1pb.DataSource_AZURE_IAM |
| 201 | default: |
| 202 | } |
| 203 | |
| 204 | dataSource := &v1pb.DataSource{ |
| 205 | Id: ds.GetId(), |
| 206 | Type: dataSourceType, |
| 207 | Username: ds.GetUsername(), |
| 208 | // We don't return the password and SSLs on reads. |
| 209 | Host: ds.GetHost(), |
| 210 | Port: ds.GetPort(), |
| 211 | Database: ds.GetDatabase(), |
| 212 | Srv: ds.GetSrv(), |
| 213 | AuthenticationDatabase: ds.GetAuthenticationDatabase(), |
| 214 | Sid: ds.GetSid(), |
| 215 | ServiceName: ds.GetServiceName(), |
| 216 | SshHost: ds.GetSshHost(), |
| 217 | SshPort: ds.GetSshPort(), |
| 218 | SshUser: ds.GetSshUser(), |
| 219 | ExternalSecret: externalSecret, |
| 220 | AuthenticationType: authenticationType, |
| 221 | SaslConfig: convertDataSourceSaslConfig(ds.GetSaslConfig()), |
| 222 | AdditionalAddresses: convertDataSourceAddresses(ds.GetAdditionalAddresses()), |
| 223 | ReplicaSet: ds.GetReplicaSet(), |
| 224 | DirectConnection: ds.GetDirectConnection(), |
| 225 | Region: ds.GetRegion(), |
| 226 | WarehouseId: ds.GetWarehouseId(), |
| 227 | UseSsl: ds.GetUseSsl(), |
| 228 | VerifyTlsCertificate: ds.GetVerifyTlsCertificate(), |
| 229 | RedisType: convertRedisType(ds.GetRedisType()), |
| 230 | CloudSqlIpType: convertCloudSQLIPType(ds.GetCloudSqlIpType()), |
| 231 | MasterName: ds.GetMasterName(), |
| 232 | MasterUsername: ds.GetMasterUsername(), |
| 233 | ExtraConnectionParameters: ds.GetExtraConnectionParameters(), |
| 234 | SslCaSet: ds.GetSslCa() != "", |