/
get-iam-policy.go
76 lines (51 loc) · 1.76 KB
/
get-iam-policy.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Code generated. DO NOT EDIT.
package main
import (
"github.com/spf13/cobra"
"fmt"
"github.com/golang/protobuf/jsonpb"
iampb "google.golang.org/genproto/googleapis/iam/v1"
"os"
)
var GetIamPolicyInput iampb.GetIamPolicyRequest
var GetIamPolicyFromFile string
func init() {
SecretManagerServiceCmd.AddCommand(GetIamPolicyCmd)
GetIamPolicyInput.Options = new(iampb.GetPolicyOptions)
GetIamPolicyCmd.Flags().StringVar(&GetIamPolicyInput.Resource, "resource", "", "Required. REQUIRED: The resource for which the policy is...")
GetIamPolicyCmd.Flags().Int32Var(&GetIamPolicyInput.Options.RequestedPolicyVersion, "options.requested_policy_version", 0, "Optional. The policy format version to be...")
GetIamPolicyCmd.Flags().StringVar(&GetIamPolicyFromFile, "from_file", "", "Absolute path to JSON file containing request payload")
}
var GetIamPolicyCmd = &cobra.Command{
Use: "get-iam-policy",
Short: "Gets the access control policy for a secret. ...",
Long: "Gets the access control policy for a secret. Returns empty policy if the secret exists and does not have a policy set.",
PreRun: func(cmd *cobra.Command, args []string) {
if GetIamPolicyFromFile == "" {
cmd.MarkFlagRequired("resource")
}
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
in := os.Stdin
if GetIamPolicyFromFile != "" {
in, err = os.Open(GetIamPolicyFromFile)
if err != nil {
return err
}
defer in.Close()
err = jsonpb.Unmarshal(in, &GetIamPolicyInput)
if err != nil {
return err
}
}
if Verbose {
printVerboseInput("SecretManager", "GetIamPolicy", &GetIamPolicyInput)
}
resp, err := SecretManagerClient.GetIamPolicy(ctx, &GetIamPolicyInput)
if Verbose {
fmt.Print("Output: ")
}
printMessage(resp)
return err
},
}