()
| 134 | } |
| 135 | |
| 136 | func (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 | } |
no test coverage detected