refactor(galaxy): add type and constants
Some checks are pending
Dev / build-local (push) Waiting to run
Dev / migrate-boltdb (push) Blocked by required conditions
Dev / migrate-mysql (push) Blocked by required conditions
Dev / migrate-mariadb (push) Blocked by required conditions
Dev / migrate-postgres (push) Blocked by required conditions
Dev / integrate-boltdb (push) Blocked by required conditions
Dev / integrate-mysql (push) Blocked by required conditions
Dev / integrate-mariadb (push) Blocked by required conditions
Dev / integrate-postgres (push) Blocked by required conditions
Dev / deploy-server (push) Blocked by required conditions
Dev / deploy-runner (push) Blocked by required conditions

This commit is contained in:
Denis Gukov 2024-10-20 01:13:44 +05:00
parent 94f7da8e4a
commit 2a8f7cf884

View File

@ -90,7 +90,7 @@ func (t *AnsibleApp) getRepoPath() string {
return repo.GetFullPath()
}
func (t *AnsibleApp) installGalaxyRequirementsFile(requirementsType string, requirementsFilePath string) error {
func (t *AnsibleApp) installGalaxyRequirementsFile(requirementsType GalaxyRequirementsType, requirementsFilePath string) error {
requirementsHashFilePath := fmt.Sprintf("%s.md5", requirementsFilePath)
@ -101,7 +101,7 @@ func (t *AnsibleApp) installGalaxyRequirementsFile(requirementsType string, requ
if hasRequirementsChanges(requirementsFilePath, requirementsHashFilePath) {
if err := t.runGalaxy([]string{
requirementsType,
string(requirementsType),
"install",
"-r",
requirementsFilePath,
@ -125,21 +125,28 @@ func (t *AnsibleApp) GetPlaybookDir() string {
return path.Dir(playbookPath)
}
type GalaxyRequirementsType string
const (
GalaxyRole GalaxyRequirementsType = "role"
GalaxyCollection GalaxyRequirementsType = "collection"
)
func (t *AnsibleApp) installRolesRequirements() (err error) {
err = t.installGalaxyRequirementsFile("role", path.Join(t.GetPlaybookDir(), "roles", "requirements.yml"))
err = t.installGalaxyRequirementsFile(GalaxyRole, path.Join(t.GetPlaybookDir(), "roles", "requirements.yml"))
if err != nil {
return
}
err = t.installGalaxyRequirementsFile("role", path.Join(t.getRepoPath(), "roles", "requirements.yml"))
err = t.installGalaxyRequirementsFile(GalaxyRole, path.Join(t.getRepoPath(), "roles", "requirements.yml"))
return
}
func (t *AnsibleApp) installCollectionsRequirements() (err error) {
err = t.installGalaxyRequirementsFile("collection", path.Join(t.GetPlaybookDir(), "collections", "requirements.yml"))
err = t.installGalaxyRequirementsFile(GalaxyCollection, path.Join(t.GetPlaybookDir(), "collections", "requirements.yml"))
if err != nil {
return
}
err = t.installGalaxyRequirementsFile("collection", path.Join(t.getRepoPath(), "collections", "requirements.yml"))
err = t.installGalaxyRequirementsFile(GalaxyCollection, path.Join(t.getRepoPath(), "collections", "requirements.yml"))
return
}