From 537ae07900ea200009242b4102bb217bebef0183 Mon Sep 17 00:00:00 2001 From: Gilles Miraillet Date: Thu, 20 Jun 2024 16:43:56 +0200 Subject: [PATCH] fix wrong targeted cloudfoundry-cli version --- go.mod | 4 +- go.sum | 12 +++--- .../cli/actor/v7action/k8s_auth.go | 42 ++++++++++++++----- .../ccv3/internal/api_routes.go | 2 + .../cloudcontroller/ccv3/process_instance.go | 6 ++- .../ccversion/minimum_version.go | 4 +- .../code.cloudfoundry.org/cli/api/uaa/auth.go | 6 ++- .../code.cloudfoundry.org/cli/util/ui/ui.go | 24 +++++------ vendor/modules.txt | 4 +- 9 files changed, 67 insertions(+), 37 deletions(-) diff --git a/go.mod b/go.mod index 0ca6403..ebfc626 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ exclude ( require ( code.cloudfoundry.org/cfnetworking-cli-api v0.0.0-20190103195135-4b04f26287a6 - code.cloudfoundry.org/cli v0.0.0-20240524142151-a2a685b5ea6e + code.cloudfoundry.org/cli v0.0.0-20240609151540-b78406a9b0ce ) require ( @@ -59,7 +59,7 @@ require ( golang.org/x/oauth2 v0.20.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/term v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect + golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect diff --git a/go.sum b/go.sum index 5044521..a59e53f 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ code.cloudfoundry.org/bytefmt v0.0.0-20240524171005-f1d9d5c55b92 h1:VSMHj/g/g0Sy code.cloudfoundry.org/bytefmt v0.0.0-20240524171005-f1d9d5c55b92/go.mod h1:I2UzouXDjUGpk1nyl9mPj/Vu8890ZAzczEyBxIsQ/6o= code.cloudfoundry.org/cfnetworking-cli-api v0.0.0-20190103195135-4b04f26287a6 h1:Yc9r1p21kEpni9WlG4mwOZw87TB2QlyS9sAEebZ3+ak= code.cloudfoundry.org/cfnetworking-cli-api v0.0.0-20190103195135-4b04f26287a6/go.mod h1:u5FovqC5GGAEbFPz+IdjycDA+gIjhUwqxnu0vbHwVeM= -code.cloudfoundry.org/cli v0.0.0-20240524142151-a2a685b5ea6e h1:CUEuy2mb1jF2gEHPrko123Z3ywiqNqgXx8070BU24SU= -code.cloudfoundry.org/cli v0.0.0-20240524142151-a2a685b5ea6e/go.mod h1:m/D1YFfmfYchdZDeYYtNpU7NHP2LHnmQ1sxdDPy2ki8= +code.cloudfoundry.org/cli v0.0.0-20240609151540-b78406a9b0ce h1:Lg/u08txpuLjC7FQ4Q7DtQB2VZbmCXBbgyZbmBiwvI8= +code.cloudfoundry.org/cli v0.0.0-20240609151540-b78406a9b0ce/go.mod h1:I6bhATQKPAMQ5fdUxioHxt95aTfqJ3NibHnMIO2N0Kk= code.cloudfoundry.org/cli-plugin-repo v0.0.0-20240520170503-e7ed9c7432a0 h1:AqfPzPhykvxSpxMkDdZMSJrCbxMQ0rugvDB3BuqD0DE= code.cloudfoundry.org/cli-plugin-repo v0.0.0-20240520170503-e7ed9c7432a0/go.mod h1:R1EiyOAr7lW0l/YkZNqItUNZ01Q/dYUfbTn4X4Z+82M= code.cloudfoundry.org/clock v1.1.0 h1:XLzC6W3Ah/Y7ht1rmZ6+QfPdt1iGWEAAtIZXgiaj57c= @@ -277,8 +277,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -288,8 +288,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= -golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/vendor/code.cloudfoundry.org/cli/actor/v7action/k8s_auth.go b/vendor/code.cloudfoundry.org/cli/actor/v7action/k8s_auth.go index bbbfadb..cd02f54 100644 --- a/vendor/code.cloudfoundry.org/cli/actor/v7action/k8s_auth.go +++ b/vendor/code.cloudfoundry.org/cli/actor/v7action/k8s_auth.go @@ -52,11 +52,37 @@ func NewKubernetesAuthActor(config Config, k8sConfigGetter KubernetesConfigGette } func (actor kubernetesAuthActor) Authenticate(credentials map[string]string, origin string, grantType constant.GrantType) error { - actor.config.SetKubernetesAuthInfo(credentials["k8s-auth-info"]) - return nil + username := credentials["username"] + availableUsernames, err := actor.getAvailableUsernames() + if err != nil { + return err + } + + for _, u := range availableUsernames { + if u == username { + actor.config.SetKubernetesAuthInfo(username) + return nil + } + } + + return errors.New("kubernetes user not found in configuration: " + username) } func (actor kubernetesAuthActor) GetLoginPrompts() (map[string]coreconfig.AuthPrompt, error) { + availableUsernames, err := actor.getAvailableUsernames() + if err != nil { + return nil, err + } + sort.Strings(availableUsernames) + + return map[string]coreconfig.AuthPrompt{"username": { + Type: coreconfig.AuthPromptTypeMenu, + Entries: availableUsernames, + DisplayName: "Choose your Kubernetes authentication info", + }}, nil +} + +func (actor kubernetesAuthActor) getAvailableUsernames() ([]string, error) { conf, err := actor.k8sConfigGetter.Get() if err != nil { return nil, err @@ -66,17 +92,11 @@ func (actor kubernetesAuthActor) GetLoginPrompts() (map[string]coreconfig.AuthPr return nil, errors.New("no kubernetes authentication infos configured") } - var prompts []string + var usernames []string for authInfo := range conf.AuthInfos { - prompts = append(prompts, authInfo) + usernames = append(usernames, authInfo) } - sort.Strings(prompts) - - return map[string]coreconfig.AuthPrompt{"k8s-auth-info": { - Type: coreconfig.AuthPromptTypeMenu, - Entries: prompts, - DisplayName: "Choose your Kubernetes authentication info", - }}, nil + return usernames, nil } func (actor kubernetesAuthActor) GetCurrentUser() (configv3.User, error) { diff --git a/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal/api_routes.go b/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal/api_routes.go index 9f6b3fa..c095b2d 100644 --- a/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal/api_routes.go +++ b/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal/api_routes.go @@ -103,6 +103,7 @@ const ( GetSpaceStagingSecurityGroupsRequest = "GetSpaceStagingSecurityGroups" GetSSHEnabled = "GetSSHEnabled" GetStacksRequest = "GetStacks" + GetTasksRequest = "GetTasks" GetTaskRequest = "GetTask" GetUserRequest = "GetUser" GetUsersRequest = "GetUsers" @@ -346,6 +347,7 @@ var APIRoutes = map[string]Route{ PatchStackRequest: {Path: "/v3/stacks/:stack_guid", Method: http.MethodPatch}, GetTaskRequest: {Path: "/v3/tasks/:task_guid", Method: http.MethodGet}, PutTaskCancelRequest: {Path: "/v3/tasks/:task_guid/cancel", Method: http.MethodPut}, + GetTasksRequest: {Path: "/v3/tasks", Method: http.MethodGet}, GetUsersRequest: {Path: "/v3/users", Method: http.MethodGet}, GetUserRequest: {Path: "/v3/users/:user_guid", Method: http.MethodGet}, PostUserRequest: {Path: "/v3/users", Method: http.MethodPost}, diff --git a/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/process_instance.go b/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/process_instance.go index da5764a..17bb527 100644 --- a/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/process_instance.go +++ b/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/process_instance.go @@ -14,7 +14,9 @@ import ( // ProcessInstance represents a single process instance for a particular // application. type ProcessInstance struct { - // CPUEntitlement is the current CPU entitlement usage of the instance. + // CPU is the current CPU usage of the instance. + CPU float64 + // CPU Entitlement is the current CPU entitlement usage of the instance. CPUEntitlement types.NullFloat64 // Details is information about errors placing the instance. Details string @@ -57,6 +59,7 @@ func (instance *ProcessInstance) UnmarshalJSON(data []byte) error { Type string `json:"type"` Uptime int64 `json:"uptime"` Usage struct { + CPU float64 `json:"cpu"` CPUEntitlement types.NullFloat64 `json:"cpu_entitlement"` Mem uint64 `json:"mem"` Disk uint64 `json:"disk"` @@ -69,6 +72,7 @@ func (instance *ProcessInstance) UnmarshalJSON(data []byte) error { return err } + instance.CPU = inputInstance.Usage.CPU instance.CPUEntitlement = inputInstance.Usage.CPUEntitlement instance.Details = inputInstance.Details instance.DiskQuota = inputInstance.DiskQuota diff --git a/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccversion/minimum_version.go b/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccversion/minimum_version.go index 35f6065..5158ab1 100644 --- a/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccversion/minimum_version.go +++ b/vendor/code.cloudfoundry.org/cli/api/cloudcontroller/ccversion/minimum_version.go @@ -2,7 +2,7 @@ package ccversion const ( MinSupportedV2ClientVersion = "2.128.0" - MinSupportedClientVersionV9 = "3.160.0" + MinSupportedClientVersionV8 = "3.99.0" MinVersionUpdateServiceNameWhenPlanNotVisibleV2 = "2.131.0" MinVersionUpdateServiceInstanceMaintenanceInfoV2 = "2.135.0" @@ -14,5 +14,5 @@ const ( MinVersionHTTP2RoutingV3 = "3.104.0" MinVersionSpaceSupporterV3 = "3.104.0" - MinVersionLogRateLimitingV3 = "3.125.0" + MinVersionLogRateLimitingV3 = "3.124.0" // TODO: update this when we have a CAPI release ) diff --git a/vendor/code.cloudfoundry.org/cli/api/uaa/auth.go b/vendor/code.cloudfoundry.org/cli/api/uaa/auth.go index f12da64..1e9ddf6 100644 --- a/vendor/code.cloudfoundry.org/cli/api/uaa/auth.go +++ b/vendor/code.cloudfoundry.org/cli/api/uaa/auth.go @@ -109,7 +109,11 @@ func (client Client) getJtiFromToken(token string) (string, error) { } payload := make(map[string]interface{}) - _ = json.Unmarshal(jsonPayload, &payload) + err = json.Unmarshal(jsonPayload, &payload) + if err != nil { + return "", err + } + jti, ok := payload["jti"].(string) if !ok { diff --git a/vendor/code.cloudfoundry.org/cli/util/ui/ui.go b/vendor/code.cloudfoundry.org/cli/util/ui/ui.go index 54d7ea9..c2a634a 100644 --- a/vendor/code.cloudfoundry.org/cli/util/ui/ui.go +++ b/vendor/code.cloudfoundry.org/cli/util/ui/ui.go @@ -276,6 +276,18 @@ func (ui *UI) DisplayTextWithFlavor(template string, templateValues ...map[strin fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, firstTemplateValues)) } +func getIndent(depth int, addHyphen bool) string { + if depth == 0 { + return "" + } + indent := strings.Repeat(" ", depth-1) + if addHyphen { + return indent + "- " + } else { + return indent + " " + } +} + // DisplayDiffAddition displays added lines in a diff, colored green and prefixed with '+' func (ui *UI) DisplayDiffAddition(lines string, depth int, addHyphen bool) { ui.terminalLock.Lock() @@ -497,15 +509,3 @@ func sum(intSlice []int) int { return sum } - -func getIndent(depth int, addHyphen bool) string { - if depth == 0 { - return "" - } - indent := strings.Repeat(" ", depth-1) - if addHyphen { - return indent + "- " - } else { - return indent + " " - } -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 8a2f262..93bb75b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -8,7 +8,7 @@ code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/cfnetv1 code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/cfnetv1/internal code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/networkerror code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/wrapper -# code.cloudfoundry.org/cli v0.0.0-20240524142151-a2a685b5ea6e +# code.cloudfoundry.org/cli v0.0.0-20240609151540-b78406a9b0ce ## explicit; go 1.22 code.cloudfoundry.org/cli/actor/actionerror code.cloudfoundry.org/cli/actor/sharedaction @@ -222,7 +222,7 @@ golang.org/x/sys/windows # golang.org/x/term v0.20.0 ## explicit; go 1.18 golang.org/x/term -# golang.org/x/text v0.15.0 +# golang.org/x/text v0.16.0 ## explicit; go 1.18 golang.org/x/text/internal/language golang.org/x/text/internal/language/compact