generated from MacroPower/go_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate helm KCL schemas with go generate
- Loading branch information
1 parent
6a17f6c
commit f7e36d3
Showing
19 changed files
with
660 additions
and
242 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/MacroPower/kclipper/pkg/helmmodels/pluginmodule" | ||
) | ||
|
||
func main() { | ||
basePath := "modules" | ||
if err := generate(basePath); err != nil { | ||
fmt.Fprintf(os.Stderr, "error: %v\n", err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func generate(path string) error { | ||
modPath := filepath.Join(path, "helm") | ||
|
||
fcb, err := os.Create(filepath.Join(modPath, "chart_base.k")) | ||
if err != nil { | ||
return fmt.Errorf("failed to open file: %w", err) | ||
} | ||
defer fcb.Close() | ||
pcb := &pluginmodule.ChartBase{} | ||
if err = pcb.GenerateKCL(fcb); err != nil { | ||
return fmt.Errorf("failed to generate KCL: %w", err) | ||
} | ||
|
||
fcc, err := os.Create(filepath.Join(modPath, "chart_config.k")) | ||
if err != nil { | ||
return fmt.Errorf("failed to open file: %w", err) | ||
} | ||
defer fcc.Close() | ||
pcc := &pluginmodule.ChartConfig{} | ||
if err = pcc.GenerateKCL(fcc); err != nil { | ||
return fmt.Errorf("failed to generate KCL: %w", err) | ||
} | ||
|
||
fc, err := os.Create(filepath.Join(modPath, "chart.k")) | ||
if err != nil { | ||
return fmt.Errorf("failed to open file: %w", err) | ||
} | ||
defer fc.Close() | ||
pc := &pluginmodule.Chart{} | ||
if err = pc.GenerateKCL(fc); err != nil { | ||
return fmt.Errorf("failed to generate KCL: %w", err) | ||
} | ||
|
||
return nil | ||
} |
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 @@ | ||
package main | ||
|
||
//go:generate go run -tags=netgo cmd/gen/main.go |
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,23 @@ | ||
""" | ||
This file was generated by the KCL auto-gen tool. DO NOT EDIT. | ||
Editing this file might prove futile when you re-run the KCL auto-gen generate command. | ||
""" | ||
|
||
schema Chart(ChartBase): | ||
r""" | ||
Defines a Helm chart. | ||
|
||
Attributes | ||
---------- | ||
values : any, optional | ||
Helm values to be passed to Helm template. These take precedence over valueFiles. | ||
valueFiles : [str], optional | ||
Helm value files to be passed to Helm template. | ||
postRenderer : ({str:}) -> {str:}, optional | ||
Lambda function to modify the Helm template output. Evaluated for each resource in the Helm template output. | ||
""" | ||
|
||
values?: any | ||
valueFiles?: [str] | ||
postRenderer?: ({str:}) -> {str:} | ||
|
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,38 @@ | ||
""" | ||
This file was generated by the KCL auto-gen tool. DO NOT EDIT. | ||
Editing this file might prove futile when you re-run the KCL auto-gen generate command. | ||
""" | ||
|
||
schema ChartBase: | ||
r""" | ||
Represents attributes common in `helm.Chart` and `helm.ChartConfig`. | ||
|
||
Attributes | ||
---------- | ||
chart : str, required | ||
Helm chart name. | ||
repoURL : str, required | ||
URL of the Helm chart repository. | ||
targetRevision : str, required | ||
Semver tag for the chart's version. | ||
releaseName : str, optional | ||
Helm release name to use. If omitted the chart name will be used. | ||
namespace : str, optional | ||
Optional namespace to template with. | ||
skipCRDs : bool, optional | ||
Set to `True` to skip the custom resource definition installation step (Helm's `--skip-crds`). | ||
passCredentials : bool, optional | ||
Set to `True` to pass credentials to all domains (Helm's `--pass-credentials`). | ||
schemaValidator : "KCL" | "HELM", optional | ||
Validator to use for the Values schema. | ||
""" | ||
|
||
chart: str | ||
repoURL: str | ||
targetRevision: str | ||
releaseName?: str | ||
namespace?: str | ||
skipCRDs?: bool | ||
passCredentials?: bool | ||
schemaValidator?: "KCL" | "HELM" | ||
|
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,20 @@ | ||
""" | ||
This file was generated by the KCL auto-gen tool. DO NOT EDIT. | ||
Editing this file might prove futile when you re-run the KCL auto-gen generate command. | ||
""" | ||
|
||
schema ChartConfig(ChartBase): | ||
r""" | ||
Configuration that can be defined in `charts.k`, in addition to those specified in `helm.ChartBase`. | ||
|
||
Attributes | ||
---------- | ||
schemaGenerator : "AUTO" | "VALUE-INFERENCE" | "URL" | "CHART-PATH" | "LOCAL-PATH" | "NONE", optional | ||
Schema generator to use for the Values schema. | ||
schemaPath : str, optional | ||
Path to the schema to use, when relevant for the selected schemaGenerator. | ||
""" | ||
|
||
schemaGenerator?: "AUTO" | "VALUE-INFERENCE" | "URL" | "CHART-PATH" | "LOCAL-PATH" | "NONE" | ||
schemaPath?: str | ||
|
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.