mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-09-13 23:09:08 +00:00
feat(resource): add expiry support (--expired, --clear-expired)
This commit is contained in:
parent
43cc96a43d
commit
072ae89378
3 changed files with 69 additions and 0 deletions
|
@ -25,6 +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("expired", "", "Expiry date/time (ISO8601), e.g. 2025-12-31T23:59:59Z")
|
||||
|
||||
ResourceCreateCmd.MarkFlagRequired("name")
|
||||
ResourceCreateCmd.MarkFlagRequired("password")
|
||||
|
@ -55,6 +56,10 @@ func ResourceCreate(cmd *cobra.Command, args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
expired, err := cmd.Flags().GetString("expired")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jsonOutput, err := cmd.Flags().GetBool("json")
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -83,6 +88,12 @@ func ResourceCreate(cmd *cobra.Command, args []string) error {
|
|||
return fmt.Errorf("Creating Resource: %w", err)
|
||||
}
|
||||
|
||||
if expired != "" {
|
||||
if err := SetResourceExpiry(ctx, client, id, expired); 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