Bug #17252

Unable to set empty parameter via hammer

Added by Tomáš Strachota about 1 year ago. Updated about 1 month ago.

Status:Closed
Priority:Normal
Assigned To:Martin Bacovsky
Category:Hammer core
Target version:Foreman - Team Ivan - Iteration 23
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/hammer-cli/pull/260
Story points-
Velocity based estimate-
Releasehammer-cli-0.12.0Release relationshipAuto

Description

Hammer doesn't allow to to send nil values, which prevents users from re-setting attributes to their default values in some cases. The only thing a user can do is to send empty string --param="" but it's not the same as nil.

From the discussions about this topic it seems that one of the solutions could be to use a reserved value, that would be translated to nil internally. Users could override the value using some env variable.
For example:

hammer domain update --name test --dns nil
HAMMER_NIL=None hammer domain update --name test --dns None


Related issues

Related to Hammer CLI - Bug #13994: Cannot dis-associate a Subnet from a Domain using Hammer New 03/01/2016
Related to Hammer CLI - Bug #17250: Unable to remove all locations or organizations from a do... New 11/07/2016
Related to Hammer CLI - Tracker #2823: Tracker for usability issues New 07/24/2013
Related to Hammer CLI - Bug #21768: Support NIL values in searchable options Ready For Testing 11/26/2017
Related to Hammer CLI - Bug #22009: Invalid routes with NIL as a route param are selected Assigned 12/18/2017

Associated revisions

Revision cd5cc9d6
Added by Martin Bacovsky about 1 month ago

Fixes #17252 - Allow empty parameters in hammer (#260)

  • Fixes #17252 - Allow empty parameters in hammer

This change allows user to use nil as a valid value for an argument.

$ hammer command --option=NIL
$ HAMMER_NIL=NULL hammer command --option=NULL

Just before option normalization the 'NIL' string is replaced for
special internal object which help us to distinguish between unused
options and options set to nil. The internal object is replaced with
nil after all options are collected and unused options filtered out.

History

#1 Updated by Tomáš Strachota about 1 year ago

  • Related to Bug #13994: Cannot dis-associate a Subnet from a Domain using Hammer added

#2 Updated by Tomáš Strachota about 1 year ago

  • Related to Bug #17250: Unable to remove all locations or organizations from a domain added

#3 Updated by Tomáš Strachota about 1 year ago

#4 Updated by Martin Bacovsky 2 months ago

  • Target version changed from Team Marek backlog to Team Ivan - Iteration 23
  • Assigned To set to Martin Bacovsky
  • Status changed from New to Assigned

#5 Updated by The Foreman Bot 2 months ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/hammer-cli/pull/260 added

#6 Updated by Martin Bacovsky about 1 month ago

  • % Done changed from 0 to 100
  • Status changed from Ready For Testing to Closed

#7 Updated by Martin Bacovsky about 1 month ago

  • Release set to hammer-cli-0.12.0

#8 Updated by Martin Bacovsky about 1 month ago

  • Related to Bug #21768: Support NIL values in searchable options added

#9 Updated by Martin Bacovsky 29 days ago

  • Related to Bug #22009: Invalid routes with NIL as a route param are selected added

Also available in: Atom PDF