Skip to content

Commit

Permalink
Merge branch 'main' into run-schema-on-create-2485
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinAbro321 committed Jun 5, 2024
2 parents 40f4f28 + d832c60 commit 83796fc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
15 changes: 2 additions & 13 deletions src/internal/packager/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import (
)

const (
depMarkerOld = "DATA_INJECTON_MARKER"
depMarkerNew = "DATA_INJECTION_MARKER"
depMarker = "DATA_INJECTION_MARKER"
)

// GetZarfVariableConfig gets a variable configuration specific to Zarf
Expand All @@ -36,7 +35,6 @@ func GetZarfVariableConfig() *variables.VariableConfig {

return variables.New(
"zarf",
deprecatedKeys(),
prompt,
slog.New(message.ZarfHandler{}))
}
Expand Down Expand Up @@ -65,9 +63,7 @@ func GetZarfTemplates(componentName string, state *types.ZarfState) (templateMap
"GIT_AUTH_PULL": gitInfo.PullPassword,
}

// Preserve existing misspelling for backwards compatibility
builtinMap[depMarkerOld] = config.GetDataInjectionMarker()
builtinMap[depMarkerNew] = config.GetDataInjectionMarker()
builtinMap[depMarker] = config.GetDataInjectionMarker()

// Don't template component-specific variables for every component
switch componentName {
Expand Down Expand Up @@ -111,13 +107,6 @@ func GetZarfTemplates(componentName string, state *types.ZarfState) (templateMap
return templateMap, nil
}

// deprecatedKeys returns a map of template keys that are deprecated
func deprecatedKeys() map[string]string {
return map[string]string{
fmt.Sprintf("###ZARF_%s###", depMarkerOld): fmt.Sprintf("###ZARF_%s###", depMarkerNew),
}
}

// generateHtpasswd returns an htpasswd string for the current state's RegistryInfo.
func generateHtpasswd(regInfo *types.RegistryInfo) (string, error) {
// Only calculate this for internal registries to allow longer external passwords
Expand Down
4 changes: 1 addition & 3 deletions src/pkg/variables/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
// VariableConfig represents a value to be templated into a text file.
type VariableConfig struct {
templatePrefix string
deprecatedKeys map[string]string

applicationTemplates map[string]*TextTemplate
setVariableMap SetVariableMap
Expand All @@ -22,10 +21,9 @@ type VariableConfig struct {
}

// New creates a new VariableConfig
func New(templatePrefix string, deprecatedKeys map[string]string, prompt func(variable InteractiveVariable) (value string, err error), logger *slog.Logger) *VariableConfig {
func New(templatePrefix string, prompt func(variable InteractiveVariable) (value string, err error), logger *slog.Logger) *VariableConfig {
return &VariableConfig{
templatePrefix: templatePrefix,
deprecatedKeys: deprecatedKeys,
applicationTemplates: make(map[string]*TextTemplate),
setVariableMap: make(SetVariableMap),
prompt: prompt,
Expand Down
6 changes: 0 additions & 6 deletions src/pkg/variables/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ func (vc *VariableConfig) ReplaceTextTemplate(path string) error {
preTemplate := matches[regexTemplateLine.SubexpIndex("preTemplate")]
templateKey := matches[regexTemplateLine.SubexpIndex("template")]

_, present := vc.deprecatedKeys[templateKey]
if present {
deprecationWarning := fmt.Sprintf("This Zarf Package uses a deprecated variable: '%s' changed to '%s'. Please notify your package creator for an update.", templateKey, vc.deprecatedKeys[templateKey])
vc.logger.Warn(deprecationWarning)
}

template := templateMap[templateKey]

// Check if the template is nil (present), use the original templateKey if not (so that it is not replaced).
Expand Down

0 comments on commit 83796fc

Please sign in to comment.