Skip to content

Commit 995dd42

Browse files
authored
Merge pull request #3852 from buildkite/remove-deprecated-plugin-env-vars
Remove deprecated plugin env vars
2 parents 008d6d4 + 43d4323 commit 995dd42

5 files changed

Lines changed: 1 addition & 294 deletions

File tree

agent/plugin/error.go

Lines changed: 0 additions & 119 deletions
This file was deleted.

agent/plugin/error_test.go

Lines changed: 0 additions & 116 deletions
This file was deleted.

agent/plugin/plugin.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -266,33 +266,6 @@ func flattenConfigToEnvMap(into map[string]string, v any, envPrefix string) erro
266266
}
267267
}
268268

269-
// addDeprecatedEnvVarAliases provides backward compatibility for environment variable names.
270-
//
271-
// Before v3.48.0 (https://github.com/buildkite/agent/pull/2116), consecutive underscores in
272-
// derived env var names were collapsed (e.g., "some--key__name" → SOME_KEY_NAME).
273-
// Since v3.48.0, consecutive underscores are preserved (e.g., SOME__KEY__NAME).
274-
//
275-
// For compatibility, this function adds the collapsed form for any key containing consecutive
276-
// underscores and returns deprecation errors listing the affected variables.
277-
func addDeprecatedEnvVarAliases(envMap map[string]string) error {
278-
var errs *DeprecatedNameErrors
279-
for k, v := range envMap {
280-
// the form with consecutive underscores is replacing the form without, but the replacement
281-
// is what is expected to be in input map
282-
withoutConsecutiveUnderscores := consecutiveUnderscoreRE.ReplaceAllString(k, "_")
283-
if k != withoutConsecutiveUnderscores {
284-
envMap[withoutConsecutiveUnderscores] = v
285-
errs = errs.Append(DeprecatedNameError{old: withoutConsecutiveUnderscores, new: k})
286-
}
287-
}
288-
289-
if !errs.IsEmpty() {
290-
return errs
291-
}
292-
293-
return nil
294-
}
295-
296269
// ConfigurationToEnvironment converts the plugin configuration values to environment variables.
297270
func (p *Plugin) ConfigurationToEnvironment() (*env.Environment, error) {
298271
configJSON, err := json.Marshal(p.Configuration)
@@ -309,7 +282,6 @@ func (p *Plugin) ConfigurationToEnvironment() (*env.Environment, error) {
309282
return env.New(), err
310283
}
311284

312-
err = addDeprecatedEnvVarAliases(envMap)
313285
return env.FromMap(envMap), err
314286
}
315287

agent/plugin/plugin_test.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -400,37 +400,18 @@ func TestConfigurationToEnvironment(t *testing.T) {
400400
configJSON: `{ "and _ with a - number": 12 }`,
401401
wantEnvMap: map[string]string{
402402
"BUILDKITE_PLUGIN_CONFIGURATION": `{"and _ with a - number":12}`,
403-
"BUILDKITE_PLUGIN_DOCKER_COMPOSE_AND_WITH_A_NUMBER": "12",
404403
"BUILDKITE_PLUGIN_DOCKER_COMPOSE_AND___WITH_A______NUMBER": "12",
405404
"BUILDKITE_PLUGIN_NAME": "DOCKER_COMPOSE",
406405
},
407-
expectedErr: (&DeprecatedNameErrors{}).Append(
408-
DeprecatedNameError{
409-
old: "BUILDKITE_PLUGIN_DOCKER_COMPOSE_AND_WITH_A_NUMBER",
410-
new: "BUILDKITE_PLUGIN_DOCKER_COMPOSE_AND___WITH_A______NUMBER",
411-
},
412-
),
413406
},
414407
{
415408
configJSON: `{ "and _ with a - number": 12, "A - B": 13 }`,
416409
wantEnvMap: map[string]string{
417410
"BUILDKITE_PLUGIN_CONFIGURATION": `{"A - B":13,"and _ with a - number":12}`,
418-
"BUILDKITE_PLUGIN_DOCKER_COMPOSE_AND_WITH_A_NUMBER": "12",
419411
"BUILDKITE_PLUGIN_DOCKER_COMPOSE_AND___WITH_A______NUMBER": "12",
420-
"BUILDKITE_PLUGIN_DOCKER_COMPOSE_A_B": "13",
421412
"BUILDKITE_PLUGIN_DOCKER_COMPOSE_A___B": "13",
422413
"BUILDKITE_PLUGIN_NAME": "DOCKER_COMPOSE",
423414
},
424-
expectedErr: (&DeprecatedNameErrors{}).Append(
425-
DeprecatedNameError{
426-
old: "BUILDKITE_PLUGIN_DOCKER_COMPOSE_AND_WITH_A_NUMBER",
427-
new: "BUILDKITE_PLUGIN_DOCKER_COMPOSE_AND___WITH_A______NUMBER",
428-
},
429-
DeprecatedNameError{
430-
old: "BUILDKITE_PLUGIN_DOCKER_COMPOSE_A_B",
431-
new: "BUILDKITE_PLUGIN_DOCKER_COMPOSE_A___B",
432-
},
433-
),
434415
},
435416
{
436417
configJSON: `{ "bool-true-key": true, "bool-false-key": false }`,

internal/job/plugin.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,7 @@ func (e *Executor) executePluginHook(ctx context.Context, name string, checkouts
255255
hookTypeSeen[name] = true
256256

257257
envMap, err := p.ConfigurationToEnvironment()
258-
if dnerr := (&plugin.DeprecatedNameErrors{}); errors.As(err, &dnerr) {
259-
e.shell.Headerf("Deprecated environment variables for plugin %s", p.Plugin.Name())
260-
e.shell.Printf("%s", strings.Join([]string{
261-
"The way that environment variables are derived from the plugin configuration is changing.",
262-
"We'll export both the deprecated and the replacement names for now,",
263-
"You may be able to avoid this by removing consecutive underscore, hyphen, or whitespace",
264-
"characters in your plugin configuration.",
265-
}, " "))
266-
for _, err := range dnerr.Unwrap() {
267-
e.shell.Printf("%s", err.Error())
268-
}
269-
} else if err != nil {
258+
if err != nil {
270259
e.shell.Warningf("Error configuring plugin environment: %s", err)
271260
}
272261

0 commit comments

Comments
 (0)