Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/add_validate_build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rm -rf ./tmp/
mkdir -p ./tmp/

# This script is written to also work in for example cfengine/cfbs
# where we'd need to downooad cfbs.json.
# where we'd need to download cfbs.json.
if [ ! -f ./cfbs.json ] ; then
echo "No cfbs.json found in current working directory, downloading from GitHub"
curl -L https://raw.githubusercontent.com/cfengine/build-index/refs/heads/master/cfbs.json -o ./tmp/cfbs.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install cfbs with pip
run: pip3 install cfbs
Expand Down
6 changes: 3 additions & 3 deletions JSON.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,20 +368,20 @@ Which results in:
You can start a project with an alternate index:

```
cfbs init --index blah
cfbs init --index ./some-index.json
```

```json
{
"name": "Example",
"description": "Example description",
"type": "policy-set",
"index": "blah",
"index": "./some-index.json",
"build": []
}
```

`blah` can be a URL or a relative file path (inside project).
The `--index` argument can either be a relative path to a JSON, as seen above, or a HTTPS URL.

## Index file

Expand Down
6 changes: 5 additions & 1 deletion cfbs/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ def get_arg_parser():
help="Don't prompt, use defaults (only for testing)",
action="store_true",
)
parser.add_argument("--index", help="Specify alternate index", type=str)
parser.add_argument(
"--index",
help="Specify alternate index (HTTPS URL or relative path to JSON file)",
type=str,
)
parser.add_argument(
"--check", help="Check if file(s) would be reformatted", action="store_true"
)
Expand Down
8 changes: 8 additions & 0 deletions cfbs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Union

from cfbs.result import Result
from cfbs.validate import validate_index_string
from cfbs.version import string as version
from cfbs.utils import (
CFBSValidationError,
Expand Down Expand Up @@ -75,6 +76,13 @@ def _main() -> Union[int, Result]:
print_help()
raise CFBSUserError("Command '%s' not found" % args.command)

if args.index is not None:
if args.command not in ["init", "add", "search", "validate"]:
raise CFBSUserError(
"'--index' option can not be used with the '%s' command" % args.command
)
validate_index_string(args.index)

if args.masterfiles and args.command != "init":
raise CFBSUserError(
"The option --masterfiles is only for 'cfbs init', not 'cfbs %s'"
Expand Down
1 change: 1 addition & 0 deletions cfbs/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"repo",
"url",
"by",
"index",
"version",
"commit",
"subdirectory",
Expand Down
Loading