Skip to content

Commit ae99cf4

Browse files
committed
chore(cli): remove some spurious types and parameters
Signed-off-by: Leonid Dubinsky <dub@podval.org>
1 parent 3f9ab46 commit ae99cf4

9 files changed

Lines changed: 49 additions & 63 deletions

File tree

cmd/machine/create.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
"github.com/skevetter/devpod/cmd/flags"
7-
"github.com/skevetter/devpod/pkg/client"
87
"github.com/skevetter/devpod/pkg/config"
98
"github.com/skevetter/devpod/pkg/workspace"
109
"github.com/skevetter/log"
@@ -52,7 +51,7 @@ func (cmd *CreateCmd) Run(ctx context.Context, args []string) error {
5251
return err
5352
}
5453

55-
err = machineClient.Create(ctx, client.CreateOptions{})
54+
err = machineClient.Create(ctx)
5655
if err != nil {
5756
return err
5857
}

cmd/machine/start.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
"github.com/skevetter/devpod/cmd/flags"
7-
"github.com/skevetter/devpod/pkg/client"
87
"github.com/skevetter/devpod/pkg/config"
98
"github.com/skevetter/devpod/pkg/workspace"
109
"github.com/skevetter/log"
@@ -44,7 +43,7 @@ func (cmd *StartCmd) Run(ctx context.Context, args []string) error {
4443
return err
4544
}
4645

47-
err = machineClient.Start(ctx, client.StartOptions{})
46+
err = machineClient.Start(ctx)
4847
if err != nil {
4948
return err
5049
}

cmd/troubleshoot.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ func NewTroubleshootCmd(flags *flags.GlobalFlags) *cobra.Command {
5555

5656
func (cmd *TroubleshootCmd) Run(ctx context.Context, args []string) {
5757
// (ThomasK33): We're creating an anonymous struct here, so that we group
58-
// everything and then we can serialize it in one call.
58+
// everything so that we can serialize it in one call.
5959
var info struct {
6060
CLIVersion string
6161
Config *config.Config
6262
Providers map[string]provider.ProviderWithDefault
6363
DevPodProInstances []DevPodProInstance
6464
Workspace *pkgprovider.Workspace
65-
WorkspaceStatus client.Status
65+
WorkspaceStatus string
6666
WorkspaceTroubleshoot *managementv1.DevPodWorkspaceInstanceTroubleshoot
6767
DaemonStatus *daemon.Status
6868

pkg/client/client.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type BaseClient interface {
2323
RefreshOptions(ctx context.Context, userOptions []string, reconfigure bool) error
2424

2525
// Status retrieves the workspace status
26-
Status(ctx context.Context, options StatusOptions) (Status, error)
26+
Status(ctx context.Context, options StatusOptions) (string, error)
2727

2828
// Stop stops the workspace
2929
Stop(ctx context.Context, options StopOptions) error
@@ -45,13 +45,13 @@ type Client interface {
4545
AgentURL() string
4646

4747
// Create creates a new workspace
48-
Create(ctx context.Context, options CreateOptions) error
48+
Create(ctx context.Context) error
4949

5050
// Describe retrieves the virtual machine description
5151
Describe(ctx context.Context) (string, error)
5252

5353
// Start starts the workspace
54-
Start(ctx context.Context, options StartOptions) error
54+
Start(ctx context.Context) error
5555

5656
// Command creates an SSH tunnel into the workspace
5757
Command(ctx context.Context, options CommandOptions) error
@@ -135,12 +135,6 @@ type WorkspaceClient interface {
135135
AgentInfo(options provider.CLIOptions) (string, *provider.AgentWorkspaceInfo, error)
136136
}
137137

138-
type InitOptions struct{}
139-
140-
type ValidateOptions struct{}
141-
142-
type StartOptions struct{}
143-
144138
type StopOptions struct {
145139
Platform devpod.PlatformOptions `json:"platform"`
146140
}
@@ -153,8 +147,6 @@ type DeleteOptions struct {
153147
GracePeriod string `json:"gracePeriod,omitempty"`
154148
}
155149

156-
type CreateOptions struct{}
157-
158150
type StatusOptions struct {
159151
ContainerStatus bool `json:"containerStatus,omitempty"`
160152
}
@@ -182,22 +174,14 @@ type SshOptions struct {
182174
Stdout io.Writer
183175
}
184176

185-
type ImportWorkspaceOptions map[string]string
186-
187-
type Status string
188-
189177
const (
190178
StatusRunning = "Running"
191179
StatusBusy = "Busy"
192180
StatusStopped = "Stopped"
193181
StatusNotFound = "NotFound"
194182
)
195183

196-
const (
197-
DescriptionNotFound = "{}"
198-
)
199-
200-
func ParseStatus(in string) (Status, error) {
184+
func ParseStatus(in string) (string, error) {
201185
in = strings.ToUpper(strings.TrimSpace(in))
202186
switch in {
203187
case "RUNNING":
@@ -217,6 +201,10 @@ func ParseStatus(in string) (Status, error) {
217201
}
218202
}
219203

204+
const (
205+
DescriptionNotFound = "{}"
206+
)
207+
220208
type WorkspaceStatus struct {
221209
ID string `json:"id,omitempty"`
222210
Context string `json:"context,omitempty"`

pkg/client/clientimplementation/daemonclient/status.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
func (c *client) Status(
1212
ctx context.Context,
1313
opt clientpkg.StatusOptions,
14-
) (clientpkg.Status, error) {
14+
) (string, error) {
1515
c.m.Lock()
1616
defer c.m.Unlock()
1717

18-
status := clientpkg.Status(clientpkg.StatusNotFound)
18+
status := clientpkg.StatusNotFound
1919
baseClient, err := c.initPlatformClient(ctx)
2020
if err != nil {
2121
return status, err
@@ -32,5 +32,5 @@ func (c *client) Status(
3232
return status, fmt.Errorf("couldn't find workspace")
3333
}
3434

35-
return clientpkg.Status(instance.Status.LastWorkspaceStatus), nil
35+
return string(instance.Status.LastWorkspaceStatus), nil
3636
}

pkg/client/clientimplementation/machine_client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ func (s *machineClient) Context() string {
187187
return s.machine.Context
188188
}
189189

190-
func (s *machineClient) Create(ctx context.Context, options client.CreateOptions) error {
190+
func (s *machineClient) Create(ctx context.Context) error {
191191
return s.executor.lifecycleCommand(ctx, "create", s.config.Exec.Create, "creating", "created")
192192
}
193193

194-
func (s *machineClient) Start(ctx context.Context, options client.StartOptions) error {
194+
func (s *machineClient) Start(ctx context.Context) error {
195195
return s.executor.lifecycleCommand(ctx, "start", s.config.Exec.Start, "starting", "started")
196196
}
197197

@@ -216,7 +216,7 @@ func (s *machineClient) Command(ctx context.Context, commandOptions client.Comma
216216
func (s *machineClient) Status(
217217
ctx context.Context,
218218
options client.StatusOptions,
219-
) (client.Status, error) {
219+
) (string, error) {
220220
stdout := &bytes.Buffer{}
221221
stderr := &bytes.Buffer{}
222222

pkg/client/clientimplementation/proxy_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func (s *proxyClient) Delete(ctx context.Context, opt client.DeleteOptions) erro
384384
func (s *proxyClient) Status(
385385
ctx context.Context,
386386
options client.StatusOptions,
387-
) (client.Status, error) {
387+
) (string, error) {
388388
s.m.Lock()
389389
defer s.m.Unlock()
390390

pkg/client/clientimplementation/workspace_client.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (s *workspaceClient) Unlock() {
324324
}
325325
}
326326

327-
func (s *workspaceClient) Create(ctx context.Context, options client.CreateOptions) error {
327+
func (s *workspaceClient) Create(ctx context.Context) error {
328328
s.m.Lock()
329329
defer s.m.Unlock()
330330

@@ -353,7 +353,7 @@ func (s *workspaceClient) Create(ctx context.Context, options client.CreateOptio
353353
}
354354

355355
// create the machine
356-
return machineClient.Create(ctx, client.CreateOptions{})
356+
return machineClient.Create(ctx)
357357
}
358358

359359
func (s *workspaceClient) Delete(ctx context.Context, opt client.DeleteOptions) error {
@@ -469,7 +469,7 @@ func (s *workspaceClient) isMachineRunning(ctx context.Context) (bool, error) {
469469
return false, nil
470470
}
471471

472-
func (s *workspaceClient) Start(ctx context.Context, options client.StartOptions) error {
472+
func (s *workspaceClient) Start(ctx context.Context) error {
473473
s.m.Lock()
474474
defer s.m.Unlock()
475475

@@ -482,7 +482,7 @@ func (s *workspaceClient) Start(ctx context.Context, options client.StartOptions
482482
return err
483483
}
484484

485-
return machineClient.Start(ctx, options)
485+
return machineClient.Start(ctx)
486486
}
487487

488488
func (s *workspaceClient) Stop(ctx context.Context, opt client.StopOptions) error {
@@ -559,7 +559,7 @@ func (s *workspaceClient) Command(
559559
func (s *workspaceClient) Status(
560560
ctx context.Context,
561561
options client.StatusOptions,
562-
) (client.Status, error) {
562+
) (string, error) {
563563
s.m.Lock()
564564
defer s.m.Unlock()
565565

@@ -609,6 +609,27 @@ func (s *workspaceClient) Status(
609609
return client.StatusNotFound, nil
610610
}
611611

612+
func (s *workspaceClient) Describe(ctx context.Context) (string, error) {
613+
s.m.Lock()
614+
defer s.m.Unlock()
615+
616+
// check if provider has 'describe' command
617+
if s.isMachineProvider() && len(s.config.Exec.Describe) > 0 {
618+
if s.machine == nil {
619+
return client.DescriptionNotFound, nil
620+
}
621+
622+
machineClient, err := NewMachineClient(s.devPodConfig, s.config, s.machine, s.log)
623+
if err != nil {
624+
return client.DescriptionNotFound, err
625+
}
626+
627+
return machineClient.Describe(ctx)
628+
}
629+
630+
return client.DescriptionNotFound, nil
631+
}
632+
612633
func (s *workspaceClient) initLock() error {
613634
s.workspaceLockOnce.Do(func() {
614635
s.m.Lock()
@@ -640,7 +661,7 @@ func (s *workspaceClient) initLock() error {
640661
return s.workspaceLockErr
641662
}
642663

643-
func (s *workspaceClient) getContainerStatus(ctx context.Context) (client.Status, error) {
664+
func (s *workspaceClient) getContainerStatus(ctx context.Context) (string, error) {
644665
stdout := &bytes.Buffer{}
645666
buf := &bytes.Buffer{}
646667
compressed, info, err := s.compressedAgentInfo(provider.CLIOptions{})
@@ -694,27 +715,6 @@ func (s *workspaceClient) getContainerStatus(ctx context.Context) (client.Status
694715
return parsed, nil
695716
}
696717

697-
func (s *workspaceClient) Describe(ctx context.Context) (string, error) {
698-
s.m.Lock()
699-
defer s.m.Unlock()
700-
701-
// check if provider has 'describe' command
702-
if s.isMachineProvider() && len(s.config.Exec.Describe) > 0 {
703-
if s.machine == nil {
704-
return client.DescriptionNotFound, nil
705-
}
706-
707-
machineClient, err := NewMachineClient(s.devPodConfig, s.config, s.machine, s.log)
708-
if err != nil {
709-
return client.DescriptionNotFound, err
710-
}
711-
712-
return machineClient.Describe(ctx)
713-
}
714-
715-
return client.DescriptionNotFound, nil
716-
}
717-
718718
func (s *workspaceClient) isMachineProvider() bool {
719719
return len(s.config.Exec.Create) > 0
720720
}
@@ -933,7 +933,7 @@ func handleStoppedStatus(
933933
create bool,
934934
) error {
935935
if create {
936-
err := workspaceClient.Start(ctx, client.StartOptions{})
936+
err := workspaceClient.Start(ctx)
937937
if err != nil {
938938
return fmt.Errorf("start workspace: %w", err)
939939
}
@@ -948,7 +948,7 @@ func handleNotFoundStatus(
948948
create bool,
949949
) error {
950950
if create {
951-
err := workspaceClient.Create(ctx, client.CreateOptions{})
951+
err := workspaceClient.Create(ctx)
952952
if err != nil {
953953
return err
954954
}

pkg/workspace/workspace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ func createWorkspace(
442442
}
443443

444444
// create machine
445-
err = machineClient.Create(ctx, client.CreateOptions{})
445+
err = machineClient.Create(ctx)
446446
if err != nil {
447447
_ = clientimplementation.DeleteMachineFolder(
448448
machineConfig.Context,

0 commit comments

Comments
 (0)