From beeb40a4ab17e63522fa358b1c4eb4766f6c5d8f Mon Sep 17 00:00:00 2001 From: Gerrit Date: Wed, 20 Mar 2024 15:11:21 +0100 Subject: [PATCH] Fix completion. (#294) --- cmd/completion/completion.go | 6 ++---- cmd/root.go | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/completion/completion.go b/cmd/completion/completion.go index d0a7bb6..e798d1a 100644 --- a/cmd/completion/completion.go +++ b/cmd/completion/completion.go @@ -37,10 +37,8 @@ type Completion struct { cloud *client.CloudAPI } -func NewCompletion(cloud *client.CloudAPI) *Completion { - return &Completion{ - cloud: cloud, - } +func (c *Completion) SetClient(client *client.CloudAPI) { + c.cloud = client } func (c *Completion) ContextListCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { diff --git a/cmd/root.go b/cmd/root.go index e80b9a0..79ac022 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -184,7 +184,7 @@ func initConfigWithViperCtx(cfg *config) error { } cfg.cloud = cloud - cfg.comp = completion.NewCompletion(cloud) + cfg.comp.SetClient(cloud) parsedURL, err := url.Parse(driverURL) if err != nil {