Skip to content
This repository was archived by the owner on Sep 18, 2021. It is now read-only.

Commit 15f564f

Browse files
committed
fix(cli): do not install collection dependencies in collection folder
1 parent 69e07b7 commit 15f564f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

commands/init/install_collection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ func installCollection(version string) error {
1313
if len(version) > 0 {
1414
repoPath += "," + version
1515
}
16-
return routines.ExecAnsibleGalaxy(
17-
"collection", "install", repoPath,
16+
return routines.ExecAnsibleGalaxyCollection(
17+
"install", repoPath,
1818
)
1919
}
2020

routines/exec.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ func Exec(name string, arg ...string) error {
4545

4646
// ExecAnsibleGalaxy is shortcut for executing a command via ansible-galaxy binary
4747
func ExecAnsibleGalaxy(args ...string) error {
48+
return Exec("ansible-galaxy", args...)
49+
}
50+
51+
// ExecAnsibleGalaxyCollection is shortcut for executing a collection command via ansible-galaxy binary
52+
func ExecAnsibleGalaxyCollection(args ...string) error {
4853
collectionDir, err := ansible.GetCollectionDirs()
4954
if err != nil {
5055
return err
@@ -58,7 +63,10 @@ func ExecAnsibleGalaxy(args ...string) error {
5863
// We have to set a relative path, otherwise ansible-galaxy will do weird things...
5964
relCollectionsPath, _ := filepath.Rel(cwd, "/")
6065
args = append(args, "-p "+relCollectionsPath+"/../.."+collectionDir[0])
61-
return Exec("ansible-galaxy", args...)
66+
67+
// Prepend "collection" task to args
68+
args = append([]string{"collection"}, args...)
69+
return ExecAnsibleGalaxy(args...)
6270
}
6371

6472
// ExecAnsiblePlaybook is shortcut for executing a playbook within the StackHead collection via ansible-playbook binary

0 commit comments

Comments
 (0)