Commit Graph

11 Commits

Author SHA1 Message Date
Matt McEuen
6af3da8d7b Remove config file requirement for plugin command
Change 725820 [1] configured airshipctl to fail an airship config file
isn't present.  The present change makes an exception to that behavior
for the document plugin subcommand, and moves the plugin loading from
the parent document command into the pull subcommand.

There are multiple reasons we don't want config enforcement in place for plugins:

- If a non-standard config file location is configured via an environment variable,
  the plugin won't know about it (since it's invoked separately by kustomize), and it
  would look for a potentially non-existant default config file, and fail.

- If a user is using the kustomize cli by hand along with airshipctl plugins
  (as opposed to driving the process via airshipctl itself), then they do not
  need the config anyway -- the plugin subcommand doesn't actually use it.
  Forcing the user to create a config file seems awkward here.

[1]: https://review.opendev.org/#/c/725820/16

Change-Id: Ic1b652efb14439ed2757eb9fb0a86feb8b3ef21c
2020-06-22 21:32:18 -05:00
Dmitry Ukov
6d05ae69ee Implement document rendering sub-command
Kustomize filtering and rendering mechanisms are used.

Related: #14
Related: #15
Related: #16
Relates-To: #247
Closes: #247
Co-authored-by: Ruslan Aliev <raliev@mirantis.com>
Change-Id: Ied06b95577772cc51f51f3ebb3acd441388d5cda
2020-05-22 12:05:44 +04:00
Ruslan Aliev
bc90c4f39e Move config init and load from root cmd level
There are several commands which do not require to load config:
completion, help, secret, version. Hovewer, PersistentPreRun call
at root level forces airshipctl to load config anyway. Therefore,
we can observe unnecessary config load errors instead of actual result.
This patch moves config load to subcommand level where it is necessary.

Change-Id: I774a7d038c408e71688f7bf04f1cb87a2132a342
2020-05-09 01:51:09 -05:00
Ian Howell
9ffc305392 Define a standard for creating commands
This commit cleans up the command constructors in an attempt to make the
codebase more uniform and approachable. This includes several refactors:

* Removed the FlagConstants - this makes the help messages and examples
  significantly more readable without needed to compile and run
  airshipctl
* Long help messages and examples are now constant
* Short, Long, and Examples all begin with a capitol letter
* Flag descriptions begin with a lowercase letter. This matches the flag
  description for the builtin "help" flag, making formatting uniform for
  all flags
* Removed redundant unit tests on non-leaf commands

This change also updates the documentation for the affected commands.

Change-Id: I8b9dcbfd9846b3deaab06dec17f80643dae78de9
2020-04-24 10:50:59 -05:00
Dmitry Ukov
39ee048451 Introduce document plugin subcommand
airship document plugin is intended to be executed as an exec plugin
for kustomize document model.
Environment variable is used to gather plugin configuration. Plugin to
execute is determined based on group-version-kind specified in plugin
configuration. Each airship plugin must implement plugin interface.

Relates-To: #173
Change-Id: I4f6c3b5be140c0d8fd7519f1cedd33de1cef662c
2020-04-21 15:00:22 +04:00
Yasin, Siraj (SY495P)
c25d223c7b Add copyright for missing files
* added license templates for go, bash & yaml in tools dir
* added a script that will add license information for all
    missing files. Type:  go, yaml, yml, sh
* skip adding license for all files within testdata
* Syntax:
   > ./tools/add_license.sh

* Skip license for manifests folder
* Added one extra line after licene for yaml files
* Added License after Hashbang for bash.
* Add an extra line after hashbang and before license
* Updated the go template to use multiline comments

New Files:
  1. tools/add_license.sh
  2. tools/license_go.txt
  3. tools/license_yaml.txt
  4. tools/license_bash.txt

Change-Id: Ia4da5b261e7cd518d446896b72c810421877472a
Realtes-To:#147
2020-04-09 08:35:59 -05:00
Alexander Hughes
c2a0359ff9 [#91] refactor secrets as top level command
Future use of secrets will be clunky if it remains as a document
subcommand ex: airshipctl document secret generate materpassphrase

Refactoring so that secrets are now a top level command IE
airshipctl secret ...

Change-Id: I781ef5a4e32dc971f275f758d82d17cedd0f74af
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
2020-03-13 13:00:53 +00:00
Alexander Hughes
7549fdbeb0 [#86] remove unused code
A number of items were identified by GoLand's code inspection as
being unused.  These are being removed in this change.

Change-Id: I0c8c0b5f5c33f2e715f991a02ddd63174758c533
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
2020-03-10 19:15:04 +00:00
Dmitry Ukov
ff917e5a49 Add render sub-command frame
Render command filters documents and prints them to user-defined
output in a form of multi-document YAML.

Sub-command receives following document filter flags:
 * label
 * annotation
 * apiVersion (a.k.a group-version)
 * kind
 * filter

Related: #16
Change-Id: I7efb0a478e1070efd1791ab10d7c3946c8c28630
2020-02-17 11:27:22 +00:00
Ian H. Pittwood
7437bb2972 [#13] Add document pull command
Adds `airshipctl document pull` command that will check the current
manifest specified by the config and download it to the config specified
target path.

Change-Id: I493564c056225ff1e19f5d1aecb8c187683529ec
2020-02-12 11:01:11 -06:00
Ian Howell
9e2d6932f6 Add document command and its first subcommand
This adds the "airshipctl document" tree of commands, as well as one of
its leaf commands, "generate masterpassphrase".

Change-Id: I2365ebe67b38ebbbe4873c6e1beb6407f0e000eb
2019-08-28 09:42:31 -05:00