Skip to content

Commit cb44600

Browse files
authored
Merge pull request #121 from yjinjo/master
Add grpc connection to internal service
2 parents 75251ca + fbd7717 commit cb44600

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

cmd/common/api_resources.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,7 @@ func FetchServiceResources(serviceName, endpoint string, shortNamesMap map[strin
103103
creds := credentials.NewTLS(tlsConfig)
104104
opts = append(opts, grpc.WithTransportCredentials(creds))
105105
} else if scheme == "grpc" {
106-
if strings.Contains(hostPort, ".svc.cluster.local") {
107-
tlsConfig := &tls.Config{
108-
InsecureSkipVerify: true,
109-
}
110-
creds := credentials.NewTLS(tlsConfig)
111-
opts = append(opts, grpc.WithTransportCredentials(creds))
112-
} else {
113-
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
114-
}
106+
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
115107
} else {
116108
return nil, fmt.Errorf("unsupported scheme: %s", scheme)
117109
}

cmd/other/login.go

+6
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,12 @@ func fetchWorkspaces(baseUrl string, identityEndpoint string, hasIdentityService
13211321
}
13221322
creds := credentials.NewTLS(tlsConfig)
13231323
opts = append(opts, grpc.WithTransportCredentials(creds))
1324+
} else if strings.HasPrefix(identityEndpoint, "grpc://") {
1325+
tlsConfig := &tls.Config{
1326+
InsecureSkipVerify: true,
1327+
}
1328+
creds := credentials.NewTLS(tlsConfig)
1329+
opts = append(opts, grpc.WithTransportCredentials(creds))
13241330
} else {
13251331
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
13261332
}

pkg/configs/endpoint.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ func GetServiceEndpoint(config *Environments, serviceName string) (string, error
133133
}
134134

135135
if strings.HasPrefix(envConfig.Endpoint, "grpc://") {
136-
if strings.Contains(envConfig.Endpoint, "localhost") {
136+
// Allow both localhost and cluster-internal addresses
137+
if strings.Contains(envConfig.Endpoint, "localhost") || strings.Contains(envConfig.Endpoint, ".svc.cluster.local") {
137138
return envConfig.Endpoint, nil
138139
}
139140
}

0 commit comments

Comments
 (0)