Skip to content

Commit

Permalink
Merge 9e1e28a into dcd786d
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm authored Feb 5, 2019
2 parents dcd786d + 9e1e28a commit e96682a
Show file tree
Hide file tree
Showing 999 changed files with 284,309 additions and 10,940 deletions.
23 changes: 23 additions & 0 deletions cmd/odo/odo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ import (
"github.com/redhat-developer/odo/pkg/odo/cli/version"
"github.com/redhat-developer/odo/pkg/odo/util"
"github.com/redhat-developer/odo/pkg/odo/util/completion"
"github.com/redhat-developer/odo/pkg/plugin"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"os"
"path/filepath"
"strings"
)

func main() {
loadPlugins()
defer plugin.CleanPlugins()

// create the complete command
root := cli.NewCmdOdo(cli.OdoRecommendedName, cli.OdoRecommendedName)
rootCmp := createCompletion(root)
Expand Down Expand Up @@ -112,3 +118,20 @@ func createCompletion(root *cobra.Command) complete.Command {

return rootCmp
}

func loadPlugins() {
configDir, err := config.GetPluginsDir()
if err != nil {
panic(err)
}

err = filepath.Walk(configDir, func(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(path, ".listener.odo") {
plugin.InitPluginAt(path)
}
return nil
})
if err != nil {
panic(err)
}
}
66 changes: 62 additions & 4 deletions glide.lock

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

6 changes: 6 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ import:
version: v1.1.2
- package: github.com/gobwas/glob
version: e7a84e9525fe90abcda167b604e483cc959ad4aa
- package: github.com/metacosm/odo-event-api
version: go-plugin
- package: google.golang.org/grpc
version: ^1.12.0
- package: golang.org/x/sys
version: master
- package: github.com/openshift/origin
version: v3.11.0
subpackages:
Expand Down
29 changes: 29 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,35 @@ type ConfigInfo struct {
Config
}

func GetConfigDir() (string, error) {
currentUser, err := user.Current()
if err != nil {
return "", err
}

configDir := filepath.Join(currentUser.HomeDir, ".odo")

// Check whether directory present or not
_, err = os.Stat(filepath.Dir(configDir))
if os.IsNotExist(err) {
err = os.MkdirAll(filepath.Dir(configDir), 0755)
if err != nil {
return "", err
}
}

return configDir, nil
}

func GetPluginsDir() (string, error) {
configDir, err := GetConfigDir()
if err != nil {
return "", err
}

return filepath.Join(configDir, "plugins"), nil
}

func getDefaultConfigFile() string {
currentUser, err := user.Current()
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions pkg/odo/cli/catalog/describe/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
odoutil "github.com/redhat-developer/odo/pkg/odo/util"
svc "github.com/redhat-developer/odo/pkg/service"
"github.com/spf13/cobra"
ktemplates "k8s.io/kubernetes/pkg/kubectl/cmd/templates"
Expand Down Expand Up @@ -136,9 +135,7 @@ func NewCmdCatalogDescribeService(name, fullName string) *cobra.Command {
Example: fmt.Sprintf(serviceExample, fullName),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
odoutil.LogErrorAndExit(o.Complete(name, cmd, args), "")
odoutil.LogErrorAndExit(o.Validate(), "")
odoutil.LogErrorAndExit(o.Run(), "")
genericclioptions.GenericRun(o, cmd, args)
},
}

Expand Down
5 changes: 1 addition & 4 deletions pkg/odo/cli/catalog/list/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/redhat-developer/odo/pkg/catalog"
"github.com/redhat-developer/odo/pkg/odo/cli/catalog/util"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
odoutil "github.com/redhat-developer/odo/pkg/odo/util"
"github.com/spf13/cobra"
"os"
"strings"
Expand Down Expand Up @@ -86,9 +85,7 @@ func NewCmdCatalogListComponents(name, fullName string) *cobra.Command {
Long: "List all available component types from OpenShift's Image Builder.",
Example: fmt.Sprintf(componentsExample, fullName),
Run: func(cmd *cobra.Command, args []string) {
odoutil.LogErrorAndExit(o.Complete(name, cmd, args), "")
odoutil.LogErrorAndExit(o.Validate(), "")
odoutil.LogErrorAndExit(o.Run(), "")
genericclioptions.GenericRun(o, cmd, args)
},
}

Expand Down
5 changes: 1 addition & 4 deletions pkg/odo/cli/catalog/list/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/redhat-developer/odo/pkg/occlient"
"github.com/redhat-developer/odo/pkg/odo/cli/catalog/util"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
odoutil "github.com/redhat-developer/odo/pkg/odo/util"
svc "github.com/redhat-developer/odo/pkg/service"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -64,9 +63,7 @@ func NewCmdCatalogListServices(name, fullName string) *cobra.Command {
Example: fmt.Sprintf(servicesExample, fullName),
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
odoutil.LogErrorAndExit(o.Complete(name, cmd, args), "")
odoutil.LogErrorAndExit(o.Validate(), "")
odoutil.LogErrorAndExit(o.Run(), "")
genericclioptions.GenericRun(o, cmd, args)
},
}
}
5 changes: 1 addition & 4 deletions pkg/odo/cli/catalog/search/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/redhat-developer/odo/pkg/catalog"
"github.com/redhat-developer/odo/pkg/log"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
odoutil "github.com/redhat-developer/odo/pkg/odo/util"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -68,9 +67,7 @@ components.
Args: cobra.ExactArgs(1),
Example: fmt.Sprintf(componentExample, fullName),
Run: func(cmd *cobra.Command, args []string) {
odoutil.LogErrorAndExit(o.Complete(name, cmd, args), "")
odoutil.LogErrorAndExit(o.Validate(), "")
odoutil.LogErrorAndExit(o.Run(), "")
genericclioptions.GenericRun(o, cmd, args)
},
}
}
5 changes: 1 addition & 4 deletions pkg/odo/cli/catalog/search/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/redhat-developer/odo/pkg/occlient"
"github.com/redhat-developer/odo/pkg/odo/cli/catalog/util"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
odoutil "github.com/redhat-developer/odo/pkg/odo/util"
svc "github.com/redhat-developer/odo/pkg/service"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -71,9 +70,7 @@ services from service catalog.
Example: fmt.Sprintf(serviceExample, fullName),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
odoutil.LogErrorAndExit(o.Complete(name, cmd, args), "")
odoutil.LogErrorAndExit(o.Validate(), "")
odoutil.LogErrorAndExit(o.Run(), "")
genericclioptions.GenericRun(o, cmd, args)
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/odo/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cli
import (
"flag"
"fmt"

"github.com/redhat-developer/odo/pkg/odo/cli/application"
"github.com/redhat-developer/odo/pkg/odo/cli/catalog"
"github.com/redhat-developer/odo/pkg/odo/cli/component"
Expand Down Expand Up @@ -78,6 +77,7 @@ func NewCmdOdo(name, fullName string) *cobra.Command {
Long: odoLong,
Example: fmt.Sprintf(odoExample, fullName),
}

// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
Expand Down
2 changes: 1 addition & 1 deletion pkg/odo/cli/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewCmdComponent(name, fullName string) *cobra.Command {
// 'odo component' is the same as 'odo component get'
// 'odo component <component_name>' is the same as 'odo component set <component_name>'
Run: func(cmd *cobra.Command, args []string) {
if len(args) > 0 && args[0] != "get" && args[0] != "set" {
if len(args) > 0 && args[0] != RecommendedGetCommandName && args[0] != RecommendedSetCommandName {
componentSetCmd.Run(cmd, args)
} else {
componentGetCmd.Run(cmd, args)
Expand Down
4 changes: 1 addition & 3 deletions pkg/odo/cli/component/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,7 @@ func NewCmdCreate(name, fullName string) *cobra.Command {
Example: fmt.Sprintf(createExample, fullName),
Args: cobra.RangeArgs(1, 2),
Run: func(cmd *cobra.Command, args []string) {
odoutil.LogErrorAndExit(co.Complete(name, cmd, args), "")
odoutil.LogErrorAndExit(co.Validate(), "")
odoutil.LogErrorAndExit(co.Run(), "")
genericclioptions.GenericRun(co, cmd, args)
},
}
componentCreateCmd.Flags().StringVarP(&co.componentBinary, "binary", "b", "", "Use a binary as the source file for the component")
Expand Down
5 changes: 2 additions & 3 deletions pkg/odo/cli/component/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package component

import (
"fmt"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -104,9 +105,7 @@ func NewCmdDelete(name, fullName string) *cobra.Command {
Example: fmt.Sprintf(deleteExample, fullName),
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
odoutil.LogErrorAndExit(do.Complete(name, cmd, args), "")
odoutil.LogErrorAndExit(do.Validate(), "")
odoutil.LogErrorAndExit(do.Run(), "")
genericclioptions.GenericRun(do, cmd, args)
},
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/odo/cli/component/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package component

import (
"fmt"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"

"encoding/json"

Expand Down Expand Up @@ -123,9 +124,7 @@ func NewCmdDescribe(name, fullName string) *cobra.Command {
Example: fmt.Sprintf(describeExample, fullName),
Args: cobra.RangeArgs(0, 1),
Run: func(cmd *cobra.Command, args []string) {
odoutil.LogErrorAndExit(do.Complete(name, cmd, args), "")
odoutil.LogErrorAndExit(do.Validate(), "")
odoutil.LogErrorAndExit(do.Run(), "")
genericclioptions.GenericRun(do, cmd, args)
},
}

Expand Down
5 changes: 1 addition & 4 deletions pkg/odo/cli/component/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
appCmd "github.com/redhat-developer/odo/pkg/odo/cli/application"
"github.com/redhat-developer/odo/pkg/odo/cli/project"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
odoutil "github.com/redhat-developer/odo/pkg/odo/util"
"github.com/spf13/cobra"
ktemplates "k8s.io/kubernetes/pkg/kubectl/cmd/templates"
)
Expand Down Expand Up @@ -71,9 +70,7 @@ func NewCmdGet(name, fullName string) *cobra.Command {
Example: fmt.Sprintf(getExample, fullName),
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
odoutil.LogErrorAndExit(gto.Complete(name, cmd, args), "")
odoutil.LogErrorAndExit(gto.Validate(), "")
odoutil.LogErrorAndExit(gto.Run(), "")
genericclioptions.GenericRun(gto, cmd, args)
},
}

Expand Down
Loading

0 comments on commit e96682a

Please sign in to comment.