Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHEATSHEET.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CFEngine CLI cheatsheet

Quick reference for `cfengine COMMANDS`
Quick reference for `cfengine COMMANDS`.
For the full command list, run `cfengine help` or `cfengine COMMAND --help`.

## Managing hosts
Expand Down Expand Up @@ -86,7 +86,7 @@ cfengine init --policy-set
# Initialize an example build project for working on a custom promise type (python)
cfengine init --promise-type

# Initialize an exapmlte module project for build.cfengine.com (or internal use)
# Initialize an example module project for build.cfengine.com (or internal use)
cfengine init --policy-module

# Initialize an example policy module that takes input data
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ We have different suites:
- Unit tests in `tests/unit` test individual python functions.
- Formatting tests in `tests/format` test the formatter (`cfengine format`).
- Linting tests in `tests/lint` test the linter.
- Shell tests in `tests/shell` tests various subcommands and the tool as a whole in an end-to-end fashion.
- Shell tests in `tests/shell` test various subcommands and the tool as a whole in an end-to-end fashion.
6 changes: 3 additions & 3 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If your editor does not do this automatically, you can run these tools from the
make format
```

## Installing from source:
## Installing from source

For developers working on CFEngine CLI, you can install it globally using pipx:

Expand Down Expand Up @@ -53,7 +53,7 @@ uv run bash tests/run-shell-tests.sh

## Releasing new versions

Releases are [automated using a GH Action](https://github.com/cfengine/cfengine-cli/blob/main/.github/workflows/pypi-publish.yml)
Releases are [automated using a GH Action](https://github.com/cfengine/cfengine-cli/blob/main/.github/workflows/pypi-publish.yml).
We create tags and releases through the GitHub UI.
Go to the releases section in GitHub:

Expand Down Expand Up @@ -107,7 +107,7 @@ Go through the prompts:
https://github.com/cfengine/cfengine-cli/releases/tag/0.2.0
```

Then check that everything went well;
Then check that everything went well:

https://github.com/cfengine/cfengine-cli/actions

Expand Down
6 changes: 3 additions & 3 deletions src/cfengine_cli/cfengine_wrapper/arg_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def parse_wrapper_args(subp: argparse._SubParsersAction):
remove_parser.add_argument(
"module",
nargs="+",
help="Module(s) for which to remove",
help="Module(s) to remove",
)

add_parser = subp.add_parser(
Expand All @@ -61,7 +61,7 @@ def parse_wrapper_args(subp: argparse._SubParsersAction):
add_parser.add_argument(
"module",
nargs="+",
help="Module(s) for which to add",
help="Module(s) to add",
)
_add_index_arg(add_parser)
search_parser = subp.add_parser(
Expand All @@ -72,7 +72,7 @@ def parse_wrapper_args(subp: argparse._SubParsersAction):
search_parser.add_argument(
"module",
nargs="+",
help="Module(s) for which to lookup",
help="Module(s) to look up",
)
_add_index_arg(search_parser)

Expand Down
4 changes: 2 additions & 2 deletions src/cfengine_cli/cfengine_wrapper/cfengine_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def report(
for agent in clients:
rc = _refresh_agent(agent)
if rc != 0:
log.error(f"Refresh failed on {agent.label})")
log.error(f"Refresh failed on {agent.label}")
errors += 1

for hub in hubs:
Expand All @@ -207,7 +207,7 @@ def report(
client_ips = [client.location.split("@", 1)[1] for client in clients]
rc = _query_hub_delta(hub.hub, client_ips)
if rc != 0:
log.error(f"Hub refresh failed on {hub.label})")
log.error(f"Hub refresh failed on {hub.label}")
errors += 1

if errors > 0:
Expand Down
2 changes: 1 addition & 1 deletion src/cfengine_cli/cfengine_wrapper/cfengine_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _run_one(self, command: str) -> int:
output = run_command(self.location, full_command, sudo=True)
if (
output is None
): # TODO: Test this, I've had some policy failing but returning output instead or error-code (I think)
): # TODO: Test this, I've had some policy failing but returning output instead of error-code (I think)
# Error already logged in run_command
return 1
if output:
Expand Down
4 changes: 2 additions & 2 deletions src/cfengine_cli/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Auto-detects which repos to include based on the current working directory (core, masterfiles, enterprise).

Enterprise' changelog also reflects changes in mission-portal, nova and buildscripts (dependency-updates).
Enterprise's changelog also reflects changes in mission-portal, nova and buildscripts (dependency-updates).
Core and Masterfiles only reflect themselves.

Usage:
Expand All @@ -13,7 +13,7 @@
on 3.27.x this will check changelog for latest known (e.g. 3.27.1) and update the changelog for 3.27.1 -> 3.27.2

- cfengine dev generate-changelog -o 3.26.0..3.27.0
on any branch will print changelog from version 2.26.0 -> 3.27.0 to stdout
on any branch will print changelog from version 3.26.0 -> 3.27.0 to stdout
"""

import os
Expand Down
4 changes: 2 additions & 2 deletions src/cfengine_cli/deptool-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It supports printing to stdout in the Markdown table format, and printing to fil
It can also generate basic SBOMs in the CycloneDX JSON format (see [below](https://github.com/cfengine/buildscripts/tree/master/scripts#generating-cyclonedx-json-sboms) for usage instructions).
It can be used as a replacement for the [cf-bottom](https://github.com/cfengine/cf-bottom/) `depstable` command.

`deptool.py` works on a local buildscripts repository. By default, the repository is assumed to be current working directory (i.e. `.`).
`deptool.py` works on a local buildscripts repository. By default, the repository is assumed to be the current working directory (i.e. `.`).
A custom path for the local repository can be specified using the `--root` argument.
Running the script will modify the git state of the repository by checking out branches (and with `--patch`, also overwriting and git-adding `README.md`), so it might be preferable to [use a copy of the buildscripts repository](https://github.com/cfengine/buildscripts/tree/master/scripts#using-a-copy-of-the-repository).

Expand Down Expand Up @@ -56,7 +56,7 @@ WARNING:root:didn't find dep in line [| libgcc
| [libexpat](https://libexpat.github.io/) | - | 2.6.3 | 2.6.3 |
| [PHP](https://php.net/) | 8.3.13 | 8.3.13 | 8.3.15 |
| [PostgreSQL](https://www.postgresql.org/) | 15.8 | 16.4 | 17.2 |
| [nghttp2](https://nghttp2.opg/) | - | - | 1.64.0 |
| [nghttp2](https://nghttp2.org/) | - | - | 1.64.0 |
| [rsync](https://download.samba.org/pub/rsync/) | 3.3.0 | 3.3.0 | 3.3.0 |

```
Expand Down
8 changes: 4 additions & 4 deletions src/cfengine_cli/deptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def is_whitespace(s: str):


class GitRepo:
"""Class responsible for working with locally checked-out repository"""
"""Class responsible for working with a locally checked-out repository"""

def __init__(
self,
Expand Down Expand Up @@ -281,7 +281,7 @@ def deps_list(self, ref="master"):
else:
filtered_lines = (x for x in options_lines if "var_append DEPS" in x)
only_deps = (re.sub('.*DEPS "(.*)".*', "\\1", x) for x in filtered_lines)
# currently only_deps is generator of space-separated deps,
# currently only_deps is a generator of space-separated deps,
# i.e. each item can contain several items, like this:
# list(only_deps) = ["lcov", "pthreads-w32 libgnurx"]
# to "flatten" it we first join using spaces and then split on spaces
Expand Down Expand Up @@ -413,7 +413,7 @@ def updated_deps_markdown_table(self, refs):
# of first column (with words "CFEngine version" in it) and,
# possibly, last ("Notes", which is now second-to-last).
# Between them are ref column widths, calculated earlier.
# Also we substract 2 to remove column "padding".
# Also we subtract 2 to remove column "padding".
column_widths = (
[column_widths[1] - 2]
+ [ref_column_widths[ref] for ref in refs] # "CFEngine version"
Expand Down Expand Up @@ -574,7 +574,7 @@ def comparison_md_table(self, refs, skip_unchanged=False):
c_dep_data = collections.OrderedDict()
bolded_in_row = 0

# iterate over refs in non-overlapping pairs, and skipping the last odd ref
# iterate over refs in non-overlapping pairs, skipping the last odd ref
for ref_A, ref_B in list(zip(refs, refs[1:]))[::2]:
version_A = deps_data[dep][ref_A]
version_B = deps_data[dep][ref_B]
Expand Down
4 changes: 2 additions & 2 deletions src/cfengine_cli/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def _can_single_line_promise(node: Node, indent: int, line_length: int) -> bool:
return True
if len(attrs) > 1:
# We always want to multiline a promise with multiple attributes
# even if it would fit on one line, i.e this should be split:
# even if it would fit on one line, i.e. this should be split:
# "foo" string => "bar", comment => "baz";
return False
if next_sib and next_sib.type == "half_promise":
Expand All @@ -615,7 +615,7 @@ def _can_single_line_promise(node: Node, indent: int, line_length: int) -> bool:
children, indent, line_length
):
# A promise with a stakeholder and no attributes might be split
# if the stakeholders are too long or include comments. i.e split this:
# if the stakeholders are too long or include comments, i.e. split this:
# "foo" -> { "bar", "too long", "stakeholders", "list", "in here", "now" };
assert not attrs # Should have already returned in if above
return False
Expand Down
2 changes: 1 addition & 1 deletion src/cfengine_cli/initialize_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def init_promise_type(name=None, non_interactive=False):
name = name or _prompt_for_name(
non_interactive,
validate=False,
hint="""Try to follow typical naming conventions e.g.
hint="""Try to follow typical naming conventions, e.g.
- promise-type-groups
- promise-type-docker-compose
""",
Expand Down
10 changes: 5 additions & 5 deletions src/cfengine_cli/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@

KNOWN_FAULTY_FUNCTION_DEFS = {"regex_replace", "peers"}
# Generally, we don't want to allow creating bodies / bundles with the same
# name as a built in function, as it can make things more confusing
# name as a built-in function, as it can make things more confusing
# (harder to read / understand policy and look up definitions).
#
# There are a couple of pre-existing cases that we need to preserve for backwards
# compatibility - bodies / bundles defined in masterfiles which have the same
# name as a built in function.
# name as a built-in function.


@dataclass
Expand Down Expand Up @@ -210,7 +210,7 @@ def __deepcopy__(self, _):
class State:
"""This class is used to keep track of needed state while linting.

Not used in parsing, that is handled entirely by tree sitter library.
Not used in parsing, that is handled entirely by the tree sitter library.
Used when we are iterating over (walking) nodes in the syntax tree.

It has 3 different sets of information:
Expand Down Expand Up @@ -607,7 +607,7 @@ def _discover(policy_file: PolicyFile, state: State) -> int:
def _lint_promise_guard(
node: Node, state: State, location: str, syntax_data: SyntaxData
):
"""Check that a promise type guard (e.g. `vars:`) for deprecation or unknown type."""
"""Check a promise type guard (e.g. `vars:`) for deprecation or unknown type."""
assert _text(node) and len(_text(node)) > 1 and _text(node)[-1] == ":"
promise_type = _text(node)[0:-1]
if state.strict and promise_type in syntax_data.DEPRECATED_PROMISE_TYPES:
Expand Down Expand Up @@ -701,7 +701,7 @@ def _lint_promise(node: Node, state: State, location: str, _syntax_data: SyntaxD
)

if len(value_nodes) > 1:
# Too many of vars_types was found
# Too many of vars_types were found
# TODO: We could improve _highlight_range to highlight multiple nodes in a nice way
nodes = ", ".join([_text(x) for x in value_nodes])
raise ValidationError(
Expand Down
6 changes: 3 additions & 3 deletions src/cfengine_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _get_arg_parser():
tst.add_argument(
"files",
nargs="*",
help="Files/Folder to lint (default is . (the entire project) )",
help="Files/Folder to lint (default is . (the entire project))",
)

dev_parser = subp.add_parser(
Expand Down Expand Up @@ -168,14 +168,14 @@ def _get_arg_parser():

Auto-detects which repos to include based on the current working directory (core, masterfiles, enterprise)

Enterprise' changelog also reflects changes in mission-portal, nova and buildscripts (dependency-updates)
Enterprise's changelog also reflects changes in mission-portal, nova and buildscripts (dependency-updates)
Core and Masterfiles only reflect themselves""",
epilog="""Examples:
- cfengine dev generate-changelog
on 3.27.x this will check changelog for latest known (e.g. 3.27.1) and update the changelog for 3.27.1 -> 3.27.2

- cfengine dev generate-changelog -o 3.26.0..3.27.0
on any branch will print changelog from version 2.26.0 -> 3.27.0 to stdout""",
on any branch will print changelog from version 3.26.0 -> 3.27.0 to stdout""",
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
Expand Down
4 changes: 2 additions & 2 deletions src/cfengine_cli/masterfiles/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"""Rationale for each version:
* 3.10.0:\\
For some reason, the `"Masterfiles ready-to-install tarball"` is a .tar.gz tarball, rather than a .pkg.tar.gz tarball.
However, an unlisted analoguous URL for the .pkg.tar.gz tarball does exist.
However, an unlisted analogous URL for the .pkg.tar.gz tarball does exist.
* 3.9.2:\\
No masterfiles are listed in the release data, but an unlisted analoguous URL does exist."""
No masterfiles are listed in the release data, but an unlisted analogous URL does exist."""

HARDCODED_VERSIONS = COMMUNITY_ONLY_VERSIONS + MISSING_DATA_VERSIONS

Expand Down
4 changes: 2 additions & 2 deletions tests/format/002_basics.expected.cf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This shows some basics of policy language, without getting
# too deep into edge cases and wrappting etc.
# too deep into edge cases and wrapping etc.
body common control
{
inputs => { "/var/cfengine/inputs/some_file.cf" };
Expand Down Expand Up @@ -34,7 +34,7 @@ bundle agent main
baz::
"bam"
if => "bar",
# Comment at atttribute level
# Comment at attribute level
string => "some_value";

"empty_list" slist => {};
Expand Down
4 changes: 2 additions & 2 deletions tests/format/002_basics.input.cf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This shows some basics of policy language, without getting
# too deep into edge cases and wrappting etc.
# too deep into edge cases and wrapping etc.

body common control{
inputs => { "/var/cfengine/inputs/some_file.cf" };
Expand Down Expand Up @@ -27,7 +27,7 @@ string => "some_value";
baz::
"bam"
if => "bar",
# Comment at atttribute level
# Comment at attribute level
string => "some_value";
"empty_list"
slist => {
Expand Down
2 changes: 1 addition & 1 deletion tests/format/011_promises.expected.cf
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ bundle common cfe_internal_inputs
enterprise_edition::
"input[enterprise_knowledge]"
string => "cfe_internal/enterprise/CFE_knowledge.cf",
comment => "Settings mostly releated to CFEngine Enteprise Mission Portal";
comment => "Settings mostly related to CFEngine Enterprise Mission Portal";

"input[enterprise_main]"
string => "cfe_internal/enterprise/main.cf",
Expand Down
2 changes: 1 addition & 1 deletion tests/format/011_promises.input.cf
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ bundle common cfe_internal_inputs

"input[enterprise_knowledge]"
string => "cfe_internal/enterprise/CFE_knowledge.cf",
comment => "Settings mostly releated to CFEngine Enteprise Mission Portal";
comment => "Settings mostly related to CFEngine Enterprise Mission Portal";

"input[enterprise_main]"
string => "cfe_internal/enterprise/main.cf",
Expand Down
2 changes: 1 addition & 1 deletion tests/run-format-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/usr/bin/env bash
#!/usr/bin/env bash

set -e
# set -x
Expand Down
2 changes: 1 addition & 1 deletion tests/run-lint-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/usr/bin/env bash
#!/usr/bin/env bash

set -e
# set -x
Expand Down
2 changes: 1 addition & 1 deletion tests/run-shell-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/usr/bin/env bash
#!/usr/bin/env bash

set -e
# set -x
Expand Down
2 changes: 1 addition & 1 deletion tests/shell/003-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -x
# Verify that the line length parameter shows up in help
cfengine format -h | grep -- "--line-length"

# Test three common line length
# Test three common line lengths
for ll in 80 100 120; do
# Format the following HEREDOC and let wc count the longest line
l=$(cfengine format --line-length $ll - <<-EOF |
Expand Down
Loading