17 Commits

Author SHA1 Message Date
Ruslan Aliev
0e44b580f0 Fix pulling docs from remote branch
Currently airshipctl is not able to checkout remote branch
due to using simple branch reference name instead of remote one.
This patch fixes appropriate problem and allows user to specify
what kind of branch to use - local or remote one (since reference
name will be different in these scenarios).

Change-Id: I1fea29f84097b9e7160597003d0e8961f4d3aca6
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2021-01-14 12:35:56 -06:00
Vladimir Kozhukalov
0dc4ab7491 Replace PrimaryRepositoryName with PhaseRepositoryName
Change-Id: I2276a3b3ea50b8e81dd240815cd00a0a2a2af96e
Relates-To: #356
2020-10-12 15:28:27 +03:00
Ruslan Aliev
d8a6139e81 Add document pull step to gate script runner
Currently we don't test document pull step by rewriting
manifest_directory variable as current source path, which
makes a mess in target_path, manifest_path and related paths
(concatenation of target_path+manifest_path won't return
an existing and proper location). This patch organizes
mentioned variables and enables document pull step which
starts working properly. The latest repo state used as
git source for this command.

Change-Id: I5abce73877441c7529f2f77add79cf410e2226d8
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
2020-09-25 00:39:28 -05:00
Ruslan Aliev
285aeeba8c Refactor document pull command
This command was refactored for usage with new config factory.
Config object now is being initialized in pkg module on demand,
which provides more flexibility and cleaner code.

Change-Id: Iff75eb66db2fee922e6db1bf2930892c02c3b601
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #327
2020-09-02 23:41:05 -05:00
Ruslan Aliev
71f7a8bc85 Improve document pull command
This patch refactors some code and adds useful debug/info log output.

Change-Id: I590f6e5c300e5c91443af0a8fdb1073229602a67
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #278
2020-07-28 22:01:20 +00:00
Ian Howell
f5846161c2 Isolate document pull unit test
This causes the document pull unit tests to use a git repo stored
locally on the machine, rather than reaching out to github

Change-Id: I0add3cdf60d7fe584c0194148e539a7a290f2bc4
2020-05-19 16:43:23 -05:00
Yasin, Siraj (SY495P)
007e36281e Validate config before document pull
* invoke EnsureComplete before document pull to make sure
  all expected sections (cluster, context, authinfo, currentcontext)
  of config are present

Change-Id: If2ef4611cddc6ae96797dc26675551ef81ca8768
Closes: #215
2020-05-14 14:56:00 -05:00
Alexander Noskov
753d8a456c Fix pull documents for non-master branch
By specifying any other branch rather than master in airshipctl config,
`airshipctl document pull` command failing with `reference not found`
error.
The resulted target dir, after execution, still pointing to master.
The idea of this change is to use checkout options during the clone
stage, so we will be clonning the specific branch.
Added debug log about cloning default(master) branch in case of
missing checkout options.
Enabled validation for incompatible parameters in checkout options.
Aligned unit tests with code changes.

Closes: #197
Change-Id: I50ac18289a8f02997d5b90c82f1688083cff8bf3
2020-05-09 01:22:54 -05:00
Yasin, Siraj (SY495P)
07f8a5e311 Fix for Lint warnings
* Adding comments for missing exported functions

Change-Id: I40c5861a5c076b654e5a3fc660c3c9c6d7b80c8f
Relates-To: #148
2020-04-28 09:40:57 -05:00
Ian Howell
7c6de22354 Uplift go-git
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
2020-04-14 09:07:28 -05:00
Zuul
e7380b3ba6 Merge "Remove getters/setters of AirshipCTLSettings" 2020-04-13 16:15:02 +00: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
Ian Howell
5efc26d9f0 Remove getters/setters of AirshipCTLSettings
This change removes the getters and setters for the following attributes
of pkg/environment.AirshipCTLSettings:

* airshipConfigPath
* kubeConfigPath
* config

The above attributes have been exported to account for the removal of
these methods.

Change-Id: I4e7d38bf6771f7521179a2fe2990475b936b5d95
2020-04-08 09:00:32 -05:00
Kostiantyn Kalynovskyi
147b97048b Split document model, add entrypoints for repos
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
2020-03-12 09:55:05 -05:00
Alan Meadows
16bc0cc81c Properly locate tests within a config_test pkg for pkg/config and cmd/config
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
2020-03-11 16:21:57 -07: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 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