Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3832

Traceback on cfbs remove

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Higher
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: N/A
    • Component/s: cfbs
    • Labels:
      None

      Description

      When I try to cfbs remove a module that is not already added I should get a nice error message instead of a trace back.

      ❯ cfbs remove inventory-fips-mode-setup
      Removing module 'inventory-fips-mode-setup'
      Traceback (most recent call last):
        File "/home/nickanderson/.local/bin/cfbs", line 8, in <module>
          sys.exit(main())
        File "/home/nickanderson/.local/lib/python3.9/site-packages/cfbs/main.py", line 139, in main
          return commands.remove_command(args.args, non_interactive=args.non_interactive)
        File "/home/nickanderson/.local/lib/python3.9/site-packages/cfbs/commands.py", line 579, in remove_command
          clean_command(non_interactive=non_interactive)
        File "/home/nickanderson/.local/lib/python3.9/site-packages/cfbs/commands.py", line 599, in clean_command
          if not _someone_needs_me(module):
        File "/home/nickanderson/.local/lib/python3.9/site-packages/cfbs/commands.py", line 588, in _someone_needs_me
          if this["added_by"] == "cfbs add":
      KeyError: 'added_by'
      ❯ cat cfbs.json
      {
        "name": "Example",
        "type": "policy-set",
        "description": "Example description",
        "build": [
          {
            "name": "masterfiles",
            "description": "Official CFEngine Masterfiles Policy Framework (MPF)",
            "tags": ["supported", "base"],
            "repo": "https://github.com/cfengine/masterfiles",
            "by": "https://github.com/cfengine",
            "version": "0.1.1",
            "commit": "5c7dc5b43088e259a94de4e5a9f17c0ce9781a0f",
            "steps": [
              "run ./autogen.sh",
              "delete ./autogen.sh",
              "run ./cfbs/cleanup.sh",
              "delete ./cfbs/cleanup.sh",
              "copy ./ ./"
            ],
            "added_by": "cfbs add"
          },
          {
            "name": "inventory-clamav",
            "description": "Inventory useful information from ClamAV (version, definitions version, definitions date)",
            "url": "https://github.com/nickanderson/cfengine-inventory-clamav/",
            "commit": "1ae7e4d50e576f8323d606dc5c546dee16a4ed85",
            "steps": [
              "copy policy/main.cf services/inventory-clamav/main.cf",
              "json cfbs/def.json def.json"
            ]
          },
          {
            "name": "inventory-etc-hosts",
            "description": "Inventory entries from /etc/hosts",
            "url": "https://github.com/nickanderson/cfengine-inventory-etc-hosts",
            "commit": "fa513964eaf82edf8038ad1cf7c203da550f0ea4",
            "steps": [
              "copy policy/main.cf services/inventory-etc-hosts/main.cf",
              "json cfbs/def.json def.json"
            ]
          }
        ]
      }
      
      

        Attachments

          Activity

            People

            Assignee:
            olehermanse Ole Herman Schumacher Elgesem
            Reporter:
            a10042 Nick Anderson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: