Skip to content

Commit

Permalink
Revert "provisioner: remove deprecated fields"
Browse files Browse the repository at this point in the history
This reverts commit aa4acf1.

The change broke on several internal manifests which should be fixed first.

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov committed Feb 1, 2024
1 parent 8caf60e commit c335aeb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
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

0 comments on commit c335aeb

Please sign in to comment.