mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-09-13 23:09:08 +00:00
cli: add --expiry (RFC3339/duration), support 'none' to clear
This commit is contained in:
parent
59fda4a584
commit
bfee06deab
3 changed files with 152 additions and 2 deletions
|
@ -25,7 +25,7 @@ func init() {
|
|||
ResourceCreateCmd.Flags().StringP("password", "p", "", "Resource Password")
|
||||
ResourceCreateCmd.Flags().StringP("description", "d", "", "Resource Description")
|
||||
ResourceCreateCmd.Flags().StringP("folderParentID", "f", "", "Folder in which to create the Resource")
|
||||
|
||||
ResourceCreateCmd.Flags().String("expiry", "", "Expiry as RFC3339 (e.g. 2025-12-31T23:59:59Z) or duration (e.g. 7d, 12h, 30m, 1w2d)")
|
||||
ResourceCreateCmd.MarkFlagRequired("name")
|
||||
ResourceCreateCmd.MarkFlagRequired("password")
|
||||
}
|
||||
|
@ -55,6 +55,12 @@ func ResourceCreate(cmd *cobra.Command, args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
expiry, err := cmd.Flags().GetString("expiry")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jsonOutput, err := cmd.Flags().GetBool("json")
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -83,6 +89,12 @@ func ResourceCreate(cmd *cobra.Command, args []string) error {
|
|||
return fmt.Errorf("Creating Resource: %w", err)
|
||||
}
|
||||
|
||||
if expiry != "" {
|
||||
if err := SetResourceExpiry(ctx, client, id, expiry); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if jsonOutput {
|
||||
jsonId, err := json.MarshalIndent(
|
||||
map[string]string{"id": id},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue