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