13 Commits

Author SHA1 Message Date
Sirisha Gopigiri
21f015b502 Updating cmd files for documentation
This PS updates cmd related to root, completion, document and
version subcommands. It also updates minor details in other
subcommands.

The description and examples are updated for the airshipctl
commands, which will be inturn used for generating documentation.
Please ignore the .md file changes in this PS. They are added for zuul
gates to pass. Here is the PS with generated documention
files https://review.opendev.org/c/airship/airshipctl/+/789250

Relates-To: #280
Change-Id: I562c15c0d25b2e9731c0eb03854d1d348eb435f2
2021-06-09 09:56:21 +00:00
Ian Howell
a8bdae6c9a Uplift cobra to v1.0.0
This commit uplifts cobra to the latest version. It also includes
various changes accounting for differences in the new version.

Change-Id: I0d1ed3ecd3b8d406428fded92abf6e782951d005
2020-08-14 09:19:34 -05: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
Kostiantyn Kalynovskyi
f34c900ecc Uplift cobra dependency to v0.0.6
This version is required to integrate with clusterctl.
Starting v0.0.6 cobra Execute() method returns ErrSubCommandRequired if
command is executed when its not runnable (Run or RuneE == nil), hence
all tests that invoke such commands need to be either remove or adjusted
to expect these errors

Change-Id: Ia7935c1bf83d47b3a7d3a6c03d1989d53ad57a9a
Relates-To: #187
2020-04-23 10:47:46 -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
Alexander Hughes
26fdd05b0f [#38] Add end-user documentation to project
1. Add end-user documentation of CLI commands
2. Minor refactor of several help messages
3. Update of golden test data to reflect help message changes

Change-Id: I58b8ac3a7871efdb569887ab65191bfb1842c24e
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
2020-03-10 16:45:19 +00: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
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 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
Dmitry Ukov
592850934f Bump kubernetes 1.16.3 as a main dependency
Change-Id: I564745a0d53367fa3b3087107610cec43272cf7c
2019-11-15 13:24:11 -06: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
Ian Howell
129ccb3e3e Add a configuration file for golangci-lint
This adds the .golangci.example.yaml, allowing for more precise control
over how linting is done.

This configuration is highly opinionated and is subject to change.

Change-Id: Ida13bf0dca12e152b75427f5060ad4931e426c72
2019-07-15 12:11:08 -05:00
Ian Howell
7fff1231d5 Add the completion command for bash and zsh
TODO:
  * Add documentation on how to use this
  * Switch to using Cobra's GenZshCompletion function
2019-06-13 12:33:19 -05:00