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

Commit

Permalink
Merge branch 'master' into pr/duffle-outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
silvin-lubecki authored Aug 9, 2019
2 parents a4c2465 + b464875 commit 08b8e84
Show file tree
Hide file tree
Showing 101 changed files with 85 additions and 21,400 deletions.
87 changes: 0 additions & 87 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
name = "github.com/spf13/cobra"
version = "0.0.3"

[[constraint]]
name = "github.com/spf13/viper"
version = "v1.2"

[[constraint]]
name = "github.com/Masterminds/semver"
version = "1.4.2"
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Duffle: The CNAB Installer
![Build Status](http://badges.technosophos.me/v1/github/build/deislabs/duffle/badge.svg?branch=master)
[![Waffle.io - Columns and their card count](https://badge.waffle.io/deislabs/duffle.svg?columns=In%20Progress,Needs%20Review,Done)](https://waffle.io/deislabs/duffle)


Duffle is the reference implementation of the [CNAB specification][cnab]. It
Expand Down
2 changes: 1 addition & 1 deletion cmd/duffle/bundle_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra"
)

const bundleActionsDesc = ` Lists all actions available in a bundle`
const bundleActionsDesc = `list all actions available in a bundle`

type bundleActionsCmd struct {
out io.Writer
Expand Down
2 changes: 1 addition & 1 deletion cmd/duffle/bundle_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func newBundleListCmd(w io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
Short: "lists bundles pulled or built and stored locally",
Short: "list bundles pulled or built and stored locally",
RunE: func(cmd *cobra.Command, args []string) error {
home := home.Home(homePath())
references, err := searchLocal(home)
Expand Down
19 changes: 9 additions & 10 deletions cmd/duffle/bundle_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"fmt"
"io"
"os"

"github.com/docker/go/canonical/json"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -58,22 +58,21 @@ func (bsc *bundleShowCmd) run() error {
return err
}

bun, err := loadBundle(bundleFile)
if err != nil {
return err
}

if bsc.raw {
f, err := os.Open(bundleFile)
if err != nil {
return err
}
defer f.Close()
_, err = io.Copy(bsc.w, f)
_, err = bun.WriteTo(bsc.w)
return err
}

bun, err := loadBundle(bundleFile)
d, err := json.MarshalIndent(bun, " ", " ")
if err != nil {
return err
}

_, err = bun.WriteTo(bsc.w)
_, err = bsc.w.Write(d)

return err
}
12 changes: 7 additions & 5 deletions cmd/duffle/install.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
Expand All @@ -16,7 +17,6 @@ import (
"github.com/deislabs/cnab-go/bundle/definition"
"github.com/deislabs/cnab-go/claim"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

const installUsage = `Installs a Cloud Native Application Bundle (CNAB)
Expand Down Expand Up @@ -218,13 +218,15 @@ func overrides(overrides []string, paramDefs definition.Definitions) (map[string
}

func parseValues(file string) (map[string]interface{}, error) {
v := viper.New()
v.SetConfigFile(file)
err := v.ReadInConfig()
vals := map[string]interface{}{}
f, err := ioutil.ReadFile(file)
if err != nil {
return nil, err
}
return v.AllSettings(), nil
if err := json.Unmarshal(f, &vals); err != nil {
return nil, err
}
return vals, nil
}

func calculateParamValues(bun *bundle.Bundle, valuesFile string, setParams, setFilePaths []string, prevVals map[string]interface{}) (map[string]interface{}, error) {
Expand Down
30 changes: 28 additions & 2 deletions docs/guides/relocation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ and

The `--repository-prefix` flag determines the repositories for the relocated images. Each image is given a name starting with the given prefix and pushed to the repository.

The `--relocation-mapping` flag is the path of a relocation mapping file which is created by the relocate command and which should be
passed to other commands (`install`, `upgrade`, `run`, and `uninstall`) when the relocated images are to be used.

For example, if the repository prefix is `example.com/user`, the image `istio/proxyv2` is relocated
to a name starting with `example.com/user/` and pushed to a repository hosted by `example.com`.

Expand Down Expand Up @@ -80,8 +83,31 @@ duffle install forge.json --bundle-is-file --relocation-mapping relmap.json ...

```

The invocation image then installs the software such that its images are loaded from the internal registry.
The invocation image is loaded from the internal registry and installs the software such that its images are also loaded from the internal registry.

### Thick Bundle Relocation

Not yet supported.
Gringotts Wizarding Bank (GWB) needs to install some software into a new coin sorting machine.
For GWB, security is paramount. Like Acme, all their production software must be loaded from internal repositories.
However, GWB regard a networked DMZ as too insecure. Their data center has no connection to the external internet.

Software is delivered to GWB encoded in Base64 and etched on large stones which are then rolled by hand into the
GWB data center, scanned, and decoded. The stones are stored for future security audits.

GWB obtains the new software as a thick bundle (`sort.tgz`) and relocates it to their private registry as follows:
```bash
duffle relocate sort.tgz --bundle-is-file --repository-prefix=registry.gold.gwb.dia/griphook --relocation-mapping relmap.json

```
This loads the images from `sort.tgz` into the private registry. Relocating from a thick bundle does not need
access to the original image repositories (which would prevent it from running inside the GWB data center).

They can now install the sorting software using the original bundle together with the relocation mapping file:
```bash
duffle install sort.tgz --bundle-is-file --relocation-mapping relmap.json ...

```

Again the invocation image is loaded from the internal registry and installs the software such that its images are also loaded from the internal registry.
Since relocation does not modify the original bundle or produce a new bundle, GWB can use the original stones in security audits.

5 changes: 3 additions & 2 deletions examples/helloazure/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"imageType": "azure-image",
"image": "duffle-dev/duffle-vm-example-0.1.1"
}
]
}
],
"schemaVersion": "v1.0.0-WD"
}
7 changes: 4 additions & 3 deletions examples/helloworld/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"invocationImages": [
{
"image": "deislabs/helloworld-cnab:675c2daf7449ae58927f251acdd88acb9d1e9767",
"imageType":"docker"
"imageType": "docker"
}
],
"keywords": [
Expand All @@ -27,5 +27,6 @@
],
"images": null,
"parameters": null,
"credentials": null
}
"credentials": null,
"schemaVersion": "v1.0.0-WD"
}
5 changes: 3 additions & 2 deletions examples/helloworld/duffle.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
}
},
"parameters": null,
"credentials": null
}
"credentials": null,
"schemaVersion": "v1.0.0-WD"
}
25 changes: 10 additions & 15 deletions pkg/duffle/manifest/load.go
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
}
Loading

0 comments on commit 08b8e84

Please sign in to comment.