Skip to content

Commit

Permalink
šŸ§¹ use new inventory-format-ansible and `inventory-format-domainlistā€¦
Browse files Browse the repository at this point in the history
ā€¦` names for flags
  • Loading branch information
chris-rock committed Mar 14, 2024
1 parent aa69c2d commit fde88a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions apps/cnquery/cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,18 @@ func init() {
scanCmd.Flags().String("platform-id", "", "Select a specific target asset by providing its platform ID.")

scanCmd.Flags().String("inventory-file", "", "Set the path to the inventory file.")

scanCmd.Flags().Bool("inventory-format-ansible", false, "Set the inventory format to Ansible.")
// "inventory-ansible" is deprecated, use "inventory-format-ansible" instead
scanCmd.Flags().Bool("inventory-ansible", false, "Set the inventory format to Ansible.")
scanCmd.Flags().MarkDeprecated("inventory-ansible", "use --inventory-format-ansible")
scanCmd.Flags().MarkHidden("inventory-ansible")

scanCmd.Flags().Bool("inventory-format-domainlist", false, "Set the inventory format to domain list.")
// "inventory-domainlist" is deprecated, use "inventory-format-domainlist" instead
scanCmd.Flags().Bool("inventory-domainlist", false, "Set the inventory format to domain list.")
scanCmd.Flags().MarkDeprecated("inventory-domainlist", "use --inventory-format-domainlist")
scanCmd.Flags().MarkHidden("inventory-domainlist")

// bundles, packs & incognito mode
scanCmd.Flags().Bool("incognito", false, "Run in incognito mode. Do not report scan results to Mondoo Platform.")
Expand Down
6 changes: 4 additions & 2 deletions cli/inventoryloader/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Parse() (*inventory.Inventory, error) {
}

// force detection
if viper.GetBool("inventory-ansible") {
if viper.GetBool("inventory-format-ansible") || viper.GetBool("inventory-ansible") {
log.Debug().Msg("parse ansible inventory")
inventory, err := parseAnsibleInventory(data)
if err != nil {
Expand All @@ -90,7 +90,7 @@ func Parse() (*inventory.Inventory, error) {
return inventory, nil
}

if viper.GetBool("inventory-domainlist") {
if viper.GetBool("inventory-format-domainlist") || viper.GetBool("inventory-domainlist") {
log.Debug().Msg("parse domainlist inventory")
inventory, err := parseDomainListInventory(data)
if err != nil {
Expand Down Expand Up @@ -119,6 +119,7 @@ func Parse() (*inventory.Inventory, error) {
}

func parseAnsibleInventory(data []byte) (*inventory.Inventory, error) {
log.Info().Msg("use ansible inventory")
inventory, err := ansibleinventory.Parse(data)
if err != nil {
return nil, err
Expand All @@ -127,6 +128,7 @@ func parseAnsibleInventory(data []byte) (*inventory.Inventory, error) {
}

func parseDomainListInventory(data []byte) (*inventory.Inventory, error) {
log.Info().Msg("use domainlist inventory")
inventory, err := domainlist.Parse(bytes.NewReader(data))
if err != nil {
return nil, err
Expand Down

0 comments on commit fde88a7

Please sign in to comment.