-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathedit.go
More file actions
58 lines (46 loc) · 1.36 KB
/
edit.go
File metadata and controls
58 lines (46 loc) · 1.36 KB
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
57
58
package cmd
import (
"context"
"fmt"
"github.com/MakeNowJust/heredoc"
"github.com/raystack/salt/cli/printer"
stencilv1beta1 "github.com/raystack/stencil/proto/raystack/stencil/v1beta1"
"github.com/spf13/cobra"
)
func editSchemaCmd(cdk *CDK) *cobra.Command {
var comp, namespaceID string
var req stencilv1beta1.UpdateSchemaMetadataRequest
cmd := &cobra.Command{
Use: "edit",
Short: "Edit a schema",
Args: cobra.ExactArgs(1),
Example: heredoc.Doc(`
$ stencil schema edit booking -n raystack -c COMPATIBILITY_BACKWARD
`),
RunE: func(cmd *cobra.Command, args []string) error {
spinner := printer.Spin("")
defer spinner.Stop()
client, cancel, err := createClient(cmd, cdk)
if err != nil {
return err
}
defer cancel()
schemaID := args[0]
req.NamespaceId = namespaceID
req.SchemaId = schemaID
req.Compatibility = stencilv1beta1.Schema_Compatibility(stencilv1beta1.Schema_Compatibility_value[comp])
_, err = client.UpdateSchemaMetadata(context.Background(), &req)
if err != nil {
return err
}
spinner.Stop()
fmt.Printf("Schema successfully updated")
return nil
},
}
cmd.Flags().StringVarP(&namespaceID, "namespace", "n", "", "Parent namespace ID")
cmd.MarkFlagRequired("namespace")
cmd.Flags().StringVarP(&comp, "comp", "c", "", "Schema compatibility")
cmd.MarkFlagRequired("comp")
return cmd
}