diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-08-31 11:29:36 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-31 11:30:47 -0700 |
commit | 7e18f158b2ea87b7f06f8e0b91e10558b4f52722 (patch) | |
tree | f73958dd5cc7525d5717e878975791fde08e8899 /runsc/specutils | |
parent | be9f454eb6e456fb1acf084612f363aa959ef9d9 (diff) |
Automated rollback of changelist 210995199
PiperOrigin-RevId: 211116429
Change-Id: I446d149c822177dc9fc3c64ce5e455f7f029aa82
Diffstat (limited to 'runsc/specutils')
-rw-r--r-- | runsc/specutils/specutils.go | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/runsc/specutils/specutils.go b/runsc/specutils/specutils.go index 477409112..5fb53edb2 100644 --- a/runsc/specutils/specutils.go +++ b/runsc/specutils/specutils.go @@ -108,24 +108,14 @@ func ValidateSpec(spec *specs.Spec) error { // ReadSpec reads an OCI runtime spec from the given bundle directory. func ReadSpec(bundleDir string) (*specs.Spec, error) { // The spec file must be in "config.json" inside the bundle directory. - specPath := filepath.Join(bundleDir, "config.json") - specFile, err := os.Open(specPath) + specFile := filepath.Join(bundleDir, "config.json") + specBytes, err := ioutil.ReadFile(specFile) if err != nil { - return nil, fmt.Errorf("error opening spec file %q: %v", specPath, err) - } - defer specFile.Close() - return ReadSpecFromFile(specFile) -} - -// ReadSpecFromFile reads an OCI runtime spec from the given File. -func ReadSpecFromFile(specFile *os.File) (*specs.Spec, error) { - specBytes, err := ioutil.ReadAll(specFile) - if err != nil { - return nil, fmt.Errorf("error reading spec from file %q: %v", specFile.Name(), err) + return nil, fmt.Errorf("error reading spec from file %q: %v", specFile, err) } var spec specs.Spec if err := json.Unmarshal(specBytes, &spec); err != nil { - return nil, fmt.Errorf("error unmarshaling spec from file %q: %v\n %s", specFile.Name(), err, string(specBytes)) + return nil, fmt.Errorf("error unmarshaling spec from file %q: %v\n %s", specFile, err, string(specBytes)) } if err := ValidateSpec(&spec); err != nil { return nil, err @@ -356,11 +346,3 @@ func WaitForReady(pid int, timeout time.Duration, ready func() (bool, error)) er } return backoff.Retry(op, b) } - -// DebugLogFile opens a file in logDir based on the timestamp and subcommand -// for writing. -func DebugLogFile(logDir, subcommand string) (*os.File, error) { - // Format: <debug-log-dir>/runsc.log.<yyyymmdd-hhmmss.uuuuuu>.<command> - filename := fmt.Sprintf("runsc.log.%s.%s", time.Now().Format("20060102-150405.000000"), subcommand) - return os.OpenFile(filepath.Join(logDir, filename), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0664) -} |