Skip to content

Commit

Permalink
add support for external cert-manager module
Browse files Browse the repository at this point in the history
  • Loading branch information
floreks committed Sep 28, 2023
1 parent afbd9e6 commit f1fa1d9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
27 changes: 17 additions & 10 deletions cmd/plural/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"strings"

"github.com/AlecAivazis/survey/v2"
"github.com/pluralsh/polly/algorithms"
"github.com/pluralsh/polly/containers"
"github.com/urfave/cli"

"github.com/pluralsh/plural/pkg/api"
"github.com/pluralsh/plural/pkg/application"
"github.com/pluralsh/plural/pkg/bootstrap"
Expand All @@ -20,9 +24,6 @@ import (
"github.com/pluralsh/plural/pkg/utils/git"
"github.com/pluralsh/plural/pkg/utils/pathing"
"github.com/pluralsh/plural/pkg/wkspace"
"github.com/pluralsh/polly/algorithms"
"github.com/pluralsh/polly/containers"
"github.com/urfave/cli"
)

const Bootstrap = "bootstrap"
Expand Down Expand Up @@ -95,15 +96,21 @@ func (p *Plural) build(c *cli.Context) error {
return errors.ErrorWrap(errNoGit, "Failed to scan your repo for secrets to encrypt them")
}

if c.IsSet("only") {
installation, err := p.GetInstallation(c.String("only"))
if err != nil {
return api.GetErrorResponse(err, "GetInstallation")
} else if installation == nil {
return utils.HighlightError(fmt.Errorf("%s is not installed. Please install it with `plural bundle install`", c.String("only")))
if len(c.StringSlice("only")) > 0 {
for _, inst := range c.StringSlice("only") {
installation, err := p.GetInstallation(inst)
if err != nil {
return api.GetErrorResponse(err, "GetInstallation")
} else if installation == nil {
return utils.HighlightError(fmt.Errorf("%s is not installed. Please install it with `plural bundle install`", inst))
}

if err := p.doBuild(installation, force); err != nil {
return err
}
}

return p.doBuild(installation, force)
return nil
}

installations, err := p.getSortedInstallations("")
Expand Down
2 changes: 1 addition & 1 deletion cmd/plural/plural.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (p *Plural) getCommands() []cli.Command {
Aliases: []string{"bld"},
Usage: "builds your workspace",
Flags: []cli.Flag{
cli.StringFlag{
cli.StringSliceFlag{
Name: "only",
Usage: "repository to (re)build",
},
Expand Down
9 changes: 8 additions & 1 deletion pkg/bootstrap/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func getBootstrapFlags(prov string) []string {
switch prov {
case api.ProviderAWS:
return []string{
"--set", "bootstrap.cert-manager.enabled=true",
"--set", "cluster-api-provider-aws.cluster-api-provider-aws.bootstrapMode=true",
"--set", "bootstrap.aws-ebs-csi-driver.enabled=false",
"--set", "bootstrap.aws-load-balancer-controller.enabled=false",
Expand All @@ -146,12 +147,14 @@ func getBootstrapFlags(prov string) []string {
}
case api.ProviderAzure:
return []string{
"--set", "bootstrap.cert-manager.enabled=true",
"--set", "cluster-api-cluster.cluster.azure.clusterIdentity.bootstrapMode=true",
"--set", "bootstrap.external-dns.enabled=false",
"--set", "plural-certmanager-webhook.enabled=false",
}
case api.ProviderGCP:
return []string{
"--set", "bootstrap.cert-manager.enabled=true",
"--set", "bootstrap.cert-manager.serviceAccount.create=true",
"--set", "cluster-api-provider-gcp.cluster-api-provider-gcp.bootstrapMode=true",
"--set", "bootstrap.external-dns.enabled=false",
Expand All @@ -174,12 +177,16 @@ func getKubeconfigPath() (string, error) {

// GetBootstrapPath returns bootstrap repository path.
func GetBootstrapPath() (string, error) {
return GetModulePath("bootstrap")
}

func GetModulePath(module string) (string, error) {
gitRootPath, err := git.Root()
if err != nil {
return "", err
}

return pathing.SanitizeFilepath(filepath.Join(gitRootPath, "bootstrap")), nil
return pathing.SanitizeFilepath(filepath.Join(gitRootPath, module)), nil
}

// GetStepPath returns path from which step will be executed.
Expand Down
14 changes: 13 additions & 1 deletion pkg/bootstrap/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,21 @@ func getMigrationSteps(runPlural ActionFunc) ([]*Step, error) {
},
Retries: 2,
},
{
Name: "Install cert-manager bundle",
Args: []string{"plural", "bundle", "install", "cert-manager", fmt.Sprintf("cert-manager-%s", man.Provider)},
TargetPath: gitRootDir,
Execute: runPlural,
},
{
Name: "Build values",
Args: []string{"plural", "build --only", "cert-manager", "--only" , "bootstrap", "--force"},
TargetPath: gitRootDir,
Execute: runPlural,
},
{
Name: "Run deploy",
Args: []string{"plural", "deploy", "--from", "bootstrap", "--silence", "--commit", "migrate to cluster api"},
Args: []string{"plural", "deploy", "--from", "cert-manager", "--silence", "--commit", "migrate to cluster api"},
TargetPath: gitRootDir,
Execute: runPlural,
},
Expand Down

0 comments on commit f1fa1d9

Please sign in to comment.