Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
30c8667
remove option to fallback to legacy (already disabled, just removing …
jcvrabo Mar 27, 2026
60d821e
simplify plugin command lookup
jcvrabo Mar 27, 2026
ab56eb1
move PluginCommandNames to Config method
jcvrabo Mar 27, 2026
7b8a84c
replace RunPlugin with a PluginRunner
jcvrabo Mar 27, 2026
267cb71
migrate coreconfig.Repository to configv3.Config for rpc service
jcvrabo Mar 29, 2026
640a0ef
prepare rpc server to use v7action.Actor instead of legacy code
jcvrabo Mar 29, 2026
a8af34c
remove legacy configuration from plugin runner
jcvrabo Mar 29, 2026
bc2bec4
poc plugin v2-v3 migration with GetService call
jcvrabo Mar 29, 2026
a5b80ad
migrate v2-v3 CliRpcCmd simpler Get methods
jcvrabo Mar 29, 2026
bfa68e6
migrate v2-v3 CliRpcCmd.GetOrg
jcvrabo Mar 29, 2026
f9e397f
migrate v2-v3 CliRpcCmd.GetSpace
jcvrabo Mar 29, 2026
b5eef86
remove fallback to legacy code
jcvrabo Mar 30, 2026
9730571
migrate v2-v3 CliRpcCmd.GetApp
jcvrabo Mar 30, 2026
5c6ec8a
migrate CliRpcCmd.GetApps to v7action
jcvrabo Mar 30, 2026
06c887d
migrate CallCoreCommand to use CommandParser instead of command runne…
jcvrabo Mar 30, 2026
86a30bd
add cfclient to CliConnection
jcvrabo Mar 30, 2026
b415db7
deprecate plugin_models methods and refer to CfClient()
jcvrabo Mar 30, 2026
7d7de9f
migrate CliRpcCmd.AccessToken and clean up
jcvrabo Mar 30, 2026
d8358b9
simplify NewRpcService signature, support output capture for core com…
jcvrabo Mar 31, 2026
66ed149
update plugin app push test to reflect logs from the v7action instead…
jcvrabo Apr 1, 2026
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
6 changes: 6 additions & 0 deletions actor/v7action/service_instance_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import (
)

type ServiceInstance struct {
GUID string
Type resources.ServiceInstanceType
Name string
ServicePlanName string
ServiceOfferingName string
ServiceBrokerName string
BoundApps []string
LastOperation string
LastOperationType resources.LastOperationType
LastOperationState resources.LastOperationState
UpgradeAvailable types.OptionalBoolean
}

Expand Down Expand Up @@ -74,6 +77,7 @@ func (actor Actor) GetServiceInstancesForSpace(spaceGUID string, omitApps bool)
for i, instance := range instances {
names := planDetailsFromPlanGUIDLookup[instance.ServicePlanGUID]
result[i] = ServiceInstance{
GUID: instance.GUID,
Name: instance.Name,
Type: instance.Type,
UpgradeAvailable: instance.UpgradeAvailable,
Expand All @@ -82,6 +86,8 @@ func (actor Actor) GetServiceInstancesForSpace(spaceGUID string, omitApps bool)
ServiceBrokerName: names.broker,
BoundApps: boundAppsNamesFromInstanceGUIDLookup[instance.GUID],
LastOperation: lastOperation(instance.LastOperation),
LastOperationType: instance.LastOperation.Type,
LastOperationState: instance.LastOperation.State,
}
}

Expand Down
16 changes: 16 additions & 0 deletions actor/v7action/service_instance_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ var _ = Describe("Service Instance List Action", func() {

Expect(serviceInstances).To(Equal([]ServiceInstance{
{
GUID: "fake-guid-1",
Name: "msi1",
Type: resources.ManagedServiceInstance,
ServicePlanName: "fake-plan-1",
Expand All @@ -248,8 +249,11 @@ var _ = Describe("Service Instance List Action", func() {
UpgradeAvailable: types.NewOptionalBoolean(true),
BoundApps: []string{"great-app-1", "great-app-2"},
LastOperation: "create succeeded",
LastOperationType: resources.CreateOperation,
LastOperationState: resources.OperationSucceeded,
},
{
GUID: "fake-guid-2",
Name: "msi2",
Type: resources.ManagedServiceInstance,
ServicePlanName: "fake-plan-2",
Expand All @@ -258,17 +262,23 @@ var _ = Describe("Service Instance List Action", func() {
UpgradeAvailable: types.NewOptionalBoolean(false),
BoundApps: []string{"great-app-3", "great-app-4"},
LastOperation: "update succeeded",
LastOperationType: resources.UpdateOperation,
LastOperationState: resources.OperationSucceeded,
},
{
GUID: "fake-guid-3",
Name: "msi3",
Type: resources.ManagedServiceInstance,
ServicePlanName: "fake-plan-3",
ServiceOfferingName: "fake-offering-3",
ServiceBrokerName: "fake-broker-2",
BoundApps: []string{"great-app-5"},
LastOperation: "create in progress",
LastOperationType: resources.CreateOperation,
LastOperationState: resources.OperationInProgress,
},
{
GUID: "fake-guid-4",
Name: "msi4",
Type: resources.ManagedServiceInstance,
ServicePlanName: "fake-plan-4",
Expand All @@ -277,8 +287,11 @@ var _ = Describe("Service Instance List Action", func() {
UpgradeAvailable: types.NewOptionalBoolean(true),
BoundApps: []string{"great-app-6"},
LastOperation: "create failed",
LastOperationType: resources.CreateOperation,
LastOperationState: resources.OperationFailed,
},
{
GUID: "fake-guid-5",
Name: "msi5",
Type: resources.ManagedServiceInstance,
ServicePlanName: "fake-plan-4",
Expand All @@ -287,8 +300,11 @@ var _ = Describe("Service Instance List Action", func() {
UpgradeAvailable: types.NewOptionalBoolean(false),
BoundApps: []string{"great-app-6"},
LastOperation: "delete in progress",
LastOperationType: resources.DeleteOperation,
LastOperationState: resources.OperationInProgress,
},
{
GUID: "fake-guid-6",
Name: "upsi",
Type: resources.UserProvidedServiceInstance,
BoundApps: nil,
Expand Down
11 changes: 10 additions & 1 deletion cf/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"code.cloudfoundry.org/cli/v8/cf/trace"
"code.cloudfoundry.org/cli/v8/cf/util/spellcheck"
"code.cloudfoundry.org/cli/v8/plugin/rpc"
"code.cloudfoundry.org/cli/v8/util/configv3"

netrpc "net/rpc"
)
Expand Down Expand Up @@ -139,7 +140,15 @@ func Main(traceEnv string, args []string) {

// non core command, try plugin command
server := netrpc.NewServer()
rpcService, err := rpc.NewRpcService(deps.TeePrinter, deps.TeePrinter, deps.Config, deps.RepoLocator, rpc.NewCommandRunner(), deps.Logger, Writer, server)

// Load configv3.Config for RPC service
v3Config, err := configv3.LoadConfig()
if err != nil {
deps.UI.Say(T("Error loading config: ") + err.Error())
os.Exit(1)
}

rpcService, err := rpc.NewRpcService(v3Config, server, nil, nil, nil)
if err != nil {
deps.UI.Say(T("Error initializing RPC service: ") + err.Error())
os.Exit(1)
Expand Down
9 changes: 8 additions & 1 deletion cf/commands/plugin/install_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"code.cloudfoundry.org/cli/v8/cf/util/downloader"
"code.cloudfoundry.org/cli/v8/plugin"
"code.cloudfoundry.org/cli/v8/util"
"code.cloudfoundry.org/cli/v8/util/configv3"
"code.cloudfoundry.org/gofileutils/fileutils"

pluginRPCService "code.cloudfoundry.org/cli/v8/plugin/rpc"
Expand Down Expand Up @@ -82,7 +83,13 @@ func (cmd *PluginInstall) SetDependency(deps commandregistry.Dependency, pluginC
// each service can only be registered once
server := rpc.NewServer()

rpcService, err := pluginRPCService.NewRpcService(deps.TeePrinter, deps.TeePrinter, deps.Config, deps.RepoLocator, pluginRPCService.NewCommandRunner(), deps.Logger, cmd.ui.Writer(), server)
// Load configv3.Config for RPC service
v3Config, err := configv3.LoadConfig()
if err != nil {
cmd.ui.Failed("Error loading config: " + err.Error())
}

rpcService, err := pluginRPCService.NewRpcService(v3Config, server, nil, nil, nil)
if err != nil {
cmd.ui.Failed("Error initializing RPC service: " + err.Error())
}
Expand Down
9 changes: 8 additions & 1 deletion cf/commands/plugin/uninstall_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"code.cloudfoundry.org/cli/v8/cf/requirements"
"code.cloudfoundry.org/cli/v8/cf/terminal"
rpcService "code.cloudfoundry.org/cli/v8/plugin/rpc"
"code.cloudfoundry.org/cli/v8/util/configv3"
)

type PluginUninstall struct {
Expand Down Expand Up @@ -55,7 +56,13 @@ func (cmd *PluginUninstall) SetDependency(deps commandregistry.Dependency, plugi
// each service can only be registered once
server := rpc.NewServer()

RPCService, err := rpcService.NewRpcService(deps.TeePrinter, deps.TeePrinter, deps.Config, deps.RepoLocator, rpcService.NewCommandRunner(), deps.Logger, cmd.ui.Writer(), server)
// Load configv3.Config for RPC service
v3Config, err := configv3.LoadConfig()
if err != nil {
cmd.ui.Failed("Error loading config: " + err.Error())
}

RPCService, err := rpcService.NewRpcService(v3Config, server, nil, nil, nil)
if err != nil {
cmd.ui.Failed("Error initializing RPC service: " + err.Error())
}
Expand Down
13 changes: 13 additions & 0 deletions cf/util/testhelpers/configuration/access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,16 @@ func BuildTokenString(expiration time.Time) string {
tokenBytes, _ := token.Serialize(nil)
return string(tokenBytes)
}

// BuildTokenStringWithUserInfo builds a JWT with user information for testing.
func BuildTokenStringWithUserInfo(userGUID, username, email, origin string) string {
c := jws.Claims{}
c.SetExpiration(time.Now().Add(24 * time.Hour))
c.Set("user_id", userGUID)
c.Set("user_name", username)
c.Set("email", email)
c.Set("origin", origin)
token := jws.NewJWT(c, crypto.Unsecured)
tokenBytes, _ := token.Serialize(nil)
return "BEARER " + string(tokenBytes)
}
28 changes: 28 additions & 0 deletions cf/util/testhelpers/configuration/test_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package configuration
import (
"code.cloudfoundry.org/cli/v8/cf/configuration/coreconfig"
"code.cloudfoundry.org/cli/v8/cf/models"
"code.cloudfoundry.org/cli/v8/util/configv3"
)

func NewRepository() coreconfig.Repository {
Expand Down Expand Up @@ -40,3 +41,30 @@ func NewRepositoryWithDefaults() coreconfig.Repository {

return configRepo
}

// NewConfigWithDefaults returns a configv3.Config initialized with the same
// default values as NewRepositoryWithDefaults for testing purposes.
func NewConfigWithDefaults() *configv3.Config {
// Create a proper JWT token with user info for configv3
// For UAA users, the user_name field contains the email
accessToken := BuildTokenStringWithUserInfo("my-user-guid", "my-user-email", "my-user-email", "uaa")

jsonConfig := configv3.JSONConfig{
AccessToken: accessToken,
TargetedOrganization: configv3.Organization{
Name: "my-org",
GUID: "my-org-guid",
},
TargetedSpace: configv3.Space{
Name: "my-space",
GUID: "my-space-guid",
},
}

return &configv3.Config{
ConfigFile: jsonConfig,
UserConfig: configv3.DefaultUserConfig{
ConfigFile: &jsonConfig,
},
}
}
1 change: 0 additions & 1 deletion command/common/command_list_v7.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
)

var Commands commandList
var ShouldFallbackToLegacy = false

type commandList struct {
VerboseOrVersion bool `short:"v" long:"version" description:"verbose and version flag"`
Expand Down
8 changes: 7 additions & 1 deletion command/plugin/shared/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ func NewRPCService(config Config, ui UI) (*RPCService, error) {
deps := commandregistry.NewDependency(ui.Writer(), traceLogger, fmt.Sprint(config.DialTimeout().Seconds()))
defer deps.Config.Close()

// Load configv3.Config for RPC service
v3Config, err := configv3.LoadConfig()
if err != nil {
return nil, fmt.Errorf("error loading config: %w", err)
}

server := netrpc.NewServer()
rpcService, err := rpc.NewRpcService(deps.TeePrinter, deps.TeePrinter, deps.Config, deps.RepoLocator, rpc.NewCommandRunner(), deps.Logger, ui.Writer(), server)
rpcService, err := rpc.NewRpcService(v3Config, server, nil, nil, nil)
if err != nil {
return nil, err
}
Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/SermoDigital/jose v0.9.2-0.20161205224733-f6df55f235c2
github.com/blang/semver/v4 v4.0.0
github.com/cloudfoundry/bosh-cli v6.4.1+incompatible
github.com/cloudfoundry/go-cfclient/v3 v3.0.0-alpha.20
github.com/creack/pty v1.1.24
github.com/cyphar/filepath-securejoin v0.6.1
github.com/distribution/reference v0.6.0
Expand Down Expand Up @@ -58,24 +59,30 @@ require (
github.com/charlievieth/fs v0.0.3 // indirect
github.com/clipperhouse/uax29/v2 v2.2.0 // indirect
github.com/cloudfoundry/bosh-utils v0.0.385 // indirect
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
github.com/cppforlife/go-patch v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/pprof v0.0.0-20260302011040-a15ffb7f9dcc // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/martini-contrib/render v0.0.0-20150707142108-ec18f8345a11 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.9 // indirect
github.com/stretchr/testify v1.11.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
Expand All @@ -91,6 +98,7 @@ require (
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.36.8 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ github.com/cloudfoundry/bosh-cli v6.4.1+incompatible h1:n5/+NIF9QxvGINOrjh6DmO+G
github.com/cloudfoundry/bosh-cli v6.4.1+incompatible/go.mod h1:rzIB+e1sn7wQL/TJ54bl/FemPKRhXby5BIMS3tLuWFM=
github.com/cloudfoundry/bosh-utils v0.0.385 h1:rOgL4fKxeLNUAYoHSfycRro29ns9bhsEyBJ8DQ5W4Rc=
github.com/cloudfoundry/bosh-utils v0.0.385/go.mod h1:vYjxd5zpxGjBKC+8voohfdXZkVk0UMOOvlMlZfxyOLM=
github.com/cloudfoundry/go-cfclient/v3 v3.0.0-alpha.20 h1:xfQAkrzb1LB8WtrR7SUepBEHVyYnToJaGzZPrdBmdd0=
github.com/cloudfoundry/go-cfclient/v3 v3.0.0-alpha.20/go.mod h1:cwg8bywOst/2c5huQgBIbA5gcI4g8DLov00cJaDaFy0=
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 h1:sDMmm+q/3+BukdIpxwO365v/Rbspp2Nt5XntgQRXq8Q=
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
github.com/cppforlife/go-patch v0.1.0 h1:I0fT+gFTSW4xWwvaTaUUVjr9xxjNXJ4naGc01BeQjwY=
github.com/cppforlife/go-patch v0.1.0/go.mod h1:67a7aIi94FHDZdoeGSJRRFDp66l9MhaAG1yGxpUoFD8=
Expand Down Expand Up @@ -87,6 +91,8 @@ github.com/gkampitakis/go-snaps v0.5.15 h1:amyJrvM1D33cPHwVrjo9jQxX8g/7E2wYdZ+01
github.com/gkampitakis/go-snaps v0.5.15/go.mod h1:HNpx/9GoKisdhw9AFOBT1N7DBs9DiHo/hGheFGBZ+mc=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab h1:xveKWz2iaueeTaUgdetzel+U7exyigDYBryyVfV/rZk=
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
Expand Down Expand Up @@ -166,6 +172,8 @@ github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+L
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/martini-contrib/render v0.0.0-20150707142108-ec18f8345a11 h1:YFh+sjyJTMQSYjKwM4dFKhJPJC/wfo98tPUc17HdoYw=
github.com/martini-contrib/render v0.0.0-20150707142108-ec18f8345a11/go.mod h1:Ah2dBMoxZEqk118as2T4u4fjfXarE0pPnMJaArZQZsI=
github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo=
github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
Expand Down Expand Up @@ -219,6 +227,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg=
github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
github.com/pivotal-cf/brokerapi/v7 v7.2.0/go.mod h1:5QRQ8vJmav91F+AvY5NA/QoDOq70XgBVxXKUK4N/cNE=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
2 changes: 1 addition & 1 deletion integration/shared/plugin/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _ = Describe("logs", func() {
appName, "-p", appDir, "-b", "staticfile_buildpack")
Eventually(session).Should(Exit(0))
Expect(session).To(Say("Downloading app package..."))
Expect(session).To(Say("Creating app"))
Expect(session).To(Say("Uploading complete"))
})
})
})
Expand Down
24 changes: 14 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import (
"fmt"
"os"

"code.cloudfoundry.org/cli/v8/cf/cmd"
"code.cloudfoundry.org/cli/v8/command/common"
"code.cloudfoundry.org/cli/v8/plugin/runner"
"code.cloudfoundry.org/cli/v8/util/command_parser"
"code.cloudfoundry.org/cli/v8/util/configv3"
"code.cloudfoundry.org/cli/v8/util/panichandler"
plugin_util "code.cloudfoundry.org/cli/v8/util/plugin"
"code.cloudfoundry.org/cli/v8/util/ui"
)

Expand Down Expand Up @@ -44,21 +42,27 @@ func main() {
}

if unknownCommandError, ok := err.(command_parser.UnknownCommandError); ok {
plugin, commandIsPlugin := plugin_util.IsPluginCommand(os.Args[1:])
var plugin configv3.Plugin
var commandIsPlugin bool

// Note: os.Args[1] can be safely indexed here because UnknownCommandError
// is only returned when ParseCommandFromArgs receives at least one argument.
// The command parser requires a command name to generate this error.
if len(os.Args) > 1 {
plugin, commandIsPlugin = config.FindPluginByCommand(os.Args[1])
}

switch {
case commandIsPlugin:
err = plugin_util.RunPlugin(plugin)
pluginRunner := runner.NewPluginRunner(config, commandUI, plugin, &p)
err = pluginRunner.Run(os.Args[1:])
if err != nil {
fmt.Fprintf(os.Stderr, "Error running plugin: %s\n", err.Error())
exitCode = 1
}

case common.ShouldFallbackToLegacy:
cmd.Main(os.Getenv("CF_TRACE"), os.Args)
// NOT REACHED, legacy main will exit the process

default:
unknownCommandError.Suggest(plugin_util.PluginCommandNames())
unknownCommandError.Suggest(config.PluginCommandNames())
fmt.Fprintf(os.Stderr, "%s\n", unknownCommandError.Error())
os.Exit(1)
}
Expand Down
Loading
Loading