runtime-tools
runtime-tools copied to clipboard
NewFromSpec is deprecated, but required to avoid addEnv panic from nil envMap
The addition of Generator.envMap and its use for caching env vars requires it to be non-nil, or a call to AddProcessEnv() will panic within addEnv() at:
https://github.com/opencontainers/runtime-tools/blob/59cdde06764be8d761db120664020f0415f36045/generate/generate.go#L532
envMap is initialized in New() or NewFromSpec(). However, NewFromSpec() is marked deprecated:
// NewFromSpec creates a configuration Generator from a given
// configuration.
//
// Deprecated: Replace with:
//
// generator := Generator{Config: config}
The replacement of creating the Generator struct directly will not initialize envMap, so a panic is possible.
Possibly use of envMap should be protected in case it is nil, and/or the non-deprecated method of creating with a config should permit initializing it?