-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support adding modules from git repositories #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a company e-mail instead of v***@mykolab.com
75e3de2
to
4986bd8
Compare
Aside from using the defaul/global index, it's handy to have an ability to add modules from just a git repository. With a 'cfbs.json' file with the repository-specific index it can be used as a source of modules. Ticket: CFE-3771 Changelog: 'cfbs add' now supports adding modules from git repositories with index
4986bd8
to
b41d009
Compare
b41d009
to
32204ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple case worked for me.
❯ cd cfengine/src/cfbs
❯ ls
cfbs test LICENSE README.md requirements.txt setup.py
❯ PYTHONPATH=. cfbs add https://github.com/nickanderson/cfengine-sysctl
Error: This is not a cfbs repo, to get started, type: cfbs init
❯ PYTHONPATH=
❯ cfbs init
Initialized - edit name and description cfbs.json
To add your first module, type: cfbs add masterfiles
❯ PYTHONPATH=. cfbs add https://github.com/nickanderson/cfengine-sysctl
Do you want to add all 3 modules from the repository? [y/N] y
Added module: inventory-kernel-settings-sysctl-current
Added module: inventory-kernel-settings-sysctl-conf
Added module: kernel-settings-sysctl-conf
❯ cat cfbs.json
{
"name": "Example",
"description": "Example description",
"build": [
{
"name": "inventory-kernel-settings-sysctl-current",
"description": "Inventory sysctl settings current state.",
"tags": ["inventory", "sysctl"],
"by": "https://github.com/nickanderson",
"version": "1.0.0",
"commit": "60fe0eee9b5b44ff078b12989d5057b2660c1eda",
"subdirectory": "policy/inventory-kernel-settings-sysctl-current",
"steps": [
"copy ./main.cf services/inventory-kernel-settings-sysctl-current/",
"copy ./README.org services/inventory-kernel-settings-sysctl-current/",
"json ./cfbs/def.json def.json"
],
"index": "https://github.com/nickanderson/cfengine-sysctl",
"repo": "https://github.com/nickanderson/cfengine-sysctl",
"added_by": "cfbs add"
},
{
"name": "inventory-kernel-settings-sysctl-conf",
"description": "Inventory settings from /etc/sysctl.conf.",
"tags": ["inventory", "sysctl"],
"by": "https://github.com/nickanderson",
"version": "1.0.0",
"commit": "60fe0eee9b5b44ff078b12989d5057b2660c1eda",
"subdirectory": "policy/inventory-kernel-settings-sysctl-conf",
"steps": [
"copy ./main.cf services/inventory-kernel-settings-sysctl-conf/",
"copy ./README.org services/inventory-kernel-settings-sysctl-conf/",
"json ./cfbs/def.json def.json"
],
"index": "https://github.com/nickanderson/cfengine-sysctl",
"repo": "https://github.com/nickanderson/cfengine-sysctl",
"added_by": "cfbs add"
},
{
"name": "kernel-settings-sysctl-conf",
"description": "Manage settings in /etc/sysctl.conf.",
"tags": ["sysctl"],
"by": "https://github.com/nickanderson",
"version": "1.0.0",
"commit": "60fe0eee9b5b44ff078b12989d5057b2660c1eda",
"subdirectory": "policy/kernel-settings-sysctl-conf",
"steps": [
"copy ./main.cf services/kernel-settings-sysctl-conf/",
"copy ./README.org services/kernel-settings-sysctl-conf/",
"json ./cfbs/def.json def.json"
],
"index": "https://github.com/nickanderson/cfengine-sysctl",
"repo": "https://github.com/nickanderson/cfengine-sysctl",
"added_by": "cfbs add"
}
]
}%
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I have some smaller nitpicks but feel free to merge it as is, and address things in follow-ups etc.
index_path = os.path.join(commit_path, "cfbs.json") | ||
if os.path.exists(index_path): | ||
return (index_path, commit) | ||
else: | ||
user_error("Repository '%s' doesn't contain a valid cfbs.json index file" % repo_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you are calling it an index file. That's not what I intended, up until now we've had 2 types of JSON files cfbs.json
(config file for 1 project), index.json
(index of all available modules).
BUT, what you did is smart and I think we should probably change this, standardize the format so there is only 1 format, cfbs.json
and it can have an index inline or external path to index.
No need to do anything here, but let's discuss this some more :)
Aside from using the defaul/global index, it's handy to have an
ability to add modules from just a git repository. With a
'cfbs.json' file with the repository-specific index it can be
used as a source of modules.
Ticket: CFE-3771
Changelog: 'cfbs add' now supports adding modules from git repositories with index
TODO:
ssh://git@example.com/some/git/repo/here
cfbs add https://some/repo@some_commit_sha
index
info tocfbs info