Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
dist/
test/yaml/
.DS_Store
9 changes: 6 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ func addDynamicServiceCommands() error {
var apiEndpoint string

// For local environment
if strings.HasPrefix(config.Endpoint, "grpc://") {
if strings.Contains(config.Endpoint, ".svc.cluster.local") {
apiEndpoint = endpointName
} else if strings.HasPrefix(config.Endpoint, "grpc://") {
endpoint := strings.TrimPrefix(config.Endpoint, "grpc://")

conn, err := grpc.Dial(endpoint, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(time.Second))
Expand Down Expand Up @@ -319,9 +321,10 @@ func addDynamicServiceCommands() error {
}

if hasPlugin {
cmd := createServiceCommand(config.Environment)
cmd := createServiceCommand("static")
cmd.GroupID = "available"
rootCmd.AddCommand(cmd)
return nil
}

// Add commands for other microservices
Expand All @@ -334,7 +337,7 @@ func addDynamicServiceCommands() error {
return nil
}

if strings.HasPrefix(endpointName, "grpc+ssl://") {
if strings.HasPrefix(endpointName, "grpc+ssl://") || strings.HasPrefix(endpointName, "grpc://") {
apiEndpoint = endpointName
} else if strings.HasPrefix(endpointName, "http://") || strings.HasPrefix(endpointName, "https://") {
apiEndpoint, err = configs.GetAPIEndpoint(endpointName)
Expand Down
21 changes: 13 additions & 8 deletions pkg/configs/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ func GetServiceEndpoint(config *Environments, serviceName string) (string, error
}

func FetchEndpointsMap(endpoint string) (map[string]string, error) {
if strings.HasPrefix(endpoint, "grpc://") {
if strings.HasPrefix(endpoint, "grpc://localhost") {
endpointsMap := make(map[string]string)
endpointsMap["local"] = endpoint
endpointsMap["static"] = endpoint
return endpointsMap, nil
}

Expand All @@ -187,16 +187,21 @@ func FetchEndpointsMap(endpoint string) (map[string]string, error) {

if !hasIdentityService {
// Handle gRPC+SSL protocol directly
if strings.HasPrefix(endpoint, "grpc+ssl://") {
if strings.HasPrefix(endpoint, "grpc+ssl://") || strings.HasPrefix(endpoint, "grpc://") {
protocol := "grpc+ssl://"
if strings.HasPrefix(endpoint, "grpc://") {
protocol = "grpc://"
}

// Parse the endpoint
parts := strings.Split(endpoint, "/")
endpoint = strings.Join(parts[:len(parts)-1], "/")
parts = strings.Split(endpoint, "://")
if len(parts) != 2 {
hostPart := strings.TrimPrefix(endpoint, protocol)
hostPart = strings.TrimSuffix(hostPart, "/")

hostParts := strings.Split(hostPart, ".")
if len(hostParts) == 0 {
return nil, fmt.Errorf("invalid endpoint format: %s", endpoint)
}

hostParts := strings.Split(parts[1], ".")
svc := hostParts[0]
baseDomain := strings.Join(hostParts[1:], ".")

Expand Down
Loading