Skip to content

Commit 713686c

Browse files
authored
push models (fake) (#395)
1 parent 7ce4883 commit 713686c

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

cli/cmd/collection_rm.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func (r *runners) InitCollectionRemove(parent *cobra.Command) *cobra.Command {
1616
SilenceUsage: true,
1717
}
1818
parent.AddCommand(cmd)
19+
1920
cmd.Flags().StringVar(&r.outputFormat, "output", "table", "The output format to use. One of: json|table (default: table)")
2021

2122
return cmd

cli/cmd/model_push.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
11
package cmd
22

33
import (
4+
"fmt"
5+
46
"github.com/spf13/cobra"
57
)
68

79
func (r *runners) InitModelPush(parent *cobra.Command) *cobra.Command {
810
cmd := &cobra.Command{
911
Use: "push",
10-
Short: "",
11-
Long: ``,
12+
Short: "push a model to the model repository",
13+
Long: `push a model to the mdoel repository`,
1214
RunE: r.pushModel,
15+
Args: cobra.ExactArgs(1),
1316
SilenceUsage: true,
1417
}
1518
parent.AddCommand(cmd)
1619

20+
cmd.Flags().StringVar(&r.args.modelPushName, "name", "", "The name of the model to push")
21+
cmd.MarkFlagRequired("name")
22+
1723
return cmd
1824
}
1925

2026
func (r *runners) pushModel(_ *cobra.Command, args []string) error {
21-
return nil
27+
path := args[0]
28+
29+
// THIS IS JUST A PLACEHOLDER
30+
// IT WILL ACTUALLY PUSH TO OCI
31+
// BUT NOW IT'S CALLING AN API TO SIMULATE
32+
33+
err := r.kotsAPI.PushModel(r.args.modelPushName, path)
34+
if err != nil {
35+
return err
36+
}
37+
38+
_, err = fmt.Fprintf(r.w, "Model %s has been pushed\n", r.args.modelPushName)
39+
return err
2240
}

cli/cmd/runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ type runnerArgs struct {
243243
removeClusterDryRun bool
244244

245245
modelCollectionCreateName string
246+
modelPushName string
246247

247248
lsAppVersion string
248249
lsVersionsClusterKubernetesDistribution string

pkg/kotsclient/model_push.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package kotsclient
2+
3+
import "net/http"
4+
5+
type pushModelRequest struct {
6+
Name string `json:"name"`
7+
}
8+
9+
func (c *VendorV3Client) PushModel(name string, path string) error {
10+
reqBody := pushModelRequest{
11+
Name: name,
12+
}
13+
14+
// ignore path
15+
16+
err := c.DoJSON("POST", "/v3/models/push-delete-this-route", http.StatusCreated, reqBody, nil)
17+
if err != nil {
18+
return err
19+
}
20+
21+
return nil
22+
}

0 commit comments

Comments
 (0)