-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial work on resource workload support
- Loading branch information
1 parent
63fdf16
commit 6a8b2e2
Showing
39 changed files
with
1,768 additions
and
77 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
generator "github.com/uselagoon/build-deploy-tool/internal/generator" | ||
"github.com/uselagoon/build-deploy-tool/internal/helpers" | ||
hpatemplate "github.com/uselagoon/build-deploy-tool/internal/templating/resources/hpa" | ||
pdbtemplate "github.com/uselagoon/build-deploy-tool/internal/templating/resources/pdb" | ||
) | ||
|
||
var resourceWorkloadGeneration = &cobra.Command{ | ||
Use: "resource-workloads", | ||
Aliases: []string{"rw"}, | ||
Short: "Generate the resource workload templates for a Lagoon build", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
generator, err := generatorInput(true) | ||
if err != nil { | ||
return err | ||
} | ||
return ResourceWorkloadTemplateGeneration(generator) | ||
}, | ||
} | ||
|
||
// IngressTemplateGeneration . | ||
func ResourceWorkloadTemplateGeneration(g generator.GeneratorInput) error { | ||
lagoonBuild, err := generator.NewGenerator( | ||
g, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
savedTemplates := g.SavedTemplatesPath | ||
|
||
// generate the templates | ||
if g.Debug { | ||
fmt.Println(fmt.Sprintf("Templating HPA manifests to %s", fmt.Sprintf("%s/%s.yaml", savedTemplates, "hpas"))) | ||
} | ||
templateYAML, err := hpatemplate.GenerateHPATemplate(*lagoonBuild.BuildValues) | ||
if err != nil { | ||
return fmt.Errorf("couldn't generate template: %v", err) | ||
} | ||
helpers.WriteTemplateFile(fmt.Sprintf("%s/%s.yaml", savedTemplates, "hpas"), templateYAML) | ||
if g.Debug { | ||
fmt.Println(fmt.Sprintf("Templating HPA manifests to %s", fmt.Sprintf("%s/%s.yaml", savedTemplates, "pdbs"))) | ||
} | ||
templateYAML, err = pdbtemplate.GeneratePDBTemplate(*lagoonBuild.BuildValues) | ||
if err != nil { | ||
return fmt.Errorf("couldn't generate template: %v", err) | ||
} | ||
helpers.WriteTemplateFile(fmt.Sprintf("%s/%s.yaml", savedTemplates, "pdbs"), templateYAML) | ||
return nil | ||
} | ||
|
||
func init() { | ||
templateCmd.AddCommand(resourceWorkloadGeneration) | ||
} |
Oops, something went wrong.