@@ -90,7 +90,7 @@ func (t *AnsibleApp) getRepoPath() string {
9090	return  repo .GetFullPath ()
9191}
9292
93- func  (t  * AnsibleApp ) installGalaxyRequirementsFile (requirementsType  string , requirementsFilePath  string ) error  {
93+ func  (t  * AnsibleApp ) installGalaxyRequirementsFile (requirementsType  GalaxyRequirementsType , requirementsFilePath  string ) error  {
9494
9595	requirementsHashFilePath  :=  fmt .Sprintf ("%s.md5" , requirementsFilePath )
9696
@@ -101,7 +101,7 @@ func (t *AnsibleApp) installGalaxyRequirementsFile(requirementsType string, requ
101101
102102	if  hasRequirementsChanges (requirementsFilePath , requirementsHashFilePath ) {
103103		if  err  :=  t .runGalaxy ([]string {
104- 			requirementsType ,
104+ 			string ( requirementsType ) ,
105105			"install" ,
106106			"-r" ,
107107			requirementsFilePath ,
@@ -125,21 +125,28 @@ func (t *AnsibleApp) GetPlaybookDir() string {
125125	return  path .Dir (playbookPath )
126126}
127127
128+ type  GalaxyRequirementsType  string 
129+ 
130+ const  (
131+ 	GalaxyRole        GalaxyRequirementsType  =  "role" 
132+ 	GalaxyCollection  GalaxyRequirementsType  =  "collection" 
133+ )
134+ 
128135func  (t  * AnsibleApp ) installRolesRequirements () (err  error ) {
129- 	err  =  t .installGalaxyRequirementsFile ("role" , path .Join (t .GetPlaybookDir (), "roles" , "requirements.yml" ))
136+ 	err  =  t .installGalaxyRequirementsFile (GalaxyRole , path .Join (t .GetPlaybookDir (), "roles" , "requirements.yml" ))
130137	if  err  !=  nil  {
131138		return 
132139	}
133- 	err  =  t .installGalaxyRequirementsFile ("role" , path .Join (t .getRepoPath (), "roles" , "requirements.yml" ))
140+ 	err  =  t .installGalaxyRequirementsFile (GalaxyRole , path .Join (t .getRepoPath (), "roles" , "requirements.yml" ))
134141	return 
135142}
136143
137144func  (t  * AnsibleApp ) installCollectionsRequirements () (err  error ) {
138- 	err  =  t .installGalaxyRequirementsFile ("collection" , path .Join (t .GetPlaybookDir (), "collections" , "requirements.yml" ))
145+ 	err  =  t .installGalaxyRequirementsFile (GalaxyCollection , path .Join (t .GetPlaybookDir (), "collections" , "requirements.yml" ))
139146	if  err  !=  nil  {
140147		return 
141148	}
142- 	err  =  t .installGalaxyRequirementsFile ("collection" , path .Join (t .getRepoPath (), "collections" , "requirements.yml" ))
149+ 	err  =  t .installGalaxyRequirementsFile (GalaxyCollection , path .Join (t .getRepoPath (), "collections" , "requirements.yml" ))
143150	return 
144151}
145152
0 commit comments