Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playground: Plugin Library #2216

Draft
wants to merge 4 commits into
base: release/v1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 29 additions & 45 deletions cmd/porter/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"strings"

"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -30,126 +31,110 @@ func buildAliasCommands(p *porter.Porter) []*cobra.Command {
func buildCreateAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleCreateCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle create", "porter create", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")
return cmd
}

func buildBuildAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleBuildCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle build", "porter build", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")
return cmd
}

func buildLintAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleLintCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle lint", "porter lint", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildInstallAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleInstallCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle install", "porter install", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildUpgradeAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleUpgradeCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle upgrade", "porter upgrade", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildInvokeAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleInvokeCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle invoke", "porter invoke", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildUninstallAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleUninstallCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle uninstall", "porter uninstall", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildPublishAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundlePublishCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle publish", "porter publish", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildShowAlias(p *porter.Porter) *cobra.Command {
cmd := buildInstallationShowCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter installation show", "porter show", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildListAlias(p *porter.Porter) *cobra.Command {
cmd := buildInstallationsListCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter installations list", "porter list", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildArchiveAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleArchiveCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle archive", "porter archive", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildExplainAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleExplainCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle explain", "porter explain", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildCopyAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleCopyCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle copy", "porter copy", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

func buildInspectAlias(p *porter.Porter) *cobra.Command {
cmd := buildBundleInspectCommand(p)
cmd.Example = strings.Replace(cmd.Example, "porter bundle inspect", "porter inspect", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}

Expand All @@ -158,8 +143,7 @@ func buildLogsAlias(p *porter.Porter) *cobra.Command {
cmd.Use = "logs"
cmd.Aliases = []string{"log"}
cmd.Example = strings.Replace(cmd.Example, "porter installation logs show", "porter logs", -1)
cmd.Annotations = map[string]string{
"group": "alias",
}
cli.SetCommandGroup(cmd, "alias")

return cmd
}
5 changes: 2 additions & 3 deletions cmd/porter/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
)
Expand All @@ -15,9 +16,7 @@ func buildBundleCommands(p *porter.Porter) *cobra.Command {
Short: "Bundle commands",
Long: "Commands for working with bundles. These all have shortcuts so that you can call these commands without the bundle resource prefix. For example, porter bundle install is available as porter install as well.",
}
cmd.Annotations = map[string]string{
"group": "resource",
}
cli.SetCommandGroup(cmd, "resource")

cmd.AddCommand(buildBundleCreateCommand(p))
cmd.AddCommand(buildBundleBuildCommand(p))
Expand Down
8 changes: 4 additions & 4 deletions cmd/porter/completion.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -29,9 +30,8 @@ For additional details see: https://porter.sh/install#command-completion`,
}
},
}
cmd.Annotations = map[string]string{
"group": "meta",
skipConfig: "",
}
cli.SetCommandGroup(cmd, "meta")
cli.SkipConfigForCommand(cmd)

return cmd
}
3 changes: 2 additions & 1 deletion cmd/porter/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"testing"

"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/porter"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -29,6 +30,6 @@ func TestCompletion(t *testing.T) {
func TestCompletion_SkipConfig(t *testing.T) {
p := porter.NewTestPorter(t)
cmd := buildCompletionCommand(p.Porter)
shouldSkip := shouldSkipConfig(cmd)
shouldSkip := cli.ShouldSkipConfig(cmd)
require.True(t, shouldSkip, "expected that we skip loading configuration for the completion command")
}
9 changes: 5 additions & 4 deletions cmd/porter/credentials.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package main

import (
"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
)

func buildCredentialsCommands(p *porter.Porter) *cobra.Command {
cmd := &cobra.Command{
Use: "credentials",
Aliases: []string{"credential", "cred", "creds"},
Annotations: map[string]string{"group": "resource"},
Short: "Credentials commands",
Use: "credentials",
Aliases: []string{"credential", "cred", "creds"},
Short: "Credentials commands",
}
cli.SetCommandGroup(cmd, "resource")

cmd.AddCommand(buildCredentialsApplyCommand(p))
cmd.AddCommand(buildCredentialsEditCommand(p))
Expand Down
7 changes: 3 additions & 4 deletions cmd/porter/docs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/docs"
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
Expand All @@ -23,10 +24,8 @@ func buildDocsCommand(p *porter.Porter) *cobra.Command {
},
}

cmd.Annotations = map[string]string{
"group": "meta",
skipConfig: "",
}
cli.SkipConfigForCommand(cmd)
cli.SetCommandGroup(cmd, "meta")

flags := cmd.Flags()
flags.StringVarP(&opts.Destination, "dest", "d", docs.DefaultDestination,
Expand Down
5 changes: 2 additions & 3 deletions cmd/porter/installations.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
)
Expand All @@ -12,9 +13,7 @@ func buildInstallationCommands(p *porter.Porter) *cobra.Command {
Short: "Installation commands",
Long: "Commands for working with installations of a bundle",
}
cmd.Annotations = map[string]string{
"group": "resource",
}
cli.SetCommandGroup(cmd, "resource")

cmd.AddCommand(buildInstallationsListCommand(p))
cmd.AddCommand(buildInstallationShowCommand(p))
Expand Down
5 changes: 2 additions & 3 deletions cmd/porter/logs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"get.porter.sh/porter/pkg/cli"
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
)
Expand All @@ -12,9 +13,7 @@ func buildInstallationLogCommands(p *porter.Porter) *cobra.Command {
Short: "Installation Logs commands",
Long: "Commands for working with installation logs",
}
cmd.Annotations = map[string]string{
"group": "resource",
}
cli.SetCommandGroup(cmd, "resource")

cmd.AddCommand(buildInstallationLogShowCommand(p))

Expand Down
Loading