MCPcopy Index your code
hub / github.com/bytebase/bytebase / convertDataSources

Function convertDataSources

backend/api/v1/instance_service_converter.go:177–274  ·  view source on GitHub ↗
(dataSources []*storepb.DataSource)

Source from the content-addressed store, hash-verified

175}
176
177func 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() != "",

Callers 3

convertToV1InstanceFunction · 0.85

Calls 15

convertRedisTypeFunction · 0.85
convertCloudSQLIPTypeFunction · 0.85
GetDatabaseMethod · 0.65
GetExternalSecretMethod · 0.45
GetTypeMethod · 0.45
GetAuthenticationTypeMethod · 0.45
GetIdMethod · 0.45
GetUsernameMethod · 0.45
GetHostMethod · 0.45

Tested by 1