-
Notifications
You must be signed in to change notification settings - Fork 26
/
load.go
41 lines (33 loc) · 858 Bytes
/
load.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
package cmd
import (
"os"
"path"
"github.com/aserto-dev/topaz/pkg/cli/cc"
"github.com/aserto-dev/topaz/pkg/cli/clients"
"github.com/fatih/color"
"github.com/google/uuid"
)
type LoadCmd struct {
File string `arg:"" default:"manifest.yaml" help:"absolute path to manifest file"`
clients.Config
}
var defaultManifestName = "manifest.yaml"
func (cmd *LoadCmd) Run(c *cc.CommonCtx) error {
if err := CheckRunning(c); err != nil {
return err
}
cmd.Config.SessionID = uuid.NewString()
dirClient, err := clients.NewDirectoryClient(c, &cmd.Config)
if err != nil {
return err
}
if cmd.File == defaultManifestName {
currentDir, err := os.Getwd()
if err != nil {
return err
}
cmd.File = path.Join(currentDir, defaultManifestName)
}
color.Green(">>> load manifest from %s", cmd.File)
return dirClient.Load(c.Context, cmd.File)
}