79 Commits

Author SHA1 Message Date
Ian Howell
49027f4151 Tighten the restrictions of the linter
This change causes the linter to be a bit more complainy. The hope is
that this will cut down on some of the more pedantic issues being caught
in code reviews, and thus reduce the overall time a change spends in the
review process.

This change includes various changes to the codebase to bring it up to
the new standards.

Change-Id: I570d304bca5554404354f972d8a2743279a0171b
2020-01-10 14:54:34 -06:00
Kostiantyn Kalynovskyi
b43e4e4fea Add abstraction to git repositories
This can be used to pull documents from git repositories defined
by config module in manifest

Change-Id: Ib25cd7e263b6de56bc107607c081e2b02281b8b5
2020-01-08 19:43:59 +00:00
Zuul
7359327a20 Merge "Introduces set_context and get_context operations Each of these include an option for --current-context that set or retrieves the curret context" 2020-01-08 19:10:14 +00:00
Rodolfo Pacheco
a480527808 Introduces set_context and get_context operations
Each of these include an option for --current-context that set or retrieves
the curret context

This patchset mainly creates the cmd/config and pkg/config require additions

Also includes a fync getCurrentContext(<CLUSTERTYPE>)  in the config pkg
that other modules should rely on.

Introduces new  ErrMissingConfig and  ErrConfigFailed types been used by
set-context, will decimate through get/ and set/get cluster after this is
reviewed.

Change-Id: I501483a9db99f33f860eaf329a65bb0209b2aaff
2020-01-08 11:46:16 -05:00
Zuul
d9e18f78ff Merge "Fix redfish reboot logic" 2020-01-02 22:59:20 +00:00
Dmitry Ukov
ca08fec157 Fix redfish reboot logic
Power On commnad was not sent due to wrong logic around
ScreenRedfishError function.

Change-Id: Iec39c49ddf7c4df8fed16fdfe06828513692abad
2019-12-04 08:59:48 +00:00
Dmitry Ukov
c1ed28fd25 Move all error structs to common package 'errors'
Change-Id: I91e9610b27244fe5d7500575eae24647e256dab8
2019-12-01 14:14:09 +04:00
Ian Howell
8dd721830b Create a new test object for each redfish unittest
This removes the SampleSystem testing variable and replaces it by a
function which generates the object. This guarantees that the test
system has the same initial configuration for each test regardless of
the order in which tests are run.

Change-Id: I9875723ac4194425674c2806cf099509f94ad771
2019-11-20 13:58:36 -06:00
Zuul
49e05cc9a6 Merge "Remove a duplicated unit test" 2019-11-15 16:59:55 +00:00
Zuul
80621d71e5 Merge "Remove unused and commented out code" 2019-11-15 16:46:08 +00:00
Ian Howell
a0751bb343 Remove a duplicated unit test
This drops the TestSpecifyKubeConfigInCli unit test, as it as a
duplicate of TestInitFlags.

Change-Id: I69a8f5f0151e9c8b9906c1b3076e16304c50831a
2019-11-15 10:27:46 -06:00
Ian Howell
086b0661d2 Remove unused and commented out code
Change-Id: I92b325d7b78e26bbab21270ac9e52540a26c4ea1
2019-11-15 10:14:42 -06:00
Zuul
1556a09103 Merge "Clean up the reconcileClusters function" 2019-11-15 15:52:31 +00:00
Zuul
ffcb533d39 Merge "Switch isogen command output to log module" 2019-11-15 15:37:48 +00:00
Zuul
5e7cad2d8a Merge "Isolate unit tests by using temp directories" 2019-11-15 15:37:47 +00:00
Dmitry Ukov
5ae4a37618 Switch isogen command output to log module
Change-Id: I4f23bbe192a2f56a4ebfa0d1417b2271a343ff96
2019-11-14 13:25:49 -06:00
Zuul
a6b837afa7 Merge "[AIR-137] Add ISO builder artifacts check" 2019-11-13 17:22:17 +00:00
Zuul
3c3c4b32e0 Merge "[AIR-145] Generate cloud init settings" 2019-11-13 17:21:10 +00:00
Ian Howell
61eecca7f3 Isolate unit tests by using temp directories
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
2019-11-12 15:37:29 -06:00
Ian Howell
871bd8c703 Clean up the reconcileClusters function
* This removes unneeded variables and complexity from the
  reconcileClusters function.
* It also adds a unit test for said function, slightly increasing overall
  unit test coverage
* Finally, this also addresses an issue in the rmConfigClusterStragglers
  function in which the clusters entry was not cleaned up in spite of
  being empty.

Change-Id: I9e7535305840db5f2fb763452d5e4ef46be467c9
2019-11-12 14:56:58 -06:00
Ian Howell
e48b436680 This commit prevents NewConfig from returning errors
Prior to this commit, NewConfig was setting up a new Config object and
filling it with a new kubeconfig object. The process for creating a
kubeconfig object has the potential to return an error. This commit
removes the creation of that object from NewConfig, delegating creation
of kubeconfig objects to more appropriate functions, such as LoadConfig.

Change-Id: I57a040f2e76bbc003eb82171f382e80425b37870
2019-11-12 10:09:36 -06:00
Dmitry Ukov
f73e28164c [AIR-137] Add ISO builder artifacts check
Change-Id: I0f454d56044c6f477b0e4fae18ea0bef8738715d
2019-11-08 08:49:33 +00:00
Dmitry Ukov
6b82a529fc [AIR-145] Generate cloud init settings
Settins are generated based on a secret data

Change-Id: Ib4c25e720759694432e03796ae5d1b4f2f2a1a1b
2019-11-08 08:49:33 +00: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
70f49926ba Remove the need for reflect for testing config
* This also makes some minor newline changes to output.
* This also changes the behavior of nil objects to compare equal to
  other nil objects. This follows the pattern of builtin Go types.

Change-Id: I10d99bbd5251db594a302ca65cd21917804d6a20
2019-11-06 16:34:52 -06:00
Zuul
7dde8016b8 Merge "airshipctl config (replace 686508)" 2019-11-05 19:44:25 +00:00
Zuul
32ee6c48b0 Merge "[AIR-137] Add logic to isogen subcommand" 2019-11-05 15:48:48 +00:00
jezogwza
b2af034e57 airshipctl config (replace 686508)
This implementation creates named references between an airship
config file , and a user specified or system  default kubeconfig file

airshipconfig location can be specified via an envirnment variable
or via
--airshipconf string   Path to file for airshipctl configuration.
                       (default ".airship/config")

kubeconfig has to be explicitly stated using the argument below
--kubeconfig string    Path to kubeconfig associated with airshipctl
                       configuration. (default ".airship/kubeconfig")

if the argument is not specified a default empty kubeconfig will be
used using the default ".airship/kubeconfig"

All subcommands exposed via airshipctl config will update airship
config and airship related kubeconfig
when appropriate.

This patchset adds :

- Config Struct (type)
- config cmd and pkg
- get_cluster : List a specific name cluster or
                List all clusters if no name is provided.
- set-cluster : Create or Modify an existing cluster.

Review comment fixes as of Pathset 19
- Moved core functionality from cmd to pkg
- Encapsulate cmd needs in pck in nw files cmds, cmds_types and cmds_test .
  Expectation is that other functions will need func an structs there.
- added test for GetCluster
- Added GetCluster method to config object to be used by get_cluster command
- Change ClusterNames func as per review suggestion
- Change TestEmpty Cluster to avoid pointing to non test kubecnfig by default
- Change constant AirshipConfigFilePath to AirshipConfigDir
- Renamed config_utils to utils
- Added config cmd output tests
- Changes to settings_test.go to clean after itself.
- Created new pkg/config/testdata/GoldenString for struct data comparison values to avoid confusion
- Fix small get_cluster no name issue when empty config
- Fix issue when reconciling a cluster info that only exists in airship config and not in kubeconfig

Increased coverage to: SUCCESS: Test coverage is at 84.2%,
Started to move all testdata to a single place under pkg/config for now.

Change-Id: I7aae1f15afaebc99407f7fabccecf86ab0923bc3
2019-11-05 15:42:42 +00:00
Kostiantyn Kalynovskyi
3ca3a34fbf Add NewTestBundle function to testutils package
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
2019-11-04 18:28:13 +00:00
Dmitry Ukov
b37b6f3703 [AIR-137] Add logic to isogen subcommand
* Add add default values for isogen subcommand keys
* Introduce container interface
* Implement docker driver
* Add stdin support to container interface
* Implement volume mount for container

Change-Id: Ide0ecd474b1ccce358bdc9c85ef0006f230490b5
2019-11-01 12:27:35 +00:00
Kanwar Saad Bin Liaqat
3bf54274c3 Bootstrap redfish Remote direct
This commit implements redfish remote direct subcommand
under bootstrap.

Change-Id: Idf97445f6fa59a77145eae1edaa15b1d22723f19
Signed-off-by: Kanwar Saad Bin Liaqat <kanwar.sbl@gmail.com>
2019-11-01 02:41:38 +02:00
Kostiantyn Kalynovskyi
3101e642ce Small increase in test coverage
Improving test coverage

Change-Id: I0e4da35f24b16d143cf0e4045182ae7d93d13b1c
2019-10-24 00:34:20 -05:00
Kostiantyn Kalynovskyi
f8f6f8be27 [AIR-97] Moving WriteOut function from bundle pkg
This commit moves Write function to separate yaml package, and makes
it available to anyone for dumping documents in single file, with
correct yaml separators '---', '...'.

This will allow, for example dumping of filtered from bundle documents
to disk or any writer, like Stdout, for debugging purposes. Specifically
it will be used as part of `airshipctl cluster initinfra` command as a
buffer for delivering resources to kubernetes cluster.

Change-Id: I780e3f2d2ff446b8787153f500d04d10487ed71b
2019-10-11 17:13:59 -05:00
Alan Meadows
7eeb529053 Initial commit for document pkg library
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
2019-10-04 14:22:26 -07:00
Ian Howell
062f59119f This isolates logging from the standard library
This commit adds a custom encapsulated Logger, which then has its
methods exposed in a controlled fashion. This prevents external
libraries from modifying things such as the flags passed to the logger,
or where it should output to.

Change-Id: Ide4321246b1277fcee51608aa95532b8696b9777
2019-10-04 10:36:41 -05:00
Ian Howell
dc9c78b210 Fix the coverage tests
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
2019-10-02 15:18:56 -05:00
Zuul
08cc716de5 Merge "[AIR-137] Add isogen subcommand for bootstrap" 2019-10-01 17:47:27 +00:00
Dmitry Ukov
1f2e20e106 [AIR-137] Add isogen subcommand for bootstrap
This is just a frame for command that will execute docker container
with ISO builder scripts

Change-Id: I59a5c494785af3cbcffd3b9f6a488d93f73f4878
2019-09-26 13:51:18 +04: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
Ian Howell
6e41a56a7d Rename module to reflect its new location
Change-Id: I5c8c524c4d3f569b21b5b829722b3c49952cb0ab
2019-07-01 12:15:29 -05:00
Ian Howell
d6b06a8787 Zuul: Switch from travis to zuul
This PS adds the skeleton for a set of zuul checks and gates for
airshipctl and removes the travis config.

This PS also removes some dead code from the util package. This change
is required to get unit tests passing.

Change-Id: Ifb1be49cb1bb82c62a0085b6da9b8ff1b261a95b
2019-07-01 11:00:26 -05:00
Ian Howell
5999d17323 Add argo as a subcommand
This is a drop-in of the argo cmd package, with some slight tweaks to
adhere to airshipctl's models and linter. It still needs to be combed
over and modified to meet airshipctl's needs, as well as requiring unit
tests
2019-06-13 08:58:19 -05:00
Ian Howell
3c02f845d0 Remove argo 2019-06-13 08:12:45 -05:00
Ian Howell
56a4824524 Fix unit tests 2019-06-06 15:27:57 -05:00
Ian Howell
549e5cb955 Fix a fatal bug in GetClientSet 2019-06-06 14:29:56 -05:00
Ian Howell
68cfcf82ae Fix log tests 2019-06-06 11:40:40 -05:00
Ian Howell
cbd1e048c9 Move the client objects out of the settings objects
* This also modifies the way that logging is handled
2019-06-06 10:57:33 -05:00
Ian Howell
ed6cd68e55 Spelling mistake 2019-06-05 10:04:43 -05:00
Ian Howell
a8e649eb67 Move workflow listing to its own package
* adds the AGE, DURATION, and PRIORITY columns
* adds the --all-namespaces flag
2019-05-31 15:57:07 -05:00
Ian Howell
3b4a9fb82c Move workflow init to the workflow package 2019-05-31 10:12:24 -05:00