MCPcopy Index your code
hub / github.com/coder/coder / secretUpdate

Method secretUpdate

cli/secret.go:136–215  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

134}
135
136func (r *RootCmd) secretUpdate() *serpent.Command {
137 var (
138 value string
139 description string
140 env string
141 file string
142 )
143
144 cmd := &serpent.Command{
145 Use: "update <name>",
146 Short: "Update a secret",
147 Long: strings.Join([]string{
148 "At least one of --value, --description, --env, or --file must be specified.",
149 "Provide the secret value by at most one of --value or non-interactive stdin (pipe or redirect).",
150 }, " "),
151 Middleware: serpent.Chain(
152 serpent.RequireNArgs(1),
153 ),
154 Options: serpent.OptionSet{
155 {
156 Name: "value",
157 Flag: "value",
158 Description: "Update the secret value. For security reasons, prefer non-interactive stdin (pipe or redirect).",
159 Value: serpent.StringOf(&value),
160 },
161 {
162 Name: "description",
163 Flag: "description",
164 Description: "Update the secret description. Pass an empty string to clear it.",
165 Value: serpent.StringOf(&description),
166 },
167 {
168 Name: "env",
169 Flag: "env",
170 Description: "Name of the workspace environment variable that this secret will set. Pass an empty string to clear it.",
171 Value: serpent.StringOf(&env),
172 },
173 {
174 Name: "file",
175 Flag: "file",
176 Description: "Workspace file path where this secret will be written. Must start with ~/ or /. Pass an empty string to clear it.",
177 Value: serpent.StringOf(&file),
178 },
179 },
180 Handler: func(inv *serpent.Invocation) error {
181 client, err := r.InitClient(inv)
182 if err != nil {
183 return err
184 }
185
186 req := codersdk.UpdateUserSecretRequest{}
187 resolvedValue, ok, err := secretValue(inv, value)
188 if err != nil {
189 return err
190 }
191 if ok {
192 req.Value = &resolvedValue
193 }

Callers 1

secretsMethod · 0.95

Calls 7

InitClientMethod · 0.95
KeywordFunction · 0.92
secretValueFunction · 0.85
userSetOptionFunction · 0.85
UpdateUserSecretMethod · 0.80
ContextMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected