-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle terragrunt codebases (#91)
* feat: update specs to handle terragrunt * feat: add terragrunt in runner WIP * build: regenerate CRDs * chore: add logging * chore: clean naming conventions * feat: add terragrunt implementation of runner exec * test: remove useless module * fix: use linux in download url * chore: add logs for debugging * fix(terragrunt): issue with testdata module sourcing * chore: use main branch in manifests/all.yaml * chore: clean runner implementation * docs: update doc with new spec and terragrunt * fix: use url from repo instead of config * docs: reformulate * chore: remove dead code --------- Co-authored-by: Alan <alanl@padok.fr>
- Loading branch information
Showing
21 changed files
with
596 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
internal/e2e/testdata/terragrunt/modules/random-pets/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
resource "random_pet" "first" { | ||
length = 1 | ||
} | ||
|
||
resource "random_pet" "second" { | ||
length = 2 | ||
} | ||
|
||
resource "random_pet" "third" { | ||
length = 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
terraform { | ||
source = "../../modules//random-pets" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
inputs = {} |
14 changes: 14 additions & 0 deletions
14
internal/e2e/testdata/terragrunt/random-pets/prod/terragrunt.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
include "root" { | ||
path = find_in_parent_folders() | ||
merge_strategy = "deep" | ||
} | ||
|
||
include "module" { | ||
path = find_in_parent_folders("module.hcl") | ||
merge_strategy = "deep" | ||
} | ||
|
||
include "inputs" { | ||
path = "inputs.hcl" | ||
merge_strategy = "deep" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package runner | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/go-git/go-git/v5" | ||
"github.com/go-git/go-git/v5/plumbing" | ||
"github.com/go-git/go-git/v5/plumbing/transport/http" | ||
"github.com/go-git/go-git/v5/plumbing/transport/ssh" | ||
"github.com/padok-team/burrito/internal/burrito/config" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func clone(repository config.RepositoryConfig, URL, branch, path string) (*git.Repository, error) { | ||
cloneOptions, err := getCloneOptions(repository, URL, branch, path) | ||
if err != nil { | ||
return &git.Repository{}, err | ||
} | ||
return git.PlainClone(WorkingDir, false, cloneOptions) | ||
} | ||
|
||
func getCloneOptions(repository config.RepositoryConfig, URL, branch, path string) (*git.CloneOptions, error) { | ||
authMethod := "ssh" | ||
cloneOptions := &git.CloneOptions{ | ||
ReferenceName: plumbing.NewBranchReferenceName(branch), | ||
URL: URL, | ||
} | ||
if strings.Contains(URL, "https://") { | ||
authMethod = "https" | ||
} | ||
log.Infof("clone method is %s", authMethod) | ||
switch authMethod { | ||
case "ssh": | ||
if repository.SSHPrivateKey == "" { | ||
log.Infof("detected keyless authentication") | ||
return cloneOptions, nil | ||
} | ||
log.Infof("private key found") | ||
publicKeys, err := ssh.NewPublicKeys("git", []byte(repository.SSHPrivateKey), "") | ||
if err != nil { | ||
return cloneOptions, err | ||
} | ||
cloneOptions.Auth = publicKeys | ||
|
||
case "https": | ||
if repository.Username != "" && repository.Password != "" { | ||
log.Infof("username and password found") | ||
cloneOptions.Auth = &http.BasicAuth{ | ||
Username: repository.Username, | ||
Password: repository.Password, | ||
} | ||
} else { | ||
log.Infof("passwordless authentication detected") | ||
} | ||
} | ||
return cloneOptions, nil | ||
} |
Oops, something went wrong.