-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproperties_list.go
39 lines (34 loc) · 1.07 KB
/
properties_list.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
// Copyright (c) 2020 Steve Jones
// SPDX-License-Identifier: BSD-2-Clause
package cmd
import (
"context"
"fmt"
"github.com/sjones4/eucalyptus-sdk-go/service/euprop"
"github.com/spf13/cobra"
)
// listPropertiesCmd represents the list command
var listPropertiesCmd = &cobra.Command{
Use: "list",
Short: "List property names and values",
Run: func(cmd *cobra.Command, args []string) {
input := &euprop.DescribePropertiesInput{}
DoInput(cmd, func(ccmd *CheckedCommand) {
propertyPrefix := ccmd.GetFlagString("property-prefix")
if propertyPrefix != "" {
input.Properties = []string{propertyPrefix}
}
})
svc := GetPropertiesSvc()
request := svc.DescribePropertiesRequest(input)
response, err := request.Send(context.Background())
DoCommandError(cmd, err)
for _, property := range response.DescribePropertiesOutput.Properties {
fmt.Printf("PROPERTY\t%s\t%s\n", *property.Name, *property.Value)
}
},
}
func init() {
propertiesCmd.AddCommand(listPropertiesCmd)
listPropertiesCmd.Flags().String("property-prefix", "", "Property name prefix match")
}