-
Notifications
You must be signed in to change notification settings - Fork 206
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 #588 from carolynvs/mixin-versions
Include mixin version in porter mixins list output
- Loading branch information
Showing
22 changed files
with
444 additions
and
137 deletions.
There are no files selected for viewing
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
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,11 +1,19 @@ | ||
package exec | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/deislabs/porter/pkg" | ||
"github.com/deislabs/porter/pkg/mixin" | ||
"github.com/deislabs/porter/pkg/porter/version" | ||
) | ||
|
||
func (m *Mixin) PrintVersion() { | ||
fmt.Fprintf(m.Out, "exec mixin %s (%s)\n", pkg.Version, pkg.Commit) | ||
func (m *Mixin) PrintVersion(opts version.Options) error { | ||
metadata := mixin.Metadata{ | ||
Name: "exec", | ||
VersionInfo: mixin.VersionInfo{ | ||
Version: pkg.Version, | ||
Commit: pkg.Commit, | ||
Author: "DeisLabs", | ||
}, | ||
} | ||
return version.PrintVersion(m.Context, opts, metadata) | ||
} |
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,11 +1,19 @@ | ||
package kubernetes | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/deislabs/porter/pkg" | ||
"github.com/deislabs/porter/pkg/mixin" | ||
"github.com/deislabs/porter/pkg/porter/version" | ||
) | ||
|
||
func (m *Mixin) PrintVersion() { | ||
fmt.Fprintf(m.Out, "kubernetes mixin %s (%s)\n", pkg.Version, pkg.Commit) | ||
func (m *Mixin) PrintVersion(opts version.Options) error { | ||
metadata := mixin.Metadata{ | ||
Name: "kubernetes", | ||
VersionInfo: mixin.VersionInfo{ | ||
Version: pkg.Version, | ||
Commit: pkg.Commit, | ||
Author: "DeisLabs", | ||
}, | ||
} | ||
return version.PrintVersion(m.Context, opts, metadata) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package kubernetes | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/deislabs/porter/pkg/printer" | ||
|
||
"github.com/deislabs/porter/pkg/porter/version" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/deislabs/porter/pkg" | ||
) | ||
|
||
func TestPrintVersion(t *testing.T) { | ||
pkg.Commit = "abc123" | ||
pkg.Version = "v1.2.3" | ||
|
||
m := NewTestMixin(t) | ||
|
||
opts := version.Options{} | ||
err := opts.Validate() | ||
require.NoError(t, err) | ||
m.PrintVersion(opts) | ||
|
||
gotOutput := m.TestContext.GetOutput() | ||
wantOutput := "kubernetes v1.2.3 (abc123) by DeisLabs" | ||
if !strings.Contains(gotOutput, wantOutput) { | ||
t.Fatalf("invalid output:\nWANT:\t%q\nGOT:\t%q\n", wantOutput, gotOutput) | ||
} | ||
} | ||
|
||
func TestPrintJsonVersion(t *testing.T) { | ||
pkg.Commit = "abc123" | ||
pkg.Version = "v1.2.3" | ||
|
||
m := NewTestMixin(t) | ||
|
||
opts := version.Options{} | ||
opts.RawFormat = string(printer.FormatJson) | ||
err := opts.Validate() | ||
require.NoError(t, err) | ||
m.PrintVersion(opts) | ||
|
||
gotOutput := m.TestContext.GetOutput() | ||
wantOutput := `{ | ||
"name": "kubernetes", | ||
"version": "v1.2.3", | ||
"commit": "abc123", | ||
"author": "DeisLabs" | ||
} | ||
` | ||
if !strings.Contains(gotOutput, wantOutput) { | ||
t.Fatalf("invalid output:\nWANT:\t%q\nGOT:\t%q\n", wantOutput, gotOutput) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package mixin | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/deislabs/porter/pkg/test" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
test.TestMainWithMockedCommandHandlers(m) | ||
} |
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,16 +1,20 @@ | ||
package mixin | ||
|
||
// Metadata about a mixin | ||
// Metadata about an installed mixin. | ||
type Metadata struct { | ||
// Mixin Name | ||
Name string | ||
Name string `json:"name"` | ||
// Mixin Directory | ||
Dir string | ||
Dir string `json:"dir,omitempty"` | ||
// Path to the client executable | ||
ClientPath string | ||
// Version | ||
// Repository or Source (where did it come from) | ||
// Author | ||
// Is it up to date | ||
// etc | ||
ClientPath string `json:"clientPath,omitempty"` | ||
// Metadata about the mixin version returned from calling version on the mixin | ||
VersionInfo | ||
} | ||
|
||
// Information from running the version command against the mixin. | ||
type VersionInfo struct { | ||
Version string `json:"version"` | ||
Commit string `json:"commit"` | ||
Author string `json:"author,omitempty"` | ||
} |
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
Oops, something went wrong.