127 Commits

Author SHA1 Message Date
Yasin, Siraj (SY495P)
8d97d5d7ee [#57] - Added --current flag to set-context
* Added --current flag to set-context command to use current-context
when context not provided
* Added validation to throw error when both context and --current flag
* Updated golden files to match the recent change
given
* Added validation to check if current context is set when --current
flag is provided

Old Format: airshipctl config set-context default --manifest default --namespace default
New Format: airshipctl config set-context --current --manifest default --namespace default

Change-Id: I9ffe3a34f33ffd7ff03ca42de7609f91f5386b37
2020-02-24 19:02:20 +00:00
Yasin, Siraj (SY495P)
70eb76e608 [#51] - removing --current-context for set-context
Now that --current-context is removed for set-context, removing all
references of --current-context for set-context in test cases.

Change-Id: Ib77a8dba4a245c61d1d6c057561b0f6983d80cd3
2020-02-21 13:44:47 +00:00
Zuul
45adf6ec75 Merge "[#42] Refactor flag operations to be uniform" 2020-02-20 18:52:08 +00:00
Ian Howell
091fa09a23 [#50] Clean up temp files from unit tests
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
2020-02-20 11:48:11 -06:00
Ian Howell
dc0979b65b [#42] Refactor flag operations to be uniform
This also increases unit test coverage

Change-Id: I324954a1216f2204ff3977c05eb9bd087cd87795
2020-02-20 11:25:41 -06:00
Zuul
24542ca8bc Merge "[#51] Remove current-context flag" 2020-02-19 07:35:35 +00:00
Zuul
6c3fa7f28a Merge "Add render sub-command frame" 2020-02-18 19:46:23 +00:00
Drew Walters
18d6e2ac29 [#51] Remove current-context flag
Executing "airshipctl config set-context [NAME]" misleadingly prints a
message saying the context has been modified, but doesn't change to that
context or modify any context values. This change modifies the behavior
of context command to switch to a provided context when no flags are
specified. It also removes the current-context flag, which becomes
redundant with this change.

Change-Id: I2622fbf59539513feb1236f13b9090978aeb81ef
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-02-18 13:06:37 -06:00
Drew Walters
5d83122b17 [#6] Add config init subcommand
This change introduces logic for the config init subcommand, which
generates an airshipctl configuration file with default values. The
default values are extracted from constants and change when the source
code is updated.

Closes #6

Change-Id: I452e26bc5a924f0cdcd3153a9b124d23e2e5b1f0
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-02-17 16:22:10 -06:00
Ian H Pittwood
90f025e64d Remove remote dependency for pull_test.go
Change-Id: I158ade3b7987d3c2f2b57a616a200a210517e24a
2020-02-17 15:49:27 -06:00
Dmitry Ukov
ff917e5a49 Add render sub-command frame
Render command filters documents and prints them to user-defined
output in a form of multi-document YAML.

Sub-command receives following document filter flags:
 * label
 * annotation
 * apiVersion (a.k.a group-version)
 * kind
 * filter

Related: #16
Change-Id: I7efb0a478e1070efd1791ab10d7c3946c8c28630
2020-02-17 11:27:22 +00:00
Zuul
d6811316a1 Merge "[#27] Move execution logic from cmd to pkg" 2020-02-14 06:04:06 +00:00
Ian H. Pittwood
7437bb2972 [#13] Add document pull command
Adds `airshipctl document pull` command that will check the current
manifest specified by the config and download it to the config specified
target path.

Change-Id: I493564c056225ff1e19f5d1aecb8c187683529ec
2020-02-12 11:01:11 -06:00
Alexander Hughes
8f27532ce0 [#34] Add tests to commands expecting N args
Commands using cobra's ExactArgs feature previously did not have any
validation that the ExactArgs was being enforced. This patchset adds
tests to ensure that in the cases ExactArgs=n, that only n args are
accepted, and other values such as x or y throw an appropriate error.

Change-Id: I27b5774e79db51e0e9bc81d8c207be80811ba459
2020-02-12 14:11:30 +00:00
Zuul
ec6d1e408b Merge "[#10] Perform early validation of completion cmd" 2020-02-12 07:48:06 +00:00
Zuul
07784ce97a Merge "[#28] Fix bad defaults for config file paths." 2020-02-12 07:45:27 +00:00
Ian H. Pittwood
69b37c15b8 [#27] Move execution logic from cmd to pkg
Moves all execution logic from cmd/config to pkg/config.

Adds tests for moved execution logic.

Change-Id: I6381c9fe9eeba938e855bf7d7ea52cd22a5c08b6
2020-02-11 15:33:47 -06:00
Alexander Hughes
c7f42bfcf4 [#10] Perform early validation of completion cmd
In the completion command validation was being done at runtime to
determine if too many or too few args were being passed in.  This
approach required extra unit tests to validate the behavior.

This patch seeks to streamline the code by specifying the number of
args expected when initializing the cobra command, and allowing cobra
to throw an error before doing any work in go if the number of args is
incorrect.

As a result the unit tests for too many and too few args are no longer
needed for this package and have been removed.

Change-Id: If0cf043713ef08333f17b010210352205d74c4ee
2020-02-11 18:44:05 +00: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
Dmitry Ukov
97c114cb21 Switch remote direct to airshipctl configuration
Related #7
Change-Id: I015b178895359ea468748eb72e367b4ff56026bb
2020-02-07 22:01:45 +04:00
Dmitry Ukov
a125dc5d8a Fix cluster name parsing
For cluster names that contain underscore ('_') symbol config module
removed some part of the name due to hardcoded indexes after name split

Change-Id: Ibd1e9b3ef2fce7e43cbdf41f4b1852933a253868
2020-02-07 21:58:10 +04:00
Ian H. Pittwood
c7c1011a5c Fix various code style issues
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
2020-02-07 09:28:18 -06:00
Zuul
cac75584d0 Merge "Fix an output bug in get-context" 2020-02-06 19:11:56 +00:00
Ian H. Pittwood
8a3950d238 Fix typos in variable names and comments
Change-Id: I361916cc18c67e72fbfdbb4b6547f80a5d098327
2020-02-05 16:31:05 -06:00
Zuul
9dba7f7744 Merge "Remove extra '-type' from --cluster-type flag" 2020-02-04 21:56:50 +00:00
Ian Howell
cfb90f443e Remove extra '-type' from --cluster-type flag
Change-Id: I8340ba5fcf60f73bc12b82e004436339e2365a78
2020-02-04 13:50:04 -06:00
Rodolfo Pacheco
36a302fce1 Introduces config cmd's for set-credentials and get-credentials
to manage authentication information for clusters.

Includes username/password, certificate
and token options.

Change-Id: If95e5bbf5c3ddc4732465e81de407d5ad416e8f2
2020-02-04 13:01:19 -05:00
Kostiantyn Kalynovskyi
8c6ebb66d9 [AIR-203] add airshipctl config init subcommand
This commit is only base for future implementation

Change-Id: I3cfb3508de04d0a717245a75b5b197fda68fd01c
2020-01-28 17:16:11 +00:00
Ian Howell
73f9eb383b Fix an output bug in get-context
This fixes an issue where `airshipctl config get-context` would provide
no output when there were no contexts in the configuration.

Change-Id: I8eaafff8ecee7878f80d22867b0420feba1bf376
2020-01-27 12:08:34 -06:00
Dmitry Ukov
7089223607 Move configuration errors to config module
Change-Id: I878ba176f72db3dba587478f17290991b0f5b3d3
2020-01-23 13:05:17 +04:00
Dmitry Ukov
48e14c3b55 [AIR-195] Extend config with isogen options
Change-Id: Ibde769336b955d450105c928e2be707327273879
2020-01-23 13:03:42 +04: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
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
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
Dmitry Ukov
592850934f Bump kubernetes 1.16.3 as a main dependency
Change-Id: I564745a0d53367fa3b3087107610cec43272cf7c
2019-11-15 13:24:11 -06:00
Zuul
20c8dc8fde Merge "This tests get-cluster with the pre-built CmdTest" 2019-11-15 16:58:09 +00:00
Ian Howell
404760ce3e This tests get-cluster with the pre-built CmdTest
This changes the unit tests in ./cmd/config/get_cluster.go by swapping
out the `run` function for the pre-built CmdTest. This matches the
conventions of the existing test bed.

Change-Id: I4cecd211fe7ab74a1151635f29bda578887f400a
2019-11-15 10:30:41 -06:00
Ian Howell
086b0661d2 Remove unused and commented out code
Change-Id: I92b325d7b78e26bbab21270ac9e52540a26c4ea1
2019-11-15 10:14:42 -06:00
Zuul
ffcb533d39 Merge "Switch isogen command output to log module" 2019-11-15 15:37:48 +00:00
Dmitry Ukov
5ae4a37618 Switch isogen command output to log module
Change-Id: I4f23bbe192a2f56a4ebfa0d1417b2271a343ff96
2019-11-14 13:25:49 -06: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
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
Zuul
f24abc6033 Merge "Add testing expectations" 2019-11-07 18:05:40 +00:00
Ian Howell
d4dab71f86 Add testing expectations
* Documents the expectations for unit-tests
* Updates the tests to the version command so as to provide a clear
  example of how to test commands.

Change-Id: I3fbb509a2e4298b4ae68200764a6034459b61602
2019-11-07 11:37:53 -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
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
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
Steve Wilkerson
b1d37d8cd3 Update references to 'kubernetes' to proper name
This updates references to 'kubernetes' to be consistent with
the proper naming reference used elsewhere ('Kubernetes').

Change-Id: Ia44f5cbc75c2fba79ac6531282e0612e62cbb9f9
Signed-off-by: Steve Wilkerson <sw5822@att.com>
2019-10-30 11:37:43 -05:00
Zuul
9503619755 Merge "[AIR-97] Adding base airshipctl cluster command" 2019-10-03 16:12:30 +00:00