gene_system 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.doxie.json +25 -0
- data/.github/workflows/build.yml +25 -0
- data/.gitignore +20 -0
- data/.rubocop.yml +20 -0
- data/.ruby-version +1 -0
- data/CONTRIBUTING.md +51 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +150 -0
- data/LICENSE +21 -0
- data/README.md +255 -0
- data/Rakefile +19 -0
- data/bin/genesystem +52 -0
- data/data/manifest.jsonnet +87 -0
- data/gene_system.gemspec +40 -0
- data/lib/gene_system.rb +9 -0
- data/lib/gene_system/cli.rb +76 -0
- data/lib/gene_system/cli/commands.rb +109 -0
- data/lib/gene_system/generators.rb +58 -0
- data/lib/gene_system/manifest.rb +127 -0
- data/lib/gene_system/platform.rb +55 -0
- data/lib/gene_system/step.rb +74 -0
- data/lib/gene_system/version.rb +3 -0
- data/spec/gene_system/cli/commands_spec.rb +230 -0
- data/spec/gene_system/cli_spec.rb +83 -0
- data/spec/gene_system/generators_spec.rb +65 -0
- data/spec/gene_system/manifest_spec.rb +239 -0
- data/spec/gene_system/platform_spec.rb +94 -0
- data/spec/gene_system/step_spec.rb +108 -0
- data/spec/spec_helper.rb +27 -0
- metadata +344 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 69b1b6ad105f91562009bfa99f1a2cc3a3dfd0391a54a4e58b65296cc452e581
|
4
|
+
data.tar.gz: de398efc98b4de7eb7f3b8a8661790f5ca9f89cf55165abc89a7ec0b97b3986c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b3936aa6de8f87fec7fbabfa7574e7ab15a0252a7f653efb163bf78a341eb0451766b32db7e2b3616583589116f863e1e7747331f8cc3e6a5af0aa965c01e6bb
|
7
|
+
data.tar.gz: 524c443a8ee2425184e70072336e4d99f6b3716f14864c723164ecc7d422a1fcab722edb0b212741be7cf71964245699b80990e6eb8ec77311c9b5850f8f3533
|
data/.doxie.json
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"uploads": {
|
3
|
+
"yardoc": {
|
4
|
+
"source": "doc",
|
5
|
+
"target": {
|
6
|
+
"bucket": "docs-biggerconcept-com",
|
7
|
+
"key": "bitbucket.org/biggerconcept/gene_system/doc"
|
8
|
+
}
|
9
|
+
},
|
10
|
+
"coverage": {
|
11
|
+
"source": "target/reports/coverage",
|
12
|
+
"target": {
|
13
|
+
"bucket": "docs-biggerconcept-com",
|
14
|
+
"key": "bitbucket.org/biggerconcept/gene_system/coverage"
|
15
|
+
}
|
16
|
+
},
|
17
|
+
"critique": {
|
18
|
+
"source": "target/reports/critique",
|
19
|
+
"target": {
|
20
|
+
"bucket": "docs-biggerconcept-com",
|
21
|
+
"key": "bitbucket.org/biggerconcept/gene_system/critique"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby-version: ['2.6', '2.7']
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby-version }}
|
23
|
+
bundler-cache: true
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 2.4
|
4
|
+
|
5
|
+
Style/FrozenStringLiteralComment:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Metrics/MethodLength:
|
9
|
+
Max: 20
|
10
|
+
|
11
|
+
Metrics/AbcSize:
|
12
|
+
Max: 20
|
13
|
+
|
14
|
+
Lint/AssignmentInCondition:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Metrics/BlockLength:
|
18
|
+
Exclude:
|
19
|
+
- 'gene_system.gemspec'
|
20
|
+
- 'spec/**/*'
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.6
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
When contributing to Gene System, please take note of the following requests.
|
4
|
+
|
5
|
+
## Pull Request Process
|
6
|
+
|
7
|
+
1. Before raising a pull request, please first discuss the change by raising an issue.
|
8
|
+
2. Ensure any changes that change the behaviour or would be useful to implementers of this gem are documented within the README.md
|
9
|
+
3. Increase the version number in any PR raised. The versioning scheme we use is [SemVer](https://semver.org/)
|
10
|
+
|
11
|
+
## Code of Conduct
|
12
|
+
|
13
|
+
### Our Pledge
|
14
|
+
|
15
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
16
|
+
|
17
|
+
### Our Standards
|
18
|
+
|
19
|
+
Examples of behavior that contributes to creating a positive environment include:
|
20
|
+
|
21
|
+
- Using welcoming and inclusive language
|
22
|
+
- Being respectful of differing viewpoints and experiences
|
23
|
+
- Gracefully accepting constructive criticism
|
24
|
+
- Focusing on what is best for the community
|
25
|
+
- Showing empathy towards other community members
|
26
|
+
|
27
|
+
Examples of unacceptable behavior by participants include:
|
28
|
+
|
29
|
+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
|
30
|
+
- Trolling, insulting/derogatory comments, and personal or political attacks
|
31
|
+
- Public or private harassment
|
32
|
+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
|
33
|
+
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
34
|
+
|
35
|
+
### Our Responsibilities
|
36
|
+
|
37
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
38
|
+
|
39
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
40
|
+
|
41
|
+
### Scope
|
42
|
+
|
43
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
44
|
+
|
45
|
+
### Enforcement
|
46
|
+
|
47
|
+
Instances of abusive, harassing or otherwise unacceptable behaviour may be reported by contacting the project team. The project team will decide how to respond to any compliants.
|
48
|
+
|
49
|
+
### Attribution
|
50
|
+
|
51
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org/version/1/4), version 1.4, available at http://contributor-covenant.org/version/1/4
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
git_source(:biggerconcept) do |repo_name|
|
4
|
+
username = ENV['BIGGERCONCEPT_CI_USER']
|
5
|
+
password = ENV['BIGGERCONCEPT_CI_PASSWORD']
|
6
|
+
git_host = ENV['BIGGERCONCEPT_GIT_HOSTpro']
|
7
|
+
"https://#{username}:#{password}@#{git_host}/#{repo_name}"
|
8
|
+
end
|
9
|
+
|
10
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gene_system (0.3.2)
|
5
|
+
hashie
|
6
|
+
highline (~> 2.0)
|
7
|
+
jsonnet
|
8
|
+
logger (~> 1.4)
|
9
|
+
os
|
10
|
+
ruby-handlebars (~> 0.4)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
addressable (2.7.0)
|
16
|
+
public_suffix (>= 2.0.2, < 5.0)
|
17
|
+
ast (2.4.2)
|
18
|
+
axiom-types (0.1.1)
|
19
|
+
descendants_tracker (~> 0.0.4)
|
20
|
+
ice_nine (~> 0.11.0)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
22
|
+
bump (0.10.0)
|
23
|
+
byebug (11.1.3)
|
24
|
+
codeclimate-engine-rb (0.4.1)
|
25
|
+
virtus (~> 1.0)
|
26
|
+
coderay (1.1.3)
|
27
|
+
coercible (1.0.0)
|
28
|
+
descendants_tracker (~> 0.0.1)
|
29
|
+
descendants_tracker (0.0.4)
|
30
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
31
|
+
diff-lcs (1.4.4)
|
32
|
+
docile (1.3.5)
|
33
|
+
doxie (4.0.0)
|
34
|
+
equalizer (0.0.11)
|
35
|
+
erubis (2.7.0)
|
36
|
+
flay (2.12.1)
|
37
|
+
erubis (~> 2.7.0)
|
38
|
+
path_expander (~> 1.0)
|
39
|
+
ruby_parser (~> 3.0)
|
40
|
+
sexp_processor (~> 4.0)
|
41
|
+
flog (4.6.4)
|
42
|
+
path_expander (~> 1.0)
|
43
|
+
ruby_parser (~> 3.1, > 3.1.0)
|
44
|
+
sexp_processor (~> 4.8)
|
45
|
+
hashie (4.1.0)
|
46
|
+
highline (2.0.3)
|
47
|
+
ice_nine (0.11.2)
|
48
|
+
jaro_winkler (1.5.4)
|
49
|
+
jsonnet (0.4.0)
|
50
|
+
mini_portile2 (>= 2.2.0)
|
51
|
+
launchy (2.4.3)
|
52
|
+
addressable (~> 2.3)
|
53
|
+
logger (1.4.3)
|
54
|
+
method_source (1.0.0)
|
55
|
+
mini_portile2 (2.6.1)
|
56
|
+
nio4r (2.5.7)
|
57
|
+
os (1.1.1)
|
58
|
+
parallel (1.20.1)
|
59
|
+
parser (2.5.3.0)
|
60
|
+
ast (~> 2.4.0)
|
61
|
+
parslet (1.8.2)
|
62
|
+
path_expander (1.1.0)
|
63
|
+
private_gem (1.1.4)
|
64
|
+
bundler (> 1.7, < 3.0)
|
65
|
+
thor
|
66
|
+
pry (0.14.1)
|
67
|
+
coderay (~> 1.1)
|
68
|
+
method_source (~> 1.0)
|
69
|
+
public_suffix (4.0.6)
|
70
|
+
puma (4.3.7)
|
71
|
+
nio4r (~> 2.0)
|
72
|
+
rainbow (3.0.0)
|
73
|
+
rake (13.0.3)
|
74
|
+
reek (4.8.2)
|
75
|
+
codeclimate-engine-rb (~> 0.4.0)
|
76
|
+
parser (>= 2.5.0.0, < 2.6)
|
77
|
+
rainbow (>= 2.0, < 4.0)
|
78
|
+
rspec (3.10.0)
|
79
|
+
rspec-core (~> 3.10.0)
|
80
|
+
rspec-expectations (~> 3.10.0)
|
81
|
+
rspec-mocks (~> 3.10.0)
|
82
|
+
rspec-core (3.10.1)
|
83
|
+
rspec-support (~> 3.10.0)
|
84
|
+
rspec-expectations (3.10.1)
|
85
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
86
|
+
rspec-support (~> 3.10.0)
|
87
|
+
rspec-mocks (3.10.2)
|
88
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
89
|
+
rspec-support (~> 3.10.0)
|
90
|
+
rspec-support (3.10.2)
|
91
|
+
rubocop (0.68.1)
|
92
|
+
jaro_winkler (~> 1.5.1)
|
93
|
+
parallel (~> 1.10)
|
94
|
+
parser (>= 2.5, != 2.5.1.1)
|
95
|
+
rainbow (>= 2.2.2, < 4.0)
|
96
|
+
ruby-progressbar (~> 1.7)
|
97
|
+
unicode-display_width (>= 1.4.0, < 1.6)
|
98
|
+
ruby-handlebars (0.4.0)
|
99
|
+
parslet (~> 1.6, >= 1.6.2)
|
100
|
+
ruby-progressbar (1.11.0)
|
101
|
+
ruby_parser (3.15.1)
|
102
|
+
sexp_processor (~> 4.9)
|
103
|
+
rubycritic (3.5.2)
|
104
|
+
flay (~> 2.8)
|
105
|
+
flog (~> 4.4)
|
106
|
+
launchy (= 2.4.3)
|
107
|
+
parser (~> 2.5.0)
|
108
|
+
rainbow (~> 3.0)
|
109
|
+
reek (~> 4.4)
|
110
|
+
ruby_parser (~> 3.8)
|
111
|
+
tty-which (~> 0.3.0)
|
112
|
+
virtus (~> 1.0)
|
113
|
+
sexp_processor (4.15.2)
|
114
|
+
simplecov (0.21.2)
|
115
|
+
docile (~> 1.1)
|
116
|
+
simplecov-html (~> 0.11)
|
117
|
+
simplecov_json_formatter (~> 0.1)
|
118
|
+
simplecov-html (0.12.3)
|
119
|
+
simplecov_json_formatter (0.1.3)
|
120
|
+
thor (1.1.0)
|
121
|
+
thread_safe (0.3.6)
|
122
|
+
tty-which (0.3.0)
|
123
|
+
unicode-display_width (1.5.0)
|
124
|
+
virtus (1.0.5)
|
125
|
+
axiom-types (~> 0.1)
|
126
|
+
coercible (~> 1.0)
|
127
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
128
|
+
equalizer (~> 0.0, >= 0.0.9)
|
129
|
+
yard (0.9.26)
|
130
|
+
|
131
|
+
PLATFORMS
|
132
|
+
ruby
|
133
|
+
|
134
|
+
DEPENDENCIES
|
135
|
+
bump (~> 0.6)
|
136
|
+
byebug (~> 11.0)
|
137
|
+
doxie
|
138
|
+
gene_system!
|
139
|
+
private_gem (~> 1.1)
|
140
|
+
pry (~> 0.11)
|
141
|
+
puma (~> 4.3)
|
142
|
+
rake (~> 13.0)
|
143
|
+
rspec (~> 3.7, >= 3.7.0)
|
144
|
+
rubocop (~> 0.58)
|
145
|
+
rubycritic (~> 3.4, >= 3.4.0)
|
146
|
+
simplecov (~> 0.16)
|
147
|
+
yard (~> 0.9)
|
148
|
+
|
149
|
+
BUNDLED WITH
|
150
|
+
2.2.16
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Andrew Bigger
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
# GeneSystem
|
2
|
+
|
3
|
+
A gem for configuring systems via json or jsonnet manifest.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem into your system:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem install gene_system
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
### Creating a Configuration Manifest
|
16
|
+
|
17
|
+
Once installed, you can create a configuration manifest by calling the `new` command:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
genesystem new manifest
|
21
|
+
```
|
22
|
+
|
23
|
+
This creates a file called `manifest.json` in which you can write configuration steps.
|
24
|
+
|
25
|
+
### Writing a Configuration Manifest
|
26
|
+
|
27
|
+
A configuration manifest looks like this:
|
28
|
+
|
29
|
+
```json
|
30
|
+
{
|
31
|
+
"name": "manifest",
|
32
|
+
"version": "0.0.1",
|
33
|
+
"metadata": {
|
34
|
+
"gene_system": {
|
35
|
+
"version": "0.3.1"
|
36
|
+
}
|
37
|
+
},
|
38
|
+
"steps": [
|
39
|
+
{
|
40
|
+
"name": "say hello",
|
41
|
+
"exe": {
|
42
|
+
"install": {
|
43
|
+
"cmd": [
|
44
|
+
"echo \"hello\""
|
45
|
+
]
|
46
|
+
},
|
47
|
+
"remove": {
|
48
|
+
"cmd": [
|
49
|
+
"echo goodbye"
|
50
|
+
]
|
51
|
+
}
|
52
|
+
},
|
53
|
+
"tags": "example step"
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
Below is a description of the root level manifest attributes, each of which is required:
|
60
|
+
|
61
|
+
- `name` is the name of the configuration manifest
|
62
|
+
- `version` refers to the version of the configuration. You might want to increment this number as you make changes to the manifest.
|
63
|
+
- `metadata` contains data about the manifest, notably the `gene_system > version` attribute which governs the minimum version of the Gene System gem required to execute the manifest
|
64
|
+
- `steps` an array of step objects that configure a host machine.
|
65
|
+
|
66
|
+
#### Step Objects
|
67
|
+
|
68
|
+
Each step is executed in order and should be in the following format:
|
69
|
+
|
70
|
+
```json
|
71
|
+
{
|
72
|
+
"name": "say hello",
|
73
|
+
"exe": {
|
74
|
+
"install": {
|
75
|
+
"cmd": [
|
76
|
+
"echo \"hello\""
|
77
|
+
]
|
78
|
+
},
|
79
|
+
"remove": {
|
80
|
+
"cmd": [
|
81
|
+
"echo goodbye"
|
82
|
+
]
|
83
|
+
}
|
84
|
+
},
|
85
|
+
"tags": "example step"
|
86
|
+
}
|
87
|
+
```
|
88
|
+
|
89
|
+
Steps have a `name`, `exe` and `tag` attribute.
|
90
|
+
|
91
|
+
- `name` refers to the step name, this will be printed in STDOUT when the step is being executed.
|
92
|
+
- `exe` is an object that runs during the application or removal of a manifest. It can take an `install` or `remove` object (described below)
|
93
|
+
- `tags` a space separated string of tags.
|
94
|
+
|
95
|
+
#### Install and Remove Objects
|
96
|
+
|
97
|
+
The install and remove objects are basically the same, only differing in the sense that the `install` exe instructions are run when the `genesystem install` command is run, and the `remove` exe instructions when the `genesystem remove` command is run.
|
98
|
+
|
99
|
+
The install and remove objects require a `cmd` array like the one in the example above. These should be shell commands to be run.
|
100
|
+
|
101
|
+
Optionally, both the install and remove objects can accept the following:
|
102
|
+
|
103
|
+
- `skip` command that prevents execution of `cmd` instructions
|
104
|
+
- `prompts` array of prompt that asks the user for input
|
105
|
+
|
106
|
+
##### Skip
|
107
|
+
|
108
|
+
Skip instructions can speed up the execution of a configuration manifest, by running a shell command to determine whether the step is required.
|
109
|
+
|
110
|
+
Skip works by executing a shell command and evaluating whether it returned a zero status (in other words is truthy).
|
111
|
+
|
112
|
+
For example you might wish to skip a command in the event that a file or folder exists. You would do this by adding a step like this:
|
113
|
+
|
114
|
+
```json
|
115
|
+
{
|
116
|
+
"name": "say hello",
|
117
|
+
"exe": {
|
118
|
+
"install": {
|
119
|
+
"skip": "[ -f greeted.txt ]",
|
120
|
+
"cmd": [
|
121
|
+
"echo \"hello\""
|
122
|
+
]
|
123
|
+
}
|
124
|
+
},
|
125
|
+
"tags": "example step"
|
126
|
+
}
|
127
|
+
```
|
128
|
+
|
129
|
+
The `echo "hello"` command would only execute if the `greeted.txt` file does not exist.
|
130
|
+
|
131
|
+
##### Prompts
|
132
|
+
|
133
|
+
Prompts is an array of objects that describes a prompt for user input. A prompt looks like this:
|
134
|
+
|
135
|
+
```json
|
136
|
+
{
|
137
|
+
"prompt": "Please enter your name",
|
138
|
+
"var": "name"
|
139
|
+
}
|
140
|
+
```
|
141
|
+
|
142
|
+
Before the `exe` commands are run, the user will be asked for input, and that input will be saved to a variable named the value of `var`.
|
143
|
+
|
144
|
+
In the above example, the user input would be saved to the `name` variable.
|
145
|
+
|
146
|
+
The variable is rendered into the `cmd` command using handlebars syntax. Using the example above a prompt can be used thus:
|
147
|
+
|
148
|
+
```json
|
149
|
+
{
|
150
|
+
"name": "say hello",
|
151
|
+
"exe": {
|
152
|
+
"install": {
|
153
|
+
"prompts": [
|
154
|
+
{
|
155
|
+
"prompt": "Please enter your name",
|
156
|
+
"var": "name"
|
157
|
+
}
|
158
|
+
],
|
159
|
+
"cmd": [
|
160
|
+
"echo \"hello {{ name }}\""
|
161
|
+
]
|
162
|
+
}
|
163
|
+
},
|
164
|
+
"tags": "example step"
|
165
|
+
}
|
166
|
+
```
|
167
|
+
|
168
|
+
### Installing a Configuration Manifest
|
169
|
+
|
170
|
+
Once a manifest file is created, Gene System can apply the changes described in the manifest using the `install` command with the relative path to the manifest json as an argument.
|
171
|
+
|
172
|
+
```bash
|
173
|
+
genesystem install /path/to/manifest.json
|
174
|
+
```
|
175
|
+
|
176
|
+
This will select all of the `install` commands from the steps and execute them.
|
177
|
+
|
178
|
+
### Removing a Configuration Manifest
|
179
|
+
|
180
|
+
The Gene System manifest defines `remove` steps which are intended to be reverse commands for removing the configuration applied by the `install` commands. A good manifest should provide these to return a machine to a default state if required.
|
181
|
+
|
182
|
+
The `remove` steps can be run by calling the `remove` command with the relative path to the manifest json as an argument:
|
183
|
+
|
184
|
+
```bash
|
185
|
+
genesystem remove /path/to/manifest.json
|
186
|
+
```
|
187
|
+
|
188
|
+
### Jsonnet Support
|
189
|
+
|
190
|
+
[Jsonnet](https://jsonnet.org/) is a data templating language for specifying configuration files, and it is a supported format for Gene System manifests.
|
191
|
+
|
192
|
+
This might be useful where step loops are useful.
|
193
|
+
|
194
|
+
```jsoonnet
|
195
|
+
local conf = {
|
196
|
+
varibles: {
|
197
|
+
pkg: {
|
198
|
+
apts: [
|
199
|
+
{
|
200
|
+
"name": "docker.io"
|
201
|
+
},
|
202
|
+
{
|
203
|
+
"name": "postgresql-client"
|
204
|
+
}
|
205
|
+
]
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
{
|
211
|
+
"name": "manifest",
|
212
|
+
"version": "0.0.1",
|
213
|
+
"metadata": {
|
214
|
+
"gene_system": {
|
215
|
+
"version": "0.3.1"
|
216
|
+
}
|
217
|
+
},
|
218
|
+
"steps": [] + [
|
219
|
+
// install apt packages
|
220
|
+
{
|
221
|
+
"name": "install " + apt.name,
|
222
|
+
"exe": {
|
223
|
+
"install": {
|
224
|
+
"cmd": [
|
225
|
+
"echo password | sudo -S apt-get install " + apt.name
|
226
|
+
]
|
227
|
+
},
|
228
|
+
},
|
229
|
+
"tags": "install " + apt.name
|
230
|
+
} for apt in conf.variables.pkg.apts
|
231
|
+
]
|
232
|
+
}
|
233
|
+
```
|
234
|
+
|
235
|
+
## Tests and Quality
|
236
|
+
|
237
|
+
Tests cover this project and are written in RSpec. You'll find them in the spec folder.
|
238
|
+
|
239
|
+
```bash
|
240
|
+
bundle exec rspec spec
|
241
|
+
```
|
242
|
+
|
243
|
+
Tests and quality tasks are included in the default rake task which can be run thus:
|
244
|
+
|
245
|
+
```bash
|
246
|
+
bundle exec rake
|
247
|
+
```
|
248
|
+
|
249
|
+
## Contributing
|
250
|
+
|
251
|
+
See CONTRIBUTING.md for more information
|
252
|
+
|
253
|
+
## Licence
|
254
|
+
|
255
|
+
This gem is covered by the terms of the MIT licence. See LICENCE for more information
|