(commonFlags *secretsFlags)
| 195 | } |
| 196 | |
| 197 | func secretsUploadCmd(commonFlags *secretsFlags) *cobra.Command { |
| 198 | flags := &secretsUploadFlags{} |
| 199 | command := &cobra.Command{ |
| 200 | Use: "upload <file1> [<fileN>]...", |
| 201 | Short: "Upload variables defined in one or more .env files.", |
| 202 | Args: cobra.MinimumNArgs(1), |
| 203 | PreRunE: func(cmd *cobra.Command, args []string) error { |
| 204 | return envsec.ValidateFormat(flags.format) |
| 205 | }, |
| 206 | RunE: func(cmd *cobra.Command, paths []string) error { |
| 207 | secrets, err := commonFlags.envsec(cmd) |
| 208 | if err != nil { |
| 209 | return errors.WithStack(err) |
| 210 | } |
| 211 | absPaths, err := fileutil.EnsureAbsolutePaths(paths) |
| 212 | if err != nil { |
| 213 | return errors.WithStack(err) |
| 214 | } |
| 215 | return secrets.Upload(cmd.Context(), absPaths, flags.format) |
| 216 | }, |
| 217 | } |
| 218 | |
| 219 | command.Flags().StringVarP( |
| 220 | &flags.format, "format", "f", "", "File format: dotenv or json") |
| 221 | |
| 222 | return command |
| 223 | } |
| 224 | |
| 225 | func secretsInitFunc( |
| 226 | cmd *cobra.Command, |
no test coverage detected