Skip to content

Implemented spawn config validation#40

Open
victormlg wants to merge 1 commit intocfengine:mainfrom
victormlg:spawn-validation
Open

Implemented spawn config validation#40
victormlg wants to merge 1 commit intocfengine:mainfrom
victormlg:spawn-validation

Conversation

@victormlg
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Member

@olehermanse olehermanse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit hard to follow the code without seeing the bigger picture, please add:

  • --validate option which validates the config and won't spawn in the future when that is implemented.
  • Some shell tests which use the --validate option and prove that it's passing and failing in the right situations.
  • Some explanation and examples for the feature in the README. Clearly mark it as work in progress.

```yaml
templates:
ubuntu:
count: 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count should be moved to group, not be in template

Copy link
Copy Markdown
Contributor Author

@victormlg victormlg Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Templates is not a real key in the final config, all the names defined in templates get expanded before analyzing the config. Ex:

templates:
  mycfengine: 
    version: 3.27.0

groups:
  - myhub:
      role: hub
      cfengine: mycfengine

Gets turned into:

groups:
  - myhub:
      role: hub
      cfengine: 
        version: 3.27.0

Also, I believe it makes sense to have "count" inside "spawn", Ex:

groups:
 - client1:
      role: client
      source:
        count: 4
        mode: spawn
        spawn:
          provider: vagrant
          vagrant:
            box: ubuntu/focal64
 
  - client2:
      role: client
      source:
        # count: 4. Here count doesn't make sense, because we have saved hosts
        mode: save
        hosts: [ 8.8.8.8 ]

Signed-off-by: Victor Moene <victor.moene@northern.tech>
exit 0
fi

echo "Mock Vagrant: Unknown command $@" >&2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "Mock Vagrant: Unknown command $@" >&2
echo "Mock Vagrant: Unknown command '$*'" >&2

@@ -0,0 +1,30 @@
#/usr/bin/env bash
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#/usr/bin/env bash
#!/usr/bin/env bash

key = "@{}".format(bootstrap)

# TODO: Change how to check this if cloud_state.json changes format
if key in state and state[key].values()[1]["role"] != "hub":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably have to convert the 'dict_values' object to a list before you access it with an index

>>> d = {"a": 1, "b": 2}
>>> d.values()[1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'dict_values' object is not subscriptable
>>> list(d.values())[1]
2

return

if remote_download and not is_package_url(package):
raise UserError("Package '{}' is not a valid package URL")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a format specifier but no arguments

return self


def rgetattr(obj, attr, *args):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused function?


class GroupConfig(Config):
role: Literal["client", "hub"]
# "Field" forces pydantic to report errors on the branch defined by the field "provider"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# "Field" forces pydantic to report errors on the branch defined by the field "provider"
# "Field" forces pydantic to report errors on the branch defined by the field "mode"



class GCPConfig(Config):
image: str # There is no list of avalaible GCP platforms to validate against yet
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
image: str # There is no list of avalaible GCP platforms to validate against yet
image: str # There is no list of available GCP platforms to validate against yet


### Spawn and install cfengine from a config

**this feature is still in work in progress**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**this feature is still in work in progress**
**this feature is still a work in progress**

source: ubuntu
```

It up will spawn the necessary VMs and install cfengine using cf-remote
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It up will spawn the necessary VMs and install cfengine using cf-remote
up will spawn the necessary VMs and install cfengine using cf-remote

"aws": {
"key": "TBD",
"secret": "TBD",
"key_pair": "TDB",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"key_pair": "TDB",
"key_pair": "TBD",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants