/
create.go
44 lines (37 loc) · 852 Bytes
/
create.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
37
38
39
40
41
42
43
44
package cmd
import (
"context"
"github.com/dirien/devpod-provider-equinix/pkg/equinix"
"github.com/loft-sh/log"
"github.com/spf13/cobra"
)
// CreateCmd holds the cmd flags
type CreateCmd struct{}
// NewCreateCmd defines a command
func NewCreateCmd() *cobra.Command {
cmd := &CreateCmd{}
createCmd := &cobra.Command{
Use: "create",
Short: "Create an instance",
RunE: func(_ *cobra.Command, args []string) error {
equinixProvider, err := equinix.NewProvider(log.Default, false)
if err != nil {
return err
}
return cmd.Run(
context.Background(),
equinixProvider,
log.Default,
)
},
}
return createCmd
}
// Run runs the command logic
func (cmd *CreateCmd) Run(
ctx context.Context,
equinixProvider *equinix.EquinixProvider,
logs log.Logger,
) error {
return equinix.Create(ctx, equinixProvider)
}