mtncloud-cli 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,187 +1,187 @@
1
- # MTN Cloud CLI
2
-
3
- The MTN Cloud CLI is a command line interface for managing MTN Cloud. You can use it to provision and manage instances, hosts and clusters, deploy applications, run tasks and workflows, and automate most of what you can do in the MTN Cloud UI.
4
-
5
- It installs two commands that run the same CLI:
6
-
7
- - `mtncloud`
8
- - `mcs`, a short alias for `mtncloud`
9
-
10
- ## Installation
11
-
12
- Requirements:
13
-
14
- - Ruby. The CLI is tested on Ruby 3.3. On Windows, install Ruby+Devkit from [rubyinstaller.org](https://rubyinstaller.org/downloads/) and select the option to add Ruby to your PATH.
15
-
16
- Install the CLI from RubyGems:
17
-
18
- ```shell
19
- gem install mtncloud-cli --no-document
20
- ```
21
-
22
- Check the installation:
23
-
24
- ```shell
25
- mtncloud version
26
- mcs version
27
- ```
28
-
29
- On Windows, a first install from a clean environment took about 17 minutes in our testing, mostly spent compiling native extensions for dependencies such as `ffi`, `llhttp-ffi` and `bigdecimal`. Your install time may differ.
30
-
31
- ### Updating
32
-
33
- ```shell
34
- gem update mtncloud-cli
35
- ```
36
-
37
- ### Installing from source
38
-
39
- To install an unreleased version, build the gem from a clone of this repository. The build needs Git, which it uses to list the files to package.
40
-
41
- ```shell
42
- git clone https://github.com/Jose-henry/mtncloud-cli
43
- cd mtncloud-cli
44
- gem build mtncloud-cli.gemspec -o mtncloud-cli.gem
45
- gem install ./mtncloud-cli.gem
46
- ```
47
-
48
- ### Docker
49
-
50
- The Dockerfile builds the CLI from this repository. Build it from the root of a git clone, because the gem build needs the `.git` directory.
51
-
52
- ```shell
53
- docker build -t mtncloud-cli .
54
- docker run --rm -it -v ~/.mtncloud:/root/.mtncloud mtncloud-cli remote list
55
- ```
56
-
57
- The volume keeps your remotes and credentials between runs.
58
-
59
- ## Usage
60
-
61
- Add your MTN Cloud remote, then log in:
62
-
63
- ```shell
64
- mtncloud remote add mtncloud https://console.cloud.mtn.ng
65
- mtncloud login
66
- ```
67
-
68
- Then run commands, for example:
69
-
70
- ```shell
71
- mtncloud instances list
72
- mcs instances list
73
- ```
74
-
75
- Help is available for every command and subcommand with `-h`:
76
-
77
- ```shell
78
- mtncloud --help
79
- mcs instances list --help
80
- ```
81
-
82
- `mtncloud shell` starts an interactive shell. `mtncloud man` opens the full manual, which includes the help for every command.
83
-
84
- ## Configuration
85
-
86
- The CLI keeps its configuration in `~/.mtncloud`. Set `MTNCLOUD_CLI_HOME` to use a different directory, for example to keep separate configurations:
87
-
88
- ```shell
89
- MTNCLOUD_CLI_HOME=~/.mtncloud_test mtncloud remote list
90
- ```
91
-
92
- Files in the home directory include:
93
-
94
- | File | Contents |
95
- |---|---|
96
- | `appliances` | Your remotes, keyed by name |
97
- | `credentials` | Access tokens for each remote |
98
- | `groups` | The active group for each remote |
99
- | `.mtncloud_profile` | Commands run every time the CLI starts |
100
- | `.mtncloudrc` | Commands run when `mtncloud shell` starts |
101
- | `shell_history` | History for `mtncloud shell` |
102
-
103
- The `appliances` and `credentials` files are saved with file permissions `0600`. Only one system user should use a home directory.
104
-
105
- Other environment variables:
106
-
107
- | Variable | Purpose |
108
- |---|---|
109
- | `MTNCLOUD_PS1` | The prompt for `mtncloud shell`. See `mtncloud set-prompt --help`. |
110
- | `MTNCLOUD_CLI_TMPDIR` | Where temporary shells (`mtncloud shell -Z`) are created. The default is the `tmp` directory inside the home directory. |
111
-
112
- ## Development
113
-
114
- Install the dependencies with Bundler 2.2 or newer:
115
-
116
- ```shell
117
- bundle install
118
- ```
119
-
120
- Run the CLI from your working copy:
121
-
122
- ```shell
123
- bundle exec ruby bin/mtncloud --help
124
- bundle exec ruby bin/mcs --help
125
- ```
126
-
127
- To reload your code changes without restarting, start a shell and use `reload`:
128
-
129
- ```shell
130
- bundle exec ruby bin/mtncloud shell --debug
131
- ```
132
-
133
- Code layout:
134
-
135
- - API interfaces are in `lib/mtncloud/api/`.
136
- - CLI commands are in `lib/mtncloud/cli/commands/`.
137
-
138
- ### Testing
139
-
140
- Offline tests don't need an appliance. CI runs them on every pull request:
141
-
142
- ```shell
143
- bundle exec rake test:offline
144
- ```
145
-
146
- They include:
147
-
148
- - `test/branding_test.rb`, which checks every command's help for leftover non-MTN Cloud branding
149
- - the test files under `test/cli/` and `test/api/` that do not `require 'mtncloud_test'`
150
-
151
- The other tests run against a live appliance. Create a `test_config.yaml` in the repository root:
152
-
153
- ```yaml
154
- url: 'https://console.cloud.mtn.ng'
155
- username: (accountID/Subdomain)\testrunner
156
- password: 'SecretPassword123$'
157
- ```
158
-
159
- Then run all the tests:
160
-
161
- ```shell
162
- bundle exec rake test
163
- ```
164
-
165
- ## Contributing
166
-
167
- Changes reach `main` only through pull requests that pass CI. See [CONTRIBUTING.md](CONTRIBUTING.md).
168
-
169
- ## Releasing
170
-
171
- New versions are published to RubyGems by the [Publish gem](.github/workflows/release.yml) workflow when a version tag is pushed:
172
-
173
- 1. Update `VERSION` in `lib/mtncloud/cli/version.rb` in a pull request, and merge it once CI passes.
174
- 2. Tag the merged commit on `main` and push the tag:
175
-
176
- ```shell
177
- git tag v1.0.1
178
- git push origin v1.0.1
179
- ```
180
-
181
- The workflow fails if the tag does not match `VERSION`. RubyGems does not accept the same version twice.
182
-
183
- The workflow uses RubyGems trusted publishing, so no API key is stored in this repository. On RubyGems.org, the trusted publisher for `mtncloud-cli` names this repository, the `release.yml` workflow and the `release` environment. If the repository moves, update the repository owner and name in that trusted publisher.
184
-
185
- ## License
186
-
187
- MIT. See [LICENSE.txt](LICENSE.txt).
1
+ # MTN Cloud CLI
2
+
3
+ The MTN Cloud CLI is a command line interface for managing MTN Cloud. You can use it to provision and manage instances, hosts and clusters, deploy applications, run tasks and workflows, and automate most of what you can do in the MTN Cloud UI.
4
+
5
+ It installs two commands that run the same CLI:
6
+
7
+ - `mtncloud`
8
+ - `mcs`, a short alias for `mtncloud`
9
+
10
+ ## Installation
11
+
12
+ Requirements:
13
+
14
+ - Ruby. The CLI is tested on Ruby 3.3. On Windows, install Ruby+Devkit from [rubyinstaller.org](https://rubyinstaller.org/downloads/) and select the option to add Ruby to your PATH.
15
+
16
+ Install the CLI from RubyGems:
17
+
18
+ ```shell
19
+ gem install mtncloud-cli --no-document
20
+ ```
21
+
22
+ Check the installation:
23
+
24
+ ```shell
25
+ mtncloud version
26
+ mcs version
27
+ ```
28
+
29
+ On Windows, a first install from a clean environment took about 17 minutes in our testing, mostly spent compiling native extensions for dependencies such as `ffi`, `llhttp-ffi` and `bigdecimal`. Your install time may differ.
30
+
31
+ ### Updating
32
+
33
+ ```shell
34
+ gem update mtncloud-cli
35
+ ```
36
+
37
+ ### Installing from source
38
+
39
+ To install an unreleased version, build the gem from a clone of this repository. The build needs Git, which it uses to list the files to package.
40
+
41
+ ```shell
42
+ git clone https://github.com/Jose-henry/mtncloud-cli
43
+ cd mtncloud-cli
44
+ gem build mtncloud-cli.gemspec -o mtncloud-cli.gem
45
+ gem install ./mtncloud-cli.gem
46
+ ```
47
+
48
+ ### Docker
49
+
50
+ The Dockerfile builds the CLI from this repository. Build it from the root of a git clone, because the gem build needs the `.git` directory.
51
+
52
+ ```shell
53
+ docker build -t mtncloud-cli .
54
+ docker run --rm -it -v ~/.mtncloud:/root/.mtncloud mtncloud-cli remote list
55
+ ```
56
+
57
+ The volume keeps your remotes and credentials between runs.
58
+
59
+ ## Usage
60
+
61
+ Add your MTN Cloud remote, then log in:
62
+
63
+ ```shell
64
+ mtncloud remote add mtncloud https://console.cloud.mtn.ng
65
+ mtncloud login
66
+ ```
67
+
68
+ Then run commands, for example:
69
+
70
+ ```shell
71
+ mtncloud instances list
72
+ mcs instances list
73
+ ```
74
+
75
+ Help is available for every command and subcommand with `-h`:
76
+
77
+ ```shell
78
+ mtncloud --help
79
+ mcs instances list --help
80
+ ```
81
+
82
+ `mtncloud shell` starts an interactive shell. `mtncloud man` opens the full manual, which includes the help for every command.
83
+
84
+ ## Configuration
85
+
86
+ The CLI keeps its configuration in `~/.mtncloud`. Set `MTNCLOUD_CLI_HOME` to use a different directory, for example to keep separate configurations:
87
+
88
+ ```shell
89
+ MTNCLOUD_CLI_HOME=~/.mtncloud_test mtncloud remote list
90
+ ```
91
+
92
+ Files in the home directory include:
93
+
94
+ | File | Contents |
95
+ |---|---|
96
+ | `appliances` | Your remotes, keyed by name |
97
+ | `credentials` | Access tokens for each remote |
98
+ | `groups` | The active group for each remote |
99
+ | `.mtncloud_profile` | Commands run every time the CLI starts |
100
+ | `.mtncloudrc` | Commands run when `mtncloud shell` starts |
101
+ | `shell_history` | History for `mtncloud shell` |
102
+
103
+ The `appliances` and `credentials` files are saved with file permissions `0600`. Only one system user should use a home directory.
104
+
105
+ Other environment variables:
106
+
107
+ | Variable | Purpose |
108
+ |---|---|
109
+ | `MTNCLOUD_PS1` | The prompt for `mtncloud shell`. See `mtncloud set-prompt --help`. |
110
+ | `MTNCLOUD_CLI_TMPDIR` | Where temporary shells (`mtncloud shell -Z`) are created. The default is the `tmp` directory inside the home directory. |
111
+
112
+ ## Development
113
+
114
+ Install the dependencies with Bundler 2.2 or newer:
115
+
116
+ ```shell
117
+ bundle install
118
+ ```
119
+
120
+ Run the CLI from your working copy:
121
+
122
+ ```shell
123
+ bundle exec ruby bin/mtncloud --help
124
+ bundle exec ruby bin/mcs --help
125
+ ```
126
+
127
+ To reload your code changes without restarting, start a shell and use `reload`:
128
+
129
+ ```shell
130
+ bundle exec ruby bin/mtncloud shell --debug
131
+ ```
132
+
133
+ Code layout:
134
+
135
+ - API interfaces are in `lib/mtncloud/api/`.
136
+ - CLI commands are in `lib/mtncloud/cli/commands/`.
137
+
138
+ ### Testing
139
+
140
+ Offline tests don't need an appliance. CI runs them on every pull request:
141
+
142
+ ```shell
143
+ bundle exec rake test:offline
144
+ ```
145
+
146
+ They include:
147
+
148
+ - `test/branding_test.rb`, which checks every command's help for leftover non-MTN Cloud branding
149
+ - the test files under `test/cli/` and `test/api/` that do not `require 'mtncloud_test'`
150
+
151
+ The other tests run against a live appliance. Create a `test_config.yaml` in the repository root:
152
+
153
+ ```yaml
154
+ url: 'https://console.cloud.mtn.ng'
155
+ username: (accountID/Subdomain)\testrunner
156
+ password: 'SecretPassword123$'
157
+ ```
158
+
159
+ Then run all the tests:
160
+
161
+ ```shell
162
+ bundle exec rake test
163
+ ```
164
+
165
+ ## Contributing
166
+
167
+ Changes reach `main` only through pull requests that pass CI. See [CONTRIBUTING.md](CONTRIBUTING.md).
168
+
169
+ ## Releasing
170
+
171
+ New versions are published to RubyGems by the [Publish gem](.github/workflows/release.yml) workflow when a version tag is pushed:
172
+
173
+ 1. Update `VERSION` in `lib/mtncloud/cli/version.rb` in a pull request, and merge it once CI passes.
174
+ 2. Tag the merged commit on `main` and push the tag:
175
+
176
+ ```shell
177
+ git tag v1.0.1
178
+ git push origin v1.0.1
179
+ ```
180
+
181
+ The workflow fails if the tag does not match `VERSION`. RubyGems does not accept the same version twice.
182
+
183
+ The workflow uses RubyGems trusted publishing, so no API key is stored in this repository. On RubyGems.org, the trusted publisher for `mtncloud-cli` names this repository, the `release.yml` workflow and the `release` environment. If the repository moves, update the repository owner and name in that trusted publisher.
184
+
185
+ ## License
186
+
187
+ MIT. See [LICENSE.txt](LICENSE.txt).
data/Rakefile CHANGED
@@ -1,26 +1,26 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- # Every test, including the ones that need a live appliance (see README > Testing).
5
- Rake::TestTask.new(:test) do |t|
6
- t.libs << "test"
7
- t.libs << "lib"
8
- t.test_files = FileList['test/**/*_test.rb']
9
- end
10
-
11
- # Tests that need a live appliance load the mtncloud_test helper.
12
- OFFLINE_TESTS = FileList['test/**/*_test.rb'].exclude('test/mtncloud_test.rb').reject do |f|
13
- File.read(f).include?("require 'mtncloud_test'")
14
- end
15
-
16
- desc "Run the tests that do not need a live appliance, one file at a time"
17
- task "test:offline" do
18
- failed = OFFLINE_TESTS.reject do |f|
19
- puts "== #{f}"
20
- ruby("-Ilib", "-Itest", f) { |ok, _status| ok }
21
- end
22
- abort "Failed: #{failed.join(', ')}" unless failed.empty?
23
- puts "All #{OFFLINE_TESTS.size} offline test files passed."
24
- end
25
-
26
- #task :default => :test
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ # Every test, including the ones that need a live appliance (see README > Testing).
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << "test"
7
+ t.libs << "lib"
8
+ t.test_files = FileList['test/**/*_test.rb']
9
+ end
10
+
11
+ # Tests that need a live appliance load the mtncloud_test helper.
12
+ OFFLINE_TESTS = FileList['test/**/*_test.rb'].exclude('test/mtncloud_test.rb').reject do |f|
13
+ File.read(f).include?("require 'mtncloud_test'")
14
+ end
15
+
16
+ desc "Run the tests that do not need a live appliance, one file at a time"
17
+ task "test:offline" do
18
+ failed = OFFLINE_TESTS.reject do |f|
19
+ puts "== #{f}"
20
+ ruby("-Ilib", "-Itest", f) { |ok, _status| ok }
21
+ end
22
+ abort "Failed: #{failed.join(', ')}" unless failed.empty?
23
+ puts "All #{OFFLINE_TESTS.size} offline test files passed."
24
+ end
25
+
26
+ #task :default => :test
data/bin/mcs CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env ruby
2
- # mcs is the short alias for the mtncloud command, it runs the same CLI.
3
- load File.expand_path('mtncloud', __dir__)
1
+ #!/usr/bin/env ruby
2
+ # mcs is the short alias for the mtncloud command, it runs the same CLI.
3
+ load File.expand_path('mtncloud', __dir__)
data/bin/mtncloud CHANGED
File without changes