/
init.go
36 lines (30 loc) · 858 Bytes
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cmd
import (
"context"
"github.com/loft-sh/devpod-provider-digitalocean/pkg/digitalocean"
"github.com/loft-sh/devpod-provider-digitalocean/pkg/options"
"github.com/loft-sh/devpod/pkg/log"
"github.com/spf13/cobra"
)
// InitCmd holds the cmd flags
type InitCmd struct{}
// NewInitCmd defines a command
func NewInitCmd() *cobra.Command {
cmd := &InitCmd{}
initCmd := &cobra.Command{
Use: "init",
Short: "Init an instance",
RunE: func(_ *cobra.Command, args []string) error {
options, err := options.FromEnv(true)
if err != nil {
return err
}
return cmd.Run(context.Background(), options, log.Default)
},
}
return initCmd
}
// Run runs the command logic
func (cmd *InitCmd) Run(ctx context.Context, options *options.Options, log log.Logger) error {
return digitalocean.NewDigitalOcean(options.Token).Init(ctx)
}