Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
switch duffle.toml to duffle.json (#251)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Fisher <[email protected]>
  • Loading branch information
Matthew Fisher authored Oct 3, 2018
1 parent 9c206be commit ff9156c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 26 deletions.
3 changes: 2 additions & 1 deletion cmd/duffle/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/deis/duffle/pkg/builder/docker"
"github.com/deis/duffle/pkg/builder/mock"
"github.com/deis/duffle/pkg/cmdline"
"github.com/deis/duffle/pkg/duffle"
"github.com/deis/duffle/pkg/duffle/home"
"github.com/deis/duffle/pkg/duffle/manifest"

Expand Down Expand Up @@ -110,7 +111,7 @@ func (b *buildCmd) run() (err error) {
)
bldr.LogsDir = b.home.Logs()

mfst, err := manifest.Load(filepath.Join(b.src, "duffle.toml"))
mfst, err := manifest.Load(filepath.Join(b.src, duffle.DuffleFilepath))
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/duffle/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"testing"

"github.com/deis/duffle/pkg/duffle"
"github.com/deis/duffle/pkg/duffle/home"
)

Expand All @@ -27,12 +28,12 @@ func TestBuild(t *testing.T) {
if err := os.MkdirAll(filepath.Join(testBundlePath, "cnab"), 0755); err != nil {
t.Fatal(err)
}
from, err := os.Open(filepath.Join("testdata", "testbundle", "duffle.toml"))
from, err := os.Open(filepath.Join("testdata", "testbundle", duffle.DuffleFilepath))
if err != nil {
t.Fatal(err)
}
defer from.Close()
dest := filepath.Join(testBundlePath, "duffle.toml")
dest := filepath.Join(testBundlePath, duffle.DuffleFilepath)
to, err := os.OpenFile(dest, os.O_RDWR|os.O_CREATE, 0600)
if err != nil {
t.Fatal(err)
Expand Down
3 changes: 3 additions & 0 deletions cmd/duffle/testdata/testbundle/duffle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "testbundle"
}
3 changes: 0 additions & 3 deletions cmd/duffle/testdata/testbundle/duffle.toml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/203-duffle-build.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Duffle Build

This document describes how `duffle build` works, and how it uses `duffle.toml`.
This document describes how `duffle build` works, and how it uses `duffle.json`.
8 changes: 4 additions & 4 deletions pkg/duffle/create.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package duffle

const (
// DuffleTomlFilename is the default filename for Duffle application configuration.
DuffleTomlFilename = "duffle.toml"
// DuffleTomlFilepath is the relative path from the root of an application directory to duffle.toml
DuffleTomlFilepath = "duffle.toml"
// DuffleFilename is the default filename for Duffle application configuration.
DuffleFilename = "duffle.json"
// DuffleFilepath is the relative path from the root of an application directory to duffle.json
DuffleFilepath = DuffleFilename
)
5 changes: 0 additions & 5 deletions pkg/duffle/home/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ func (h Home) Path(elem ...string) string {
return filepath.Join(p...)
}

// Config returns the path to the Duffle config file.
func (h Home) Config() string {
return h.Path("config.toml")
}

// Repositories returns the path to the Duffle repositories.
func (h Home) Repositories() string {
return h.Path("repositories")
Expand Down
10 changes: 8 additions & 2 deletions pkg/duffle/manifest/load.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package manifest

import (
"github.com/BurntSushi/toml"
"encoding/json"
"os"
)

// Load opens the named file for reading. If successful, the manifest is returned.
func Load(name string) (*Manifest, error) {
mfst := New()
if _, err := toml.DecodeFile(name, mfst); err != nil {
f, err := os.Open(name)
if err != nil {
return nil, err
}
defer f.Close()
if err := json.NewDecoder(f).Decode(&mfst); err != nil {
return nil, err
}
return mfst, nil
Expand Down
16 changes: 8 additions & 8 deletions pkg/duffle/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import (
"github.com/technosophos/moniker"
)

// Manifest represents a duffle.toml
// Manifest represents a duffle manifest.
type Manifest struct {
Name string `toml:"name,omitempty"`
Components map[string]*Component `toml:"components,omitempty"`
Parameters map[string]bundle.ParameterDefinition `toml:"parameters,omitempty"`
Credentials map[string]bundle.CredentialLocation `toml:"credentials,omitempty"`
Name string `json:"name,omitempty"`
Components map[string]*Component `json:"components,omitempty"`
Parameters map[string]bundle.ParameterDefinition `json:"parameters,omitempty"`
Credentials map[string]bundle.CredentialLocation `json:"credentials,omitempty"`
}

// Component represents a component of a CNAB bundle
type Component struct {
Name string `toml:"name,omitempty"`
Builder string `toml:"builder,omitempty"`
Configuration map[string]string `toml:"configuration,omitempty"`
Name string `json:"name,omitempty"`
Builder string `json:"builder,omitempty"`
Configuration map[string]string `json:"configuration,omitempty"`
}

// New creates a new manifest with the Environments intialized.
Expand Down

0 comments on commit ff9156c

Please sign in to comment.