Return unmodified runtime if specModifier is nil

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2022-04-08 07:38:19 +02:00
parent 99baea9d51
commit 67602b28f9
3 changed files with 55 additions and 6 deletions

View File

@@ -33,8 +33,13 @@ type modifyingRuntimeWrapper struct {
var _ oci.Runtime = (*modifyingRuntimeWrapper)(nil)
// NewModifyingRuntimeWrapper creates a runtime wrapper that applies the specified modifier to the OCI specification
// before invoking the wrapped runtime.
// before invoking the wrapped runtime. If the modifier is nil, the input runtime is returned.
func NewModifyingRuntimeWrapper(logger *log.Logger, runtime oci.Runtime, spec oci.Spec, modifier oci.SpecModifier) oci.Runtime {
if modifier == nil {
logger.Infof("Using low-level runtime with no modification")
return runtime
}
rt := modifyingRuntimeWrapper{
logger: logger,
runtime: runtime,