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

chore: deprecate DeprecatedKeys #2581

Merged
merged 1 commit into from
Jun 5, 2024
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
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 @@
// 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 @@
}

// 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 {

Check warning on line 24 in src/pkg/variables/common.go

View check run for this annotation

Codecov / codecov/patch

src/pkg/variables/common.go#L24

Added line #L24 was not covered by tests
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
Loading