Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
Update azure-pipelines.yml (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlouie authored Nov 15, 2019
1 parent a889fc1 commit 2a5db99
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 69 deletions.
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pool:

variables:
GOBIN: "$(GOPATH)/bin" # Go binaries path
GOROOT: "/usr/local/go1.12" # Go installation path
GOROOT: "/usr/local/go1.13" # Go installation path
GOPATH: "$(system.defaultWorkingDirectory)/gopath" # Go workspace path
modulePath: "$(GOPATH)/src/github.com/$(build.repository.name)" # Path to the module's code
GO111MODULE: "on"
Expand Down Expand Up @@ -31,7 +31,7 @@ steps:
displayName: "Install helm"
- script: |
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.17.1
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.21.0
displayName: Install linter
- script: |
Expand Down
75 changes: 11 additions & 64 deletions core/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ type Component struct {
Manifest string `yaml:"-" json:"-"`
}

// supportedTypes returns a list of valid ComponentType for a Component
func supportedTypes() []string {
return []string{"component", "helm", "static"}
}

// supportedMethods returns a list of valid Method for a Component
func supportedMethods() []string {
return []string{"git", "helm", "http", "local", ""}
}

type unmarshalFunction func(in []byte, v interface{}) error

// UnmarshalFile is an unmarshal wrapper which reads in any file from `path` and attempts to
Expand Down Expand Up @@ -99,26 +89,6 @@ func (c *Component) applyDefaultsAndMigrations() error {
c.ComponentType = "component"
}

// Helper to see if string value is included in a list of strings
includes := func(haystack []string, needle string) bool {
for _, value := range haystack {
if value == needle {
return true
}
}
return false
}

// Ensure component type is valid
if !includes(supportedTypes(), c.ComponentType) {
return fmt.Errorf("component '%s' specified invalid 'type' of '%s', must be one of: %v", c.Name, c.ComponentType, supportedTypes())
}

// ensure component method is valid
if !includes(supportedMethods(), c.Method) {
return fmt.Errorf("component '%s' specified invalid 'method' of '%s', must be one of: %v", c.Name, c.Method, supportedMethods())
}

return nil
}

Expand Down Expand Up @@ -226,11 +196,12 @@ func (c *Component) afterInstall() (err error) {

// InstallComponent installs the component (if needed) utilizing its Method.
// This is only used to install 'components', Generators handle the installation
// of 'non-components' (eg; helm/static)
// of 'non-components' (eg; helm/static). Therefore the only installation needed
// for any component is when ComponentType == "component"|"" and Method ==
// "git"
func (c *Component) InstallComponent(componentPath string) (err error) {
if strings.EqualFold(c.ComponentType, "component") {
switch method := strings.ToLower(c.Method); method {
case "git":
if c.ComponentType == "component" {
if c.Method == "git" {
// ensure `components` dir exists
componentsPath := path.Join(componentPath, "components")
if err := os.MkdirAll(componentsPath, 0777); err != nil {
Expand All @@ -248,30 +219,6 @@ func (c *Component) InstallComponent(componentPath string) (err error) {
return err
}
return nil
case "helm":
return nil
case "http":
return nil
case "":
// default to 'local' if left blank
fallthrough
case "local":
// should already exist in filesystem; ensure it exists
subcomponentPath := path.Join(c.PhysicalPath, c.Path)
potentialComponentPaths := []string{path.Join(subcomponentPath, "component.yaml"), path.Join(subcomponentPath, "component.json")}
componentExists := false
for _, componentPath := range potentialComponentPaths {
if _, err := os.Stat(componentPath); err == nil {
componentExists = true
break
}
}
if !componentExists {
return fmt.Errorf("unable to stat component.yaml for 'local' component '%s' in path '%s'", c.Name, subcomponentPath)
}
return nil
default:
return fmt.Errorf("unsupported method '%s' provided in component '%s'; must be one of %v", c.Method, c.Name, supportedMethods())
}
}

Expand All @@ -285,7 +232,7 @@ func (c *Component) InstallSingleComponent(componentPath string, generator Gener
}

if err := c.applyDefaultsAndMigrations(); err != nil {
return err
return err
}

if err := c.InstallComponent(componentPath); err != nil {
Expand Down Expand Up @@ -602,10 +549,10 @@ func (c *Component) GetAccessTokens() (tokens map[string]string, err error) {
}

// InstallRoot installs the root component
func (c Component) InstallRoot(startingPath string, environments []string) (root Component, err error){
func (c Component) InstallRoot(startingPath string, environments []string) (root Component, err error) {
logger.Debug(fmt.Sprintf("Install root component'%s'", c.Name))

if (c.Method != "git") {
if c.Method != "git" {
return c, err
}

Expand All @@ -621,10 +568,10 @@ func (c Component) InstallRoot(startingPath string, environments []string) (root
func (c Component) UpdateComponentPath(startingPath string, environments []string) (root Component, err error) {
logger.Debug(fmt.Sprintf("Update component path'%s'", c.Name))

if (c.Method != "git") {
if c.Method != "git" {
return c, err
}

if c.ComponentType == "component" || c.ComponentType == "" {
relativePath := c.RelativePathTo()
c.PhysicalPath = path.Join(relativePath, c.Path)
Expand All @@ -636,7 +583,7 @@ func (c Component) UpdateComponentPath(startingPath string, environments []strin
if err != nil {
return c, err
}

if err = c.LoadConfig(environments); err != nil {
return c, err
}
Expand Down
6 changes: 3 additions & 3 deletions core/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (cache *gitCache) cloneRepo(repo string, commit string, branch string) chan
// Add repo to clone args
cloneCommandArgs = append(cloneCommandArgs, repo)

// Only fetch latest commit if commit provided
// Only fetch latest commit if commit not provided
if len(commit) == 0 {
logger.Info(emoji.Sprintf(":helicopter: Component requested latest commit: fast cloning at --depth 1"))
cloneCommandArgs = append(cloneCommandArgs, "--depth", "1")
Expand Down Expand Up @@ -179,11 +179,11 @@ func (cache *gitCache) cloneRepo(repo string, commit string, branch string) chan

// If commit provided, checkout the commit
if len(commit) != 0 {
logger.Info(emoji.Sprintf(":helicopter: Performing checkout commit '%s' for repo '%s' on branch '%s'", commit, repo, branch))
logger.Info(emoji.Sprintf(":helicopter: Performing checkout commit '%s' for repo '%s'", commit, repo))
checkoutCommit := exec.Command("git", "checkout", commit)
checkoutCommit.Dir = clonePathOnFS
if output, err := checkoutCommit.CombinedOutput(); err != nil {
logger.Error(emoji.Sprintf(":no_entry_sign: Error occurred checking out commit '%s' from repo '%s' on branch '%s'\n%s: %s", commit, repo, branch, err, output))
logger.Error(emoji.Sprintf(":no_entry_sign: Error occurred checking out commit '%s' from repo '%s'\n%s: %s", commit, repo, err, output))
cloneResultChan <- &gitCloneResult{Error: err}
return
}
Expand Down

0 comments on commit 2a5db99

Please sign in to comment.