This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
get.go
60 lines (52 loc) · 1.86 KB
/
get.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
57
58
59
60
///////////////////////////////////////////////////////////////////////
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
///////////////////////////////////////////////////////////////////////
package cmd
import (
"io"
"github.com/spf13/cobra"
"github.com/vmware/dispatch/pkg/dispatchcli/i18n"
)
var (
getLong = `Display one or many resources.` + validResources
getExample = i18n.T(`
# List all dispatch functions.
dispatch get functions
# List a single image with name "demo-python3-runtime"
dispatch get image demo-python3-runtime
# List a single function with name "open-sesame"
dispatch get function open-sesame`)
)
// NewCmdGet creates a command object for the generic "get" action, which
// retrieves one or more resources from a server.
func NewCmdGet(out io.Writer, errOut io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "get TYPE [NAME|ID] [flags]",
Short: i18n.T("Display one or many resources"),
Long: getLong,
Example: getExample,
Run: func(cmd *cobra.Command, args []string) {
err := runGet(out, errOut, cmd, args)
CheckErr(err)
},
SuggestFor: []string{"list"},
}
cmd.AddCommand(NewCmdGetBaseImage(out, errOut))
cmd.AddCommand(NewCmdGetImage(out, errOut))
cmd.AddCommand(NewCmdGetFunction(out, errOut))
cmd.AddCommand(NewCmdGetRun(out, errOut))
cmd.AddCommand(NewCmdGetSecret(out, errOut))
cmd.AddCommand(NewCmdGetAPI(out, errOut))
cmd.AddCommand(NewCmdGetSubscription(out, errOut))
cmd.AddCommand(NewCmdGetEventDriver(out, errOut))
cmd.AddCommand(NewCmdGetEventDriverType(out, errOut))
cmd.AddCommand(NewCmdGetApplication(out, errOut))
cmd.AddCommand(NewCmdGetServiceClass(out, errOut))
cmd.AddCommand(NewCmdGetServiceInstance(out, errOut))
return cmd
}
func runGet(out, errOut io.Writer, cmd *cobra.Command, args []string) error {
runHelp(cmd, args)
return nil
}