This commit adds get-manifests and set-manifests option for airshipctl
config. get-manifests prints all the manifests in current config file.
set-manifests helps in setting/creating new manifests in current config
file.
Closes: #115
Change-Id: I7c677ed491a1d456744d27bf105f21e2b3c4e6aa
Signed-off-by: Sreejith Punnapuzha <sreejith.punnapuzha@outlook.com>
This commit makes mock filesystem reusable by moving it to importable
package in testutils
Change-Id: I4885480a9ef3b8c81da0058db708c32187af8e12
Relates-To: #277
Relates-To: #238
Closes: #277
Adds FakeFactory function, that allows to inject custom handlers
for HTTP and Unstructured client, which in turn enables better
testing for kubernetes api related packages
Relates-To: #276
Relates-To: #238
Change-Id: Ic27352bdc64bfccb91cc6a49afa6164e4624b1e1
Closes: #276
* 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
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
Baremetal host power statuses are handled as strings in airshipctl.
Invoking remotedirect on a host that is powered off will result in a
remotedirect failure; therefore, the power status of a host needs to be
verified before remotedirect can begin. This change adds strict typing
to baremetal power statuses so airshipctl can verify the status of a
remote host before performing remotedirect regardless of the client type
(e.g. redfish, other).
Change-Id: I22f1784006add018ee1d67c18f94499aa9544752
Signed-off-by: Drew Walters <andrew.walters@att.com>
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>
This change introduces a command to power on baremetal hosts.
Closes: #5
Change-Id: Ie76cd7c044cc44629648ef0b02bb7e492ccccdcf
Signed-off-by: Drew Walters <andrew.walters@att.com>
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>
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>
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
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 ephemeral boot media support for iDRAC systems
using a proprietary API in the Dell client.
During the creation of this change, it was also observed that Redfish
calls fail when media is already inserted. This change adds a check
to eject media if media is already inserted.
[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
Closes: #139
Co-authored-by: Drew Walters <andrew.walters@att.com>
Change-Id: Ic9fd9e1493b1ff1bb20e956ae5f821d137c74760
* The function definition for WithToDiscoveryClientByError and
WithDynamicClientByError seems to be swapped by mistake.
* So aligned the function definiton to its signature
Change-Id: I7e293b148765f460d007aa4a6dc931defeb879b5
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>
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
This updates the Kustomize dependency for airshipctl to
api/v0.3.1, which is the oldest version which will support the
Replacement Transformer plugin.
Some changes were needed to accomodate the fact that various apis
that airshipctl was relying on were moved to kustomize-insternal
packages, namely:
- Integrated with the krusty.Kustomizer to drive kustomization
- Removed the custom plugin loader which leveraged the Unknown type
- Worked around NoFieldError becoming private, inc. removing a test
As a follow on we'll need to re-integrate plugin functionality somehow.
Also, in this release Kustomize has implemented support for the
"config.kubernetes.io/local-config" annotation, which we'd planned
to use to to avoid deploying some documents to the Kubernetes API.
It turns out the semantics are different than we anticipated;
Kustomize also fails to return these docs via document *selection*.
Therefore, this change reverts to an earlier approach which uses
a custom airshipit.org/deploy-k8s label.
Change-Id: I7022e12464ea7b6a3ca8609f99f3699bf8da0edd
* 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
* 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
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>
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>
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>
Remote direct tests mock the go-redfish client in order to avoid making
Redfish API calls. We should be able to mock airshipctl's internal
Redfish API client for unit tests with less side effects. This change
adds a mock Redfish client to reduce the side effects in our remote
direct unit tests.
Relates #5, #122
Change-Id: Ic968c5eefa90aa2065a3f15bb9880edbacf73ece
Signed-off-by: Drew Walters <andrew.walters@att.com>
This updates the Kustomize module dependency to v3.3.1,
which has replacement functionality required by the Replacement Transformer
plugin, among other enhancements.
Change-Id: I058114c398464394cfb6b2626cb475d763c1bacc
The "GetVirtualID" method is stubbed for our Redifsh implementation and
always returns the same values. This change uses the Redfish client to
retrieve the correct virtual media ID and type.
Closes #141
Change-Id: I319b89c13349e7b2f5bf6eb8ced97c949e5f44b5
Signed-off-by: Drew Walters <andrew.walters@att.com>
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
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
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>
Add document filesystem object to avoid direct kustomize imports by
other packages in airshipctl, document.filesystem also extends
kustomize filesystem with temporary file methods.
Relates-To: #11
Closes: #11
Change-Id: Ia8034048d80d79d5996dce0e283828644fbef906
The wrapper is called ApplyAdapter and is a struct, that has Apply(..)
method and some setters that allow to control kubectl apply behaviour
Addapter is expected to be used through Apply(..) function, which takes
slice of document.Document interface objects, writes them out to
temporary file system, from where they are picked up by kubectl Apply
module, and delivered to kubernetes cluster. The decision to use
temporary file system is based on the fact, that in current state
kubectl project currently only works with actual files, and ignores
io.Streams object, that is part of ApplyOptions struct, so it is
currently the only way to use it.
Change-Id: Idc5d79794149c00198f420d76cf9aa3b5264946e
This commit adds the utility testing function TempDir, which provides a
tester with a temporary directory as well as a means of cleaning up that
directory. The new function is implemented everywhere that makes sense
throughout the code base.
This also cleans up the directories left behind by go-git's testing
fixtures.
Some light refactoring was also performed in this change.
Change-Id: I754484934660487140f57671bacb5463cf669e3e
Fixes possible name collisions between variable names and package names
Remove redundant import naming
Use nil slices for slice declarations instead of empty slices
Use make for slices of fixed lengths
Remove redundant parentheses
Replace deprecated `SetOutput` method with `SetOut`
Fix swapped actual/expected arguments on assertEqualGolden
Change-Id: Ia39ef44372c3e44948e5440575125bdb470898df
This commit changes several unit tests to set a "workspace" in a temp
directory. This completely isolates them from other tests as well as the
developer's environment.
Change-Id: Ifa1048c427dc3d69e15dae04318c7d8463b8f8e1
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
This commit adds small helper function in testutils module, that would
help with testing modules that relay on bundle interface. The function
will take directory with testdata as a parameter, and load all files in
it into its fakefile system, allowing bundle to get those files and
render required yaml/kustomize files storing them as airship documents
in the returned bundle.
Change-Id: Ib55180cc720c42cab77626601d9ec0d6151b8454
This introduces two new interfaces to airshipctl:
* Bundle: represents a Kustomize rendered
collection of your documents that allows you to
iterate over or filter the documents in the bundle.
* Document: a thin wrapper around a rendered
document.
This commit also includes a proposal for a way to
represent YAML test fixtures as testdatafs.go
and a new testdata subfolder within the document
pkg.
Change-Id: I4282b27977617552c25c5ae2c3b7da44e67dd014
This fixes a bug where `make cover` was missing packages. The target now
covers all code except for code placed in the top level package (such as
main.go) and anything placed in the testutils directory.
This also fixes minor issues with the Dockerfile and the coverage_check
script
Note that this commit also strives to increase code coverage beyond the
80% margin
Change-Id: I9e1cbcf841cc869345a00f05e39774cb3da10065
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