-
Notifications
You must be signed in to change notification settings - Fork 14
/
put.go
56 lines (44 loc) · 1.23 KB
/
put.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
45
46
47
48
49
50
51
52
53
54
55
56
package cmd
import (
"os"
"path/filepath"
"github.com/infuseai/artivc/internal/core"
"github.com/spf13/cobra"
)
var putCmd = &cobra.Command{
Use: "put [-m <message>] <dir> <repository>[@<tag>]",
DisableFlagsInUseLine: true,
Short: "Upload data to a repository",
Example: ` # Upload the latest version
avc put ./folder/ /path/to/mydataset
# Upload the specific version
avc put ./folder/ /path/to/mydataset@v1.0.0`,
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
baseDir, err := filepath.Abs(args[0])
exitWithError(err)
repoUrl, ref, err := parseRepoStr(args[1])
exitWithError(err)
// options
option := core.PushOptions{}
message, err := cmd.Flags().GetString("message")
exitWithError(err)
if message != "" {
option.Message = &message
}
if ref != "" {
option.Tag = &ref
}
// Create temp metadata
metadataDir, _ := os.MkdirTemp(os.TempDir(), "*-avc")
defer os.RemoveAll(metadataDir)
config := core.NewConfig(baseDir, metadataDir, repoUrl)
// push
mngr, err := core.NewArtifactManager(config)
exitWithError(err)
exitWithError(mngr.Push(option))
},
}
func init() {
putCmd.Flags().StringP("message", "m", "", "Commit meessage")
}