113 Commits

Author SHA1 Message Date
Drew Walters
58ba1d94e0 Add management config validation
The management configuration does not have central validation, leading
to late validation errors. Additionally, there is an effort to provide
better config validation on a command-by-command basis.

This change adds central validation to the management configuration that
will be used several ways:

  1. For quicker validation today
  2. For a new CLI command that will be introduced in a future change
     that enables imperative modification of the management config
  3. Possibly in future efforts to provide command-by-command config
     validation by calling the exported Validate() function

Change-Id: I19eafddc818e8d478b9afd053d4ab387c7ad38b3
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-21 14:21:59 +00:00
Zuul
99234bad5d Merge "Remove EnsureComplete config object validation from GetCurrentContext" 2020-05-20 04:01:46 +00:00
Drew Walters
fa2b0eecff Fix cluster reconciliation logic
When reconciling clusters, airshipctl points the bootstrapInfo and
managementConfiguration to an entry named default, and the user is
unaware of this change. The result is that user settings are ignored
unless the user defines settings under entries named "default". This
change updates the cluster reconciliation logic to do this only when a
cluster is added to the airshipconfig by airshipctl.

Fixes #244

Change-Id: I2cefbf83a74d9cd566015509a4f768698d274746
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-19 20:59:23 +00:00
Yasin, Siraj (SY495P)
8d16fffb7c Fix Lint warnings: Missing comments for functions
* Added comments wherever missing for exported functions/constants

Change-Id: I7d0b79b5f56fc6c3edb60a3b58c0962ebd76314c
Relates-To: #148
2020-05-19 16:54:09 +00:00
Ruslan Aliev
9616cd0756 Remove EnsureComplete config object validation from GetCurrentContext
It's redundant and contradictory to call EnsureComplete method from
GetCurrentContext function since this method is called twice
during config load and we perform this check inside of appropriate
action function (like phase apply or cluster init).

Change-Id: Idb9ab7e7665dcc6d199bc96c21ae1dc6d059ac2e
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2020-05-19 01:57:24 -05:00
Matt McEuen
4e64e74b6f Add a setting for kustomize plugins
This adds an env var-driven configuration for the filesystem path
in which kustomize should expect its plugins (including airshipctl)
to be.  The value defaults to a subfolder off the `.airshipit` folder.

The config is persisted as a singleton rather than a member of
AirshipCTLSettings (or the Config) because
1. the settings object would have had to have been passed around
   a couple dozen additional files/functions,
2. it's reasonable to expect the plugin location to be consistent
   across threads in a multi-threaded, airshipctl-as-library context.

Settings_test.go was moved in to an environment_test package to avoid
a circular import dependency.

Change-Id: Icdd21bd3687ef42492e388af982d7b490af3eff3
2020-05-15 15:06:32 -05:00
Alexander Noskov
aab8325af5 Fix default checkout options in Airshipctl config
`airshipctl config init` command, generates default Airshipctl config
with mutually exclusive checkout options.
This CR fixing config generation by setting the only branch.
The `commitHash` and `tag` remain empty as an example in config file..

Change-Id: I12ec9b713e8f6769ddbd5301e000ab0242ea8ff4
Closes: #233
2020-05-14 04:35:19 +00:00
Alexander Noskov
84f2bc60c9 Fix default Airshipctl config parameters
Problems description:
Once we execute airshipctl config init, the default config in
~/.airship/config doesn't contain default values for:
currentContext: ~
clusters:
  default:
    clusterType:
      target:
        bootstrapInfo: ~
        managementConfiguration: ~
---
This PS set default values for Airshipctl config to use it
out of the box.

Closes: #234

Change-Id: I57449e678f19ab1c0e2212c38b01ea195f62aa44
2020-05-12 16:02:05 -05:00
Zuul
60ece21b96 Merge "Fix system power regressions" 2020-05-12 16:42:31 +00:00
Zuul
de6ae03839 Merge "Fix Lint warnings: Missing comments for functions" 2020-05-12 11:13:58 +00:00
Drew Walters
4017e9c221 Fix system power regressions
A change [0] recently merged that makes additional remote parameters
configurable; however, it changed the default wait value to two seconds
and made the wait value a duration in time between two nanoseconds.

This change restores the default wait value of thirty seconds and makes
the wait value representative of seconds again.

[0] https://review.opendev.org/717812

Change-Id: I9fad30d479419efe95fca7dc78154bfc3ca66697
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-05-11 20:33:50 +00:00
Alexander Noskov
753d8a456c Fix pull documents for non-master branch
By specifying any other branch rather than master in airshipctl config,
`airshipctl document pull` command failing with `reference not found`
error.
The resulted target dir, after execution, still pointing to master.
The idea of this change is to use checkout options during the clone
stage, so we will be clonning the specific branch.
Added debug log about cloning default(master) branch in case of
missing checkout options.
Enabled validation for incompatible parameters in checkout options.
Aligned unit tests with code changes.

Closes: #197
Change-Id: I50ac18289a8f02997d5b90c82f1688083cff8bf3
2020-05-09 01:22:54 -05:00
Zuul
f334b45638 Merge "Make remote parameters configurable" 2020-05-08 22:01:18 +00:00
Zuul
93025dfadd Merge "Encoding secret data in airshipctl config files" 2020-05-08 21:05:28 +00:00
Zuul
6559b441fa Merge "Refactor error messages to look more pretty and consistent." 2020-05-08 20:47:49 +00:00
Yasin, Siraj (SY495P)
318895d89d Encoding secret data in airshipctl config files
* encoding while saving credentials in authInfo
* decoding while fethcing credentials from authInfo
* Credentials are found only in ~/.airship/kubeconfig, so did not find
  anything in ~/.airship/config to be encoded.

Change-Id: I13f3d49b2ad7ccd1388cabd015fe5a93be2c7b96
Closes: #155
2020-05-08 15:09:17 +00:00
Vladislav Kuzmin
9c1724f6d8 Make remote parameters configurable
Remove constants and define these parameteres
in config file for remote configuration.

Closes: #138

Change-Id: Ib9250b8d39c01ef43a1262b62e4d37215481bc43
2020-05-08 17:23:59 +04:00
Ruslan Aliev
90f80d55b9 Ensure map is initialized before assignment
Attempts to write to a nil map will cause a runtime panic,
since we don't have explicit checks whether the map is nil
or not - they were added with proper initialization using make.
Appropriate test configuration was added.

Change-Id: Ib50686de44b782fdc881bd4608dd74588fce93bd
Relates-To: #190
Closes: #190
2020-05-07 16:22:52 -05:00
Alexander Noskov
0181e09c64 Refactor error messages to look more pretty and consistent.
Change-Id: I1b58b0ca363c1a22e3772ffa708eea3be4dfd9b5
2020-05-07 01:36:40 -05: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
Yasin, Siraj (SY495P)
972dcf93a9 Fix Lint warnings: Missing comments for functions
* Added comments wherever missing for exported functions/constants

Change-Id: I3757fcf7b9ad24753e2803abaaad84bba7e84fd0
Relates-To: #148
2020-04-30 22:32:39 -05:00
Yasin, Siraj (SY495P)
9530e88c97 Switch to strongly-typed errors
Removed the use of generic Error.
Declared and used specific error types

Change-Id: Iec68a6d037475222825efa8f3bba56fa5780cfa9
2020-04-30 22:31:25 -05:00
Zuul
5bb9b7e623 Merge "Add command line library to integrate clusterctl with airshipctl" 2020-05-01 00:36:24 +00:00
Zuul
93a4449696 Merge "Add utility function to be get current context target-path" 2020-05-01 00:36:23 +00:00
Kostiantyn Kalynovskyi
0e17d6c7f3 Add command line library to integrate clusterctl with airshipctl
Change-Id: I41a73abc7018410b120cff826e87c6ddc559b42d
2020-04-30 16:31:42 -05:00
Kostiantyn Kalynovskyi
081721816e Add utility function to be get current context target-path
Change-Id: I9ec841ab695526736b7bdfecfa911b3cb2204b2c
2020-04-30 21:20:00 +00:00
Zuul
b0259abb6d Merge "Improve config package organization pt.2" 2020-04-30 12:40:15 +00:00
Vladislav Kuzmin
342666c8c9 Improve config package organization pt.2
This is a series of patches that refactor config.go into
several smaller modules, each relating specifically
to one component of the configuration structure.

This patch split bootstrap, context and manifest
related part in separate modules.

Relates-To: #35

Change-Id: I692ab90a62c54f21157e093af0fbdab86c36a486
2020-04-29 18:49:00 +04:00
Ruslan Aliev
af9e46dfec Refactor CurrentContextEntryPoint function
Currently it takes ClusterType as first parameter, however
this parameter can be retrieved via appropriate function
CurrentContextClusterType in the same module.

Change-Id: I205fd7d00bf1745cada88d8fd972dac1dbe0fddf
2020-04-29 06:17:00 -05:00
Zuul
da5d62b95a Merge "Fix for Lint warnings" 2020-04-28 18:32:20 +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
Yasin, Siraj (SY495P)
07f8a5e311 Fix for Lint warnings
* Adding comments for missing exported functions

Change-Id: I40c5861a5c076b654e5a3fc660c3c9c6d7b80c8f
Relates-To: #148
2020-04-28 09:40:57 -05:00
Zuul
fd3118af19 Merge "Improve config package organization pt.1" 2020-04-28 13:53:24 +00:00
Zuul
bf63997ed6 Merge "Define a standard for creating commands" 2020-04-27 20:41:41 +00:00
Vladislav Kuzmin
bb3daf1795 Improve config package organization pt.1
This is a series of patches that refactor config.go into
several smaller modules, each relating specifically
to one component of the configuration structure.

This particular patch split auth info and cluster
related part in separate modules.

Relates-To: #35
Change-Id: Ib2abebc87c80549544a8b7775969df9db55aa8be
2020-04-27 20:54:59 +04:00
Zuul
07ade74a80 Merge "Add management configuration module" 2020-04-27 14:45:30 +00:00
Kostiantyn Kalynovskyi
996fa6f231 Add CurrentContextCluster Type and Name methods
These are convinience methods, that may be helpful if any of our
modules need to have understanding which cluster they are operating
against.

Change-Id: Ib5d32ac3d4cd3170544bbc4d5bf3044926b52955
Relates-To: #162
2020-04-24 21:18:19 -05: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
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
Drew Walters
cb59c859cb Add Dell Redfish client
The Dell Redfish implementation slightly deviates from the DMTF Redfish
specification. One variation is the Dell specification's classification
of virtual media, in which the Dell variation adds support for virtual
CDs and virtual floppy drives [0]. In order to perform some actions on Dell
hardware, airshipctl needs support for vendor specific clients.

This change introduces a vendor-specific Dell client to handle some
Redfish operations.

[0] https://www.dell.com/support/manuals/us/en/04/idrac9-lifecycle-controller-v3.2-series/idrac_3.21.21.21_redfishapiguide/virtualmedia?guid=guid-d9e76cf6-627d-4cb9-a3de-3f2b88b74cfb&lang=en-us

Relates-To: #139

Change-Id: Icc4500177e859d5a4607b98ec2bd2737521d00b1
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-04-17 19:51:24 +00: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
Kostiantyn Kalynovskyi
da2799bee3 Change bootstrap bundle entrypoint to phase dir
Change-Id: I85151f42e510eb113bcc3bb86d56043d51bf348a
Relates-To: #175
2020-04-16 20:02:45 -05: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
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
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
Zuul
21c7c166ff Merge "Allow remotedirect to ignore http*_proxy settings" 2020-03-27 18:46:23 +00:00
Alan Meadows
2e7e6709ca Allow remotedirect to ignore http*_proxy settings
The airshipctl client performs several roles, some of them
benefit from the use of proxy settings and some of them are negatively
impacted by a proxy.

This patchset allows you to explicitly enable
remotedirect to leverage http*_proxy environmental settings but
defaults to ignoring them as that is the desired behavior that
most users will appreciate with communicating directly with BMC
(e.g. redfish) URLs.

At some point, this likely should be followed up with a more holistic
approach of how to configure airshipctl to use a proxy for some functions
but not others but this may be good enough for now.

Change-Id: I10ae4da765aaeb6633df2ca9cde5e6ab543937a5
Relates-To: #143
2020-03-27 09:44:39 -07: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