-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
347 additions
and
286 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,3 @@ func AWSSessionFromCluster(cluster *Cluster) *session.Session { | |
|
||
return sess | ||
} | ||
|
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 |
---|---|---|
@@ -1,111 +1,9 @@ | ||
package cluster | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"github.com/mumoshu/shoal" | ||
"golang.org/x/sync/errgroup" | ||
"golang.org/x/xerrors" | ||
"io" | ||
"log" | ||
"path/filepath" | ||
"sync" | ||
"github.com/mumoshu/terraform-provider-eksctl/pkg/sdk" | ||
) | ||
|
||
var prepareEksctlMu sync.Mutex | ||
|
||
func prepareEksctlBinary(cluster *Cluster) (*string, error) { | ||
return prepareEksctlBinaryInternal(cluster.EksctlBin, cluster.EksctlVersion) | ||
} | ||
|
||
func prepareEksctlBinaryInternal(eksctlBin, eksctlVersion string) (*string, error) { | ||
log.Print("Preparing eksctl binary") | ||
|
||
conf := shoal.Config{ | ||
Git: shoal.Git{ | ||
Provider: "go-git", | ||
}, | ||
} | ||
|
||
rig := "https://github.com/fishworks/fish-food" | ||
|
||
installEksctl := eksctlVersion != "" | ||
|
||
if installEksctl { | ||
log.Printf("Installing eksctl %s", eksctlVersion) | ||
|
||
conf.Dependencies = append(conf.Dependencies, | ||
shoal.Dependency{ | ||
Rig: rig, | ||
Food: "eksctl", | ||
Version: eksctlVersion, | ||
}, | ||
) | ||
} | ||
|
||
log.Print("Started taking exclusive lock on shoal") | ||
|
||
prepareEksctlMu.Lock() | ||
defer prepareEksctlMu.Unlock() | ||
|
||
log.Print("Took exclusive lock on shoal") | ||
|
||
logReader, logWriter := io.Pipe() | ||
|
||
s, err := shoal.New(shoal.LogOutput(logWriter)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
log.Print("Shoal instance created") | ||
|
||
if len(conf.Dependencies) > 0 { | ||
eg := errgroup.Group{} | ||
|
||
scanner := bufio.NewScanner(logReader) | ||
|
||
eg.Go(func() error { | ||
for scanner.Scan() { | ||
log.Printf("shoal] %s", scanner.Text()) | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
if err := s.Init(); err != nil { | ||
return nil, fmt.Errorf("initializing shoal: %w", err) | ||
} | ||
|
||
log.Print("Shoal initialized") | ||
|
||
if err := s.InitGitProvider(conf); err != nil { | ||
return nil, fmt.Errorf("initializing shoal git provider: %w", err) | ||
} | ||
|
||
log.Print("Shoal's Git provider initialized") | ||
|
||
eg.Go(func() error { | ||
defer logWriter.Close() | ||
|
||
if err := s.Sync(conf); err != nil { | ||
return xerrors.Errorf("running shoal-sync: %w", err) | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
if err := eg.Wait(); err != nil { | ||
return nil, xerrors.Errorf("calling shoal: %w", err) | ||
} | ||
|
||
log.Println("Shoal sync finished") | ||
} | ||
|
||
binPath := s.BinPath() | ||
|
||
if eksctlVersion != "" { | ||
eksctlBin = filepath.Join(binPath, "eksctl") | ||
} | ||
|
||
return &eksctlBin, nil | ||
return sdk.PrepareExecutable(cluster.EksctlBin, "eksctl", cluster.EksctlVersion) | ||
} |
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
Oops, something went wrong.