Skip to content

Commit f5fb939

Browse files
author
Youngjin Jo
authored
Merge pull request #104 from yjinjo/master
Modify code for local environment
2 parents 0c4f013 + 2cba92a commit f5fb939

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

cmd/common/fetchService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func FetchService(serviceName string, verb string, resourceName string, options
145145
steps := []string{
146146
"1. Run 'cfctl login'",
147147
"2. Enter your credentials when prompted",
148-
"3. Select your workspace",
148+
"3. Select your scope",
149149
"4. Try your command again",
150150
}
151151

cmd/other/setting.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,17 @@ You can either specify a new endpoint URL directly or use the service-based endp
447447
}
448448

449449
if urlFlag != "" {
450+
// Check if the URL starts with grpc:// or grpc+ssl://
451+
if strings.HasPrefix(urlFlag, "grpc://") || strings.HasPrefix(urlFlag, "grpc+ssl://") {
452+
appV.Set(fmt.Sprintf("environments.%s.endpoint", currentEnv), urlFlag)
453+
if err := appV.WriteConfig(); err != nil {
454+
pterm.Error.Printf("Failed to update setting.yaml: %v\n", err)
455+
return
456+
}
457+
pterm.Success.Printf("Updated endpoint for '%s' to '%s'.\n", currentEnv, urlFlag)
458+
return
459+
}
460+
450461
if strings.HasSuffix(currentEnv, "-app") {
451462
pterm.Error.Println("Direct URL endpoint update is not available for user environment.")
452463
pterm.Info.Println("Please use the service flag (-s) instead.")
@@ -491,6 +502,12 @@ You can either specify a new endpoint URL directly or use the service-based endp
491502

492503
// If list flag is provided, only show available services
493504
if listFlag {
505+
// Check if environment is local
506+
if currentEnv == "local" {
507+
pterm.Error.Println("Service listing is not available in local environment.")
508+
return
509+
}
510+
494511
token, err := getToken(appV)
495512
if err != nil {
496513
if strings.HasSuffix(currentEnv, "-user") {
@@ -693,7 +710,9 @@ You can either specify a new endpoint URL directly or use the service-based endp
693710
if service != "" {
694711
var endpoints map[string]string
695712

696-
if strings.HasPrefix(endpoint, "http://") || strings.HasPrefix(endpoint, "https://") {
713+
if strings.HasPrefix(endpoint, "grpc://") || strings.HasPrefix(endpoint, "grpc+ssl://") {
714+
appV.Set(fmt.Sprintf("environments.%s.endpoint", currentEnv), endpoint)
715+
} else if strings.HasPrefix(endpoint, "http://") || strings.HasPrefix(endpoint, "https://") {
697716
// HTTP/HTTPS endpoint case
698717
client := &http.Client{}
699718
req, err := http.NewRequest("POST", restIdentityEndpoint+"/endpoint/list", bytes.NewBuffer([]byte("{}")))

0 commit comments

Comments
 (0)