Skip to content

Commit

Permalink
Skelletor the install command
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynvs-msft committed Mar 18, 2019
1 parent c694652 commit a0a908f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cmd/porter/bundle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"github.com/deislabs/porter/pkg/porter"
"github.com/spf13/cobra"
)

func buildBundleCommands(p *porter.Porter) *cobra.Command {
cmd := &cobra.Command{
Use: "bundle",
Short: "bundle commands",
}

cmd.AddCommand(buildBundleInstallCommand(p))

return cmd
}

func buildBundleInstallCommand(p *porter.Porter) *cobra.Command {
opts := porter.InstallOptions{}
cmd := &cobra.Command{
Use: "install",
Short: "Install a bundle",
RunE: func(cmd *cobra.Command, args []string) error {
return p.InstallBundle(opts)
},
}

cmd.Flags().BoolVar(&opts.Insecure, "insecure", false, "Allow installing unsigned bundles, or bundles signed by untrusted publishers")
return cmd
}

func buildInstallCommand(p *porter.Porter) *cobra.Command {
return buildBundleInstallCommand(p)
}
2 changes: 2 additions & 0 deletions cmd/porter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func buildRootCommand() *cobra.Command {
cmd.AddCommand(buildCreateCommand(p))
cmd.AddCommand(buildRunCommand(p))
cmd.AddCommand(buildBuildCommand(p))
cmd.AddCommand(buildBundleCommands(p))
cmd.AddCommand(buildInstallCommand(p))
cmd.AddCommand(buildListCommands(p))

return cmd
Expand Down
31 changes: 31 additions & 0 deletions cmd/porter/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func TestCommandWiring(t *testing.T) {
testcases := []string{
"build",
"create",
"install",
"run",
"schema",
"bundle install",
"list mixins",
"version",
}

for _, tc := range testcases {
t.Run(tc, func(t *testing.T) {
osargs := strings.Split(tc, " ")

rootCmd := buildRootCommand()
_, _, err := rootCmd.Find(osargs)
assert.NoError(t, err)
})
}
}
16 changes: 16 additions & 0 deletions pkg/porter/install.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package porter

import "fmt"

type InstallOptions struct {
Insecure bool
}

func (p *Porter) InstallBundle(opts InstallOptions) error {
err := p.Config.LoadManifest()
if err != nil {
return err
}
fmt.Fprintf(p.Out, "installing %s...\n", p.Manifest.Name)
return nil
}

0 comments on commit a0a908f

Please sign in to comment.