26 Commits

Author SHA1 Message Date
Zuul
ad9ee69cce Merge "Add implementation of document/repo interface" 2020-02-12 14:41:12 +00:00
Zuul
29fb7ff3b8 Merge "Extend airshipctl config with remotedirect options" 2020-02-10 21:15:16 +00:00
Zuul
0c4f1658fb Merge "Fix cluster name parsing" 2020-02-10 21:15:16 +00:00
Kostiantyn Kalynovskyi
d9d3eb2f98 Add implementation of document/repo interface
This patch adds methods and repository stucts that will allow easily
clone/pull/update repositories that are defined in config.manifests.

Change-Id: I3789acd79d2072a2b90ed3bbaff99767070334e5
2020-02-10 20:06:14 +00:00
Dmitry Ukov
8b86e4135f Extend airshipctl config with remotedirect options
Change-Id: I4a08dd671cce88749a6e647a46c2edb38aaf1b58
2020-02-07 21:58:10 +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 Howell
32ef58435d Refactor management of config file paths
This change replaces the usage of the clientcmd's PathOptions with a
simpler filepath approach. The handling of the kube config file
associated with airshipctl is now entirely managed by airshipctl.

This also introduces the environment variable AIRSHIP_KUBECONFIG, which
can be used to override the default location for airship's kube config.
It can in turn be overridden by the command line argument.

Prior to this change, the kube config object was created by creating a
kubernetes client, then stripping off that client's config object. As a
side effect, this change removes the middleman, and creates the kube
config object directly from file.

Change-Id: I99ba88d50a0f45c40597a58fe4b3fdfeb7d1467d
2020-02-07 10:57:50 -06: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
Ian H. Pittwood
8a3950d238 Fix typos in variable names and comments
Change-Id: I361916cc18c67e72fbfdbb4b6547f80a5d098327
2020-02-05 16:31:05 -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
Zuul
3a3d0ae90c Merge "Fix config clusters index in CurrentContextCluster()" 2020-01-23 19:45:01 +00:00
Ian Howell
f0a14cb4fd Add missing Manifest validations to EnsureComplete
The EnsureComplete method needs to perform various validations on a
Config object. This commit adds the missing validations for Manifests.

Change-Id: Ib562a67eefbbf19eb64444c4a811d946a9c8e170
2020-01-23 13:05:22 +04: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
Matt McEuen
d0ca82d624 Fix config clusters index in CurrentContextCluster()
Config.Clusters should be indexed only by "simple" cluster names
(without _ephemeral or _target postfixes).  This fixes an index
that indexed by the "full" cluster name defined in the kubeconfig,
in some cases resulting in a nil pointer dereference.

Change-Id: Ic7a4b46419354d5755ccea58ff73c5fbbc4d9658
2020-01-17 17:52:54 -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
Zuul
80621d71e5 Merge "Remove unused and commented out code" 2019-11-15 16:46:08 +00: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
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
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
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