github.com/apptainer/singularity@v3.1.1+incompatible/internal/pkg/runtime/engines/config/oci/config.go (about) 1 // Copyright (c) 2018, Sylabs Inc. All rights reserved. 2 // This software is licensed under a 3-clause BSD license. Please consult the 3 // LICENSE.md file distributed with the sources of this project regarding your 4 // rights to use or distribute this software. 5 6 package oci 7 8 import ( 9 "encoding/json" 10 11 "github.com/opencontainers/runtime-spec/specs-go" 12 "github.com/opencontainers/runtime-tools/generate" 13 ) 14 15 // Config is the OCI runtime configuration. 16 type Config struct { 17 generate.Generator 18 specs.Spec 19 } 20 21 // MarshalJSON is for json.Marshaler 22 func (c *Config) MarshalJSON() ([]byte, error) { 23 b, err := json.Marshal(&c.Spec) 24 25 return b, err 26 } 27 28 // UnmarshalJSON is for json.Unmarshaler 29 func (c *Config) UnmarshalJSON(b []byte) error { 30 if err := json.Unmarshal(b, &c.Spec); err != nil { 31 return err 32 } 33 c.Generator = generate.Generator{Config: &c.Spec} 34 return nil 35 }