24 Commits

Author SHA1 Message Date
Ruslan Aliev
fba618225a Remove AirshipCTLSettings from root level cmd
AirshipCTLSettings will no longer be used by any command, so this
patch removes it from root level.

Change-Id: I2aa1d80ab0785b498af1ac2c86334f9b0d9ff047
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #327
2020-09-03 23:52:49 -05:00
Ruslan Aliev
abd1317566 Refactor airshipctl root command
As part of config refactoring process, we have to prepare root
level command to future changes, optimize function signatures
and its logic.

Change-Id: I563a7556ce1cca795a74cf2c6a26380467a15a5d
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #327
2020-08-25 17:37:19 -05:00
Ian Howell
a8bdae6c9a Uplift cobra to v1.0.0
This commit uplifts cobra to the latest version. It also includes
various changes accounting for differences in the new version.

Change-Id: I0d1ed3ecd3b8d406428fded92abf6e782951d005
2020-08-14 09:19:34 -05:00
Drew Walters
e34edc0ce2 Move bootstrap cmd functionality to baremetal cmd
Early airshipctl usage has identified the need to control the power of
remote hosts directly from airshipctl. This functionality is typically
required during the bootstrapping phase of airshipctl; however, the
functionality could be used anytime. A logical home for this
functionality would be in a baremetal command, not a bootstrap command.
Since all functionality performed by the bootstrap command is performed on
baremetal hosts, a natural need has developed to group this
functionality together under one baremetal command.

This change moves all functionality from the bootstrap command to a new
baremetal command.

airshipctl baremetal isogen         generate ephemeral node ISO
airshipctl baremetal remotedirect   bootstrap ephemeral node

Change-Id: Ia615224686d97c95d78c3773c2b9f41df9d06ed6
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 16:29:19 +00: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
Kostiantyn Kalynovskyi
f34c900ecc Uplift cobra dependency to v0.0.6
This version is required to integrate with clusterctl.
Starting v0.0.6 cobra Execute() method returns ErrSubCommandRequired if
command is executed when its not runnable (Run or RuneE == nil), hence
all tests that invoke such commands need to be either remove or adjusted
to expect these errors

Change-Id: Ia7935c1bf83d47b3a7d3a6c03d1989d53ad57a9a
Relates-To: #187
2020-04-23 10:47:46 -05:00
Zuul
e7380b3ba6 Merge "Remove getters/setters of AirshipCTLSettings" 2020-04-13 16:15:02 +00: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
Ian Howell
5efc26d9f0 Remove getters/setters of AirshipCTLSettings
This change removes the getters and setters for the following attributes
of pkg/environment.AirshipCTLSettings:

* airshipConfigPath
* kubeConfigPath
* config

The above attributes have been exported to account for the removal of
these methods.

Change-Id: I4e7d38bf6771f7521179a2fe2990475b936b5d95
2020-04-08 09:00:32 -05:00
Ian Howell
e42049919e [#28] Fix bad defaults for config file paths.
This moves the management of default file paths away from pflag and
into airshipctl.

Change-Id: Ib2f701d727fdd28794980cf44722d3147d4e6f07
2020-02-10 16:25:43 -06:00
Ian H. Pittwood
8a3950d238 Fix typos in variable names and comments
Change-Id: I361916cc18c67e72fbfdbb4b6547f80a5d098327
2020-02-05 16:31:05 -06:00
Ian Howell
51b1e86ad9 Fix flag loading order
Prior to this change, flags associated with the Config object were being
read too early (that is, before cobra had parsed them). They are now
read just in time for command execution.

Change-Id: I0affca9429867eb25db40f8323403e0f6976b47b
2020-01-15 13:04:16 -06:00
Ian Howell
d775b2159a This updates the current unit tests for testify
This commit removes any assertion from Go's "testing" package,
preferring instead to use an assertion from the testify package. All
tests now have uniformity.

This also decrease the number of iterations in the password generation
test, decreasing test runtime tenfold

Change-Id: I8799110e93dfa19bebe9050528e865b4c991c3df
2019-11-07 12:15:06 -06:00
Ian Howell
1c999e2095 Add coverage checks
This commit adds a makefile target for generating a report for unit test
coverage. It also adds the coverage_check tool to assert that the actual
test coverage meets the specified requirement.

This also improves various aspects of the testing utilities:
* The "test" package has been renamed to "testutil"
* The "Objs" member has been removed from the CmdTest object
* The "Cmd" member has been added to the CmdTest object. This allows
  testing of multiple variants of a root airshipctl command

Finally, this commit includes additional tests for root.go. These are
required in order to meet the required coverage threshold.

Change-Id: Id48343166c0488c543a405ec3143e4a75355ba43
2019-08-15 11:11:51 -05:00
Ian Howell
6e41a56a7d Rename module to reflect its new location
Change-Id: I5c8c524c4d3f569b21b5b829722b3c49952cb0ab
2019-07-01 12:15:29 -05:00
Ian Howell
e4b45002c9 Enable the linter, and fix uncovered linting issues
This uses the current master commit of golangci-lint. We will want to
update to use a tagged version as soon as the golangci-lint team pushes
a new tag
2019-05-30 10:02:54 -05:00
Ian Howell
3dae793f70 Remove unnecessary arg parsing from tests 2019-05-29 15:15:01 -05:00
Ian Howell
4c6b8486c9 Move all tests to proper table-tests
This commit also changes the way that output is handled while testing
2019-05-29 15:11:55 -05:00
Ian Howell
19f28e278b Cleanup how settings are passed 2019-05-24 15:38:59 -05:00
Ian Howell
75b753b2c3 Remove the dependency on Argo
Much of the code here has simply been copied over from the Argo
repository and then modified to work with the desired version of
client-go. We'll need to look into using client-gen in order to maintain
this
2019-05-24 14:34:33 -05:00
Ian Howell
6aa9b3809b Fix old unit tests
These are going to need to be revisited.
2019-05-24 08:47:49 -05:00
Ian Howell
7a34fd98d9 Change airshipadm to airshipctl 2019-05-07 10:07:54 -05:00
Ian Howell
d26c6c76a1 Update the way golden files are updated 2019-05-01 16:56:42 -05:00
Ian Howell
131355333a Add unit test for root 2019-05-01 15:36:58 -05:00