189 Commits

Author SHA1 Message Date
Stanislav Egorov
5be10c5814 [#204] Refactoring for version cmd
Now the version can be changed from Makefile/env.
By default version is 'devel' if there is no ldflags in build args.
It can be overriden by providing ldflags in Makefile.

Change-Id: Ifef5932ec953ccfaeca8a2ef58eb951c900c7a59
2020-05-06 09:05:19 -07:00
Rodolfo Pacheco
078f6b027a Implement airshipctl config import
Adds clusters, contexts and credentials from a kube config
file to the airship config.

In case of duplicate, the existing airship config values
will take precedence.

Closes: #153

Change-Id: Id09489f7546d8836be5b436071fec43fb99b997e
2020-05-05 11:11:36 -05:00
Drew Walters
4b6d2328de Fix power command host selectors
Both host selectors are always passed to create a manager when a power
command is invoked; however, an empty label selector will include all
hosts.

This change adds a helper function to determine which selectors will be
used based on the flags passed to airshipctl. When a flag is not used, a
selector is not created for it.

Change-Id: I48684cdf6d16073bf85468f6286a22a0aba602f7
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-01 16:59:16 +00:00
Zuul
54d7b5f229 Merge "Add additional debug logging to Redfish calls" 2020-05-01 15:47:26 +00:00
Drew Walters
9ff4c67e05 Add additional debug logging to Redfish calls
When tracking down issues on baremetal nodes using remotedirect, it has
been difficult to pinpoint which Redfish calls fail. This change adds
additional debug logging to make the troubleshooting process simpler
during pre-alpha development.

Change-Id: Ic32d34d010c44b2e7e2a4dfe2b623a451ad94019
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-01 14:14:31 +00:00
Yasin, Siraj (SY495P)
d630b55235 Increase test coverage
* Few more minor changes to increase test coverage

Change-Id: Id34a33732d3201637027cb3eb512a245acbd77b5
2020-05-01 07:43:33 -05:00
Zuul
bee5955548 Merge "Add airshipctl cluster init command" 2020-05-01 00:36:25 +00:00
Kostiantyn Kalynovskyi
1e97f2b480 Add airshipctl cluster init command
Change-Id: Ieb23b3e313126a69e8c3256f5178651ff40a80f9
2020-04-30 16:44:47 -05:00
Ruslan Aliev
0bbc88b4a9 Add phase commandline option for interacting with phases
Instead of having a lot different arbitrary named commands
such as "cluster initinfra", "cluster control-plane", add
a generic phase command that would provide capabilities
for interacting with phases (e.g. getting list or applying
specific one).

Change-Id: I1ab797121aecbfd2348933dfd993c1a5974edaf9
Relates-To: #162
2020-04-30 12:34:07 -05:00
Drew Walters
1ce5005cd6 Add baremetal ejectmedia command
Early airshipctl usage has identified the need to eject virtual media
on-demand using airshipctl in order to prevent booting from stuck media.
This change adds a command to eject all virtual media attached to a
baremetal node.

Change-Id: Id67fa00489093dcb84ce54216e0553fa6a737ea6
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 23:10:36 +00:00
Drew Walters
ddb43694b9 Add label support to baremetal power commands
The power commands support interacting with hosts by providing the host
document name as an argument. This change adds support for filtering
hosts using a labels flag (-l or --labels). This change also adds a name
flag to support filtering host documents by name and removes the
argument requirement.

Change-Id: I54d487a35fb36f26fe8e9931f57bbda25375e714
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 23:10:36 +00:00
Drew Walters
7ddb858135 Add baremetal host poweron command
This change introduces a command to power on baremetal hosts.

Closes: #5

Change-Id: Ie76cd7c044cc44629648ef0b02bb7e492ccccdcf
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 23:10:32 +00:00
Drew Walters
fd65389f1a Move remote cmd functionality to baremetal cmd
Early airshipctl usage has identified the need to change 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 remote command to a new
baremetal command.

Once all functionality is grouped within the new baremetal command, a
user can control hosts like this:

airshipctl baremetal isogen                    generate ephemeral node ISO
airshipctl baremetal remotedirect              bootstrap ephemeral node
airshipctl baremetal poweroff       [DOC_NAME] shutdown baremetal node
airshipctl baremetal poweron        [DOC_NAME] power on baremetal node
airshipctl baremetal reboot         [DOC_NAME] reboot baremetal node
airshipctl baremetal powerstatus    [DOC_NAME] retrieve baremetal node status

Relates-To: #5

Change-Id: I31239df1593aac5810e66e1918d8d3207b9f60fb
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 22:52:35 +00:00
Ian Howell
95a768e366 Increase code coverage
This adds coverage to:

* NewDocumentCommand
* NewBaremetalCommand

Change-Id: I7ece84cd36a4df07dc4c2e7437175484ced9b802
2020-04-28 13:46:06 -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
Drew Walters
995538829e Add management support to non-ephemeral hosts
Management support is only available to the ephemeral host. This change
extends support of management features to hosts not labeled as the
ephemeral host.

Change-Id: I0ac917f2633f659e56e67cafc52d2db9d967754f
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-28 16:29:19 +00:00
Zuul
bf63997ed6 Merge "Define a standard for creating commands" 2020-04-27 20:41:41 +00:00
Drew Walters
0986773bdd Add management configuration module
Some management options are not directly related to the remote direct
functionality, and the remote direct config should not be validated when
they are needed. This change moves those management options to a
dedicated configuration module.

Change-Id: If4388bccbc70b2c77d7804cb4c38644775404242
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-24 21:14:16 +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
Zuul
94cb8bde36 Merge "Uplift cobra dependency to v0.0.6" 2020-04-24 13:59:59 +00: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
Stanislav Egorov
cd9b4dddb4 Refactored airshipctl config
Removed Modules from config. There are no other types of modules
that need additional configuration. BootstrapInfo is defined
in the config directly.

Used camelCase for config parameters.

Change-Id: I3531a061026f3b2f1e72af6272ba4709f28d1b3d
2020-04-22 19:26:07 -07:00
Zuul
2d65de45e9 Merge "Organize CLI helper functions" 2020-04-22 15:56:46 +00:00
Dmitry Ukov
c62a369fd0 Fix documentation for document plugin command
Sub-command documentation improved with real world plugin example

Change-Id: Ibf239470027b856018db38cabb56ba70fbcc5030
2020-04-21 21:33:57 +04: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)
01d66c834d Organize CLI helper functions
* moving cli helper functions to the respective packages with _helper.
* removed cmds.go within pkg/ dir and added config_helper.go

* In the first commit(https://review.opendev.org/#/c/707216/) commit CLI helper
  functions were moved from the cmd/config package to the pkg/config package
* Now we are trying to move the CLI helper functions within their respective packages instead of a command cmds.go.
* Creating and implementing this convention will help us better distinguish library code and CLI helper code
* Added MaxNArgs as 1 for get-credentials and updated test cases

Relates-To: #43
Change-Id: Ibb8139102bd98c6c7596bd97377cf83381cbeb00
2020-04-17 09:28:18 -05:00
Zuul
1ec7a24b54 Merge "Uplift go-git" 2020-04-15 13:08:33 +00:00
Alexander Hughes
c70f4a2742 Refactor of codebase addressing IDE errors
Goland is complaining of a number of bad practices, and unused code.
This patchset addresses some of those complaints, such as:
- struct initialization without field names
- error string should not be capitalized or end with punctuation
- name starts with package name
- duplicate yaml keys
- snake case
- redundant parentheses

For the http.Transport redundant parentheses, the lint target fails
without the use of //nolint:errcheck so it has been added as
(currently) there is no potential for there to be an error returned
see [0] for example.

[0] https://golang.org/src/net/http/transport.go#L42

Change-Id: Ib1b20639c9b6e9be097ef1f158ecd7472f578488
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
2020-04-14 15:55:04 -04:00
Ian Howell
7c6de22354 Uplift go-git
The go-git module (and helper modules)  recently moved from
`gopkg.in/src-d/go-git` to `github.com/go-git/go-git` [0]. This commit
switches to the new module, as well as uplifts from v4 to v5.

[0] https://github.com/src-d/go-git/issues/1295#issuecomment-592965250

Change-Id: I2e73ba7bb1220a3c75c0d81aa5ab0f1f13479161
2020-04-14 09:07:28 -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
Zuul
9ad4db66f4 Merge "Fix for Lint warnings" 2020-04-09 10:01:26 +00: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
Yasin, Siraj (SY495P)
f696ed5f11 Fix for Lint warnings
* This commit handles only warnings of mentioned type
  warning:
    comment on exported function <funcname> should be
      of the form "<funcname> ..."
* In this case, there were comments for the exported
  function/constant/var for which warnings raised,
  but not in expected format.
* So this fix is mostly formating the comment to avoid
  lint warnings.

  Observations:
    * comment did not had function name
    * function name in comment was immediately follwed by comma
        => function followed by space and any description is expected
    * function was not mentioned in the first line of the comment
        => when there is multiline comment, first line should start with
           function name

Change-Id: Ife97104ebc1054f4e34259dca51e8bdb42b33bbd
Relates-To:#148
2020-04-07 14:07:45 +00:00
Drew Walters
263f2ecd6f Add remote system shutdown command
This change introduces a system shutdown command that can be used to
power off remote hosts.

Relates-To: #5

Change-Id: I4fa52db055dcb17e344283fbdd772506e12f77fe
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-07 13:21:27 +00:00
Drew Walters
a4001d255f Add remote host reboot command
This change introduces a reboot command that allows the user to reboot a
remote host. The reboot command supports any airshipctl remote client
and simply uses the one defined in the remote options.

Relates #5

Change-Id: I6e11430aa60a09172eb3ac0f44d1a6ff17ca91b0
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-06 09:26:57 -05:00
Drew Walters
0c3eefe036 Add remote host power status command
This change introduces a command that allows the user to retrieve the
power status of a remote host.

Relates-To: #5

Change-Id: I4d3ded6667a5427ad6814c3d000da3becaec50a1
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-03 21:18:18 +00:00
Drew Walters
d25c22a538 Add remote command
This change introduces the remote command. The remote command will be
used to control the power of remote nodes and eventually include the
"bootstrap remotedirect" functionality.

This change is merely an outline of the command. No functionality is
included in this change.

Closes #117

Change-Id: I3291405f36d6a7acc5c8c1f07bd90ad9c2986cd3
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-03 20:52:22 +00:00
Drew Walters
a15f978cad Use new Redfish client
The remote package in airshipctl is tightly coupled to redfish. In the
future, we may need to introduce IPMI or SMASH; however, adding those
clients now would be difficult because of our tight dependence on
redfish. This change implements usage of the new Redfish client, which
implements the generic remote client. It also separates remoteDirect
functionality from the redfish package in order to make it more loosely
coupled.

Relates #5
Closes #122

Change-Id: I45d4ea6e2a4146ea519e94ea701a3ad527e50ca0
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-03 18:10:53 +00:00
Ian Howell
567e063589 Refactor ClusterComplexName
This change includes various code cleanups which improve the way that a
developer creates and interacts with ClusterComplexNames.

Change-Id: If3c4326f3ca46db7fd307b50ca260cdb1a82f3f3
2020-03-26 17:46:35 -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
Zuul
6fbcc26323 Merge "Split document model, add entrypoints for repos" 2020-03-12 21:10:27 +00:00
Zuul
9a1e2dc0bf Merge "[#70] Remove unnecessary kubectl subcommand" 2020-03-12 17:13:12 +00:00
Kostiantyn Kalynovskyi
147b97048b Split document model, add entrypoints for repos
Add NewBundleByPath function, that would return bundle built from
the specified path argument

Add CurrentContextEntryPoint method of the config
object, that would allow easily get kustomize root path based on
clusterType and phase. You can also leave phase arg empty string,
which would try to return bundle for all phases

Introduce changes to config pakage objects:

- Manifest:
  SubPath: this is relative path to the root of the repository that
contains directories with sites (SiteNames)
    PrimaryRepositoryName: this is a string that must correspond to a key
of the Repositories map of manifest object, which is used to derive
primary repository
    Repositories object is a map, map keys correspond to names of the
directories where `document pull` command will download repositories
defined in manifest prepended by manifest.TargetPath.

Introduce new config method CurrentContextEntryPoint(), method takes
TargetPath, PrimaryRepo.URL, SubPath, and clusterType and phase
constructs a path to the entry point out of which the DocumentBundle
should be build, and returns it to the caller. After that caller can
build a bundle out of it, the bundle will contain documents relevant to
particular cluster-type and phase.

All objects that depend on bundle interface are updated to use the
CurrentContextEntryPoint() method of the config object

Relates-To: #99

Closes: #99

Change-Id: I99320c4cb626841d46f4c298b583e9af90b1dce4
2020-03-12 09:55:05 -05:00
Alexander Hughes
51e07c57d5 [#70] Remove unnecessary kubectl subcommand
kubectl subcommand should not exist as part of airshipctl and is
being removed.

Change-Id: Ie52e8c0f32fd10593e70b68462d9ce95696b2a4d
2020-03-12 12:17:14 +00:00
Alan Meadows
16bc0cc81c Properly locate tests within a config_test pkg for pkg/config and cmd/config
This relocates tests that were improperly placed within the config pkg for both
the pkg/config and cmd/config packages. These were causing testutil to be imported
outside of tests causing a cyclic import issue when trying to import the config
pkg within the document pkg.

This patchset moves the tests as well as refactoring several of them where they
were leveraging private attributes which cannot be accessed as an external test
pkg.

Closes: #109
Relates-To: #107

Change-Id: Ib1bf2aff020599ba0b3f5a7fd7fadf737b8c86b8
2020-03-11 16:21:57 -07: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
Alexander Hughes
26fdd05b0f [#38] Add end-user documentation to project
1. Add end-user documentation of CLI commands
2. Minor refactor of several help messages
3. Update of golden test data to reflect help message changes

Change-Id: I58b8ac3a7871efdb569887ab65191bfb1842c24e
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
2020-03-10 16:45:19 +00:00
Zuul
7012f30933 Merge "Reorganize set_authinfo_test" 2020-03-06 20:25:53 +00:00
Alexander Hughes
fd096c099d Reorganize set_authinfo_test
Minor refactor to resolve warning of Goland IDE code
inspection "Unresolved reference 'run'."

Change-Id: Ic8bbde3ca63903910b91420f3d3178ed1539ce8c
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
2020-03-05 08:28:31 -05:00