This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #818 from glyn/817-allow-arbitrary-image-names
Replace viper with standard JSON decoding
- Loading branch information
Showing
93 changed files
with
36 additions
and
21,378 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
package manifest | ||
|
||
import ( | ||
"fmt" | ||
"encoding/json" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/spf13/viper" | ||
|
||
"github.com/deislabs/duffle/pkg/duffle" | ||
) | ||
|
||
// Load opens the named file for reading. If successful, the manifest is returned. | ||
// Load parses the named file into a manifest. | ||
func Load(name, dir string) (*Manifest, error) { | ||
v := viper.New() | ||
if name == "" { | ||
v.SetConfigName(duffle.DuffleFilename) | ||
} else { | ||
v.SetConfigFile(filepath.Join(dir, name)) | ||
name = duffle.DuffleFilename + ".json" | ||
} | ||
v.AddConfigPath(dir) | ||
err := v.ReadInConfig() | ||
f, err := os.Open(filepath.Join(dir, name)) | ||
if err != nil { | ||
return nil, fmt.Errorf("Error finding duffle config file: %s", err) | ||
return nil, err | ||
} | ||
|
||
m := New() | ||
err = v.Unmarshal(m) | ||
if err != nil { | ||
manifest := New() | ||
if err := json.NewDecoder(f).Decode(&manifest); err != nil { | ||
return nil, err | ||
} | ||
return m, nil | ||
|
||
return manifest, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.