Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "provisioner: remove deprecated fields" #742

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions provisioner/clusterpy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ post_apply:

deletionsContent2 = `
pre_apply:
- name: {{.Cluster.Alias}}-pre
- name: {{.Alias}}-pre
namespace: templated
kind: deployment
post_apply:
- name: {{.Cluster.Alias}}-post
- name: {{.Alias}}-post
namespace: templated
kind: deployment
`
Expand Down
48 changes: 45 additions & 3 deletions provisioner/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ type templateContext struct {
}

type templateData struct {
// From api.Cluster, TODO: drop after we migrate all Kubernetes manifests
Alias string
APIServerURL string
Channel string
ConfigItems map[string]string
CriticalityLevel int32
Environment string
ID string
InfrastructureAccount string
LifecycleStatus string
LocalID string
NodePools []*api.NodePool
Region string
Owner string

// Available everywhere
Cluster *api.Cluster

Expand All @@ -57,6 +72,12 @@ type templateData struct {

// Available in node pool templates
NodePool *api.NodePool

// User data (deprecated, TODO: move to .Values.UserData)
UserData string

// Path to the generated files uploaded to S3 (deprecated, TODO: move to .Values.S3GeneratedFilesPath)
S3GeneratedFilesPath string
}

func newTemplateContext(fileData map[string][]byte, cluster *api.Cluster, nodePool *api.NodePool, values map[string]interface{}, adapter *awsAdapter) *templateContext {
Expand Down Expand Up @@ -137,9 +158,30 @@ func renderTemplate(context *templateContext, file string) (string, error) {
var out bytes.Buffer

data := &templateData{
Cluster: context.cluster,
Values: context.values,
NodePool: context.nodePool,
Alias: context.cluster.Alias,
APIServerURL: context.cluster.APIServerURL,
Channel: context.cluster.Channel,
ConfigItems: context.cluster.ConfigItems,
CriticalityLevel: context.cluster.CriticalityLevel,
Environment: context.cluster.Environment,
ID: context.cluster.ID,
InfrastructureAccount: context.cluster.InfrastructureAccount,
LifecycleStatus: context.cluster.LifecycleStatus,
LocalID: context.cluster.LocalID,
NodePools: context.cluster.NodePools,
Region: context.cluster.Region,
Owner: context.cluster.Owner,
Cluster: context.cluster,
Values: context.values,
NodePool: context.nodePool,
}

if ud, ok := context.values[userDataValuesKey]; ok {
data.UserData = ud.(string)
}

if s3path, ok := context.values[s3GeneratedFilesPathValuesKey]; ok {
data.S3GeneratedFilesPath = s3path.(string)
}

err = t.Execute(&out, data)
Expand Down
Loading