Skip to content

Commit

Permalink
Merge 10588f9 into d3b58ca
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm authored Jan 27, 2019
2 parents d3b58ca + 10588f9 commit a36c516
Show file tree
Hide file tree
Showing 970 changed files with 284,154 additions and 10,850 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 @@ -59,6 +59,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 @@ -4,7 +4,6 @@ import (
"fmt"
"github.com/redhat-developer/odo/pkg/catalog"
"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 @@ -84,9 +83,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
5 changes: 2 additions & 3 deletions pkg/odo/cli/component/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

appCmd "github.com/redhat-developer/odo/pkg/odo/cli/application"
projectCmd "github.com/redhat-developer/odo/pkg/odo/cli/project"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
"github.com/redhat-developer/odo/pkg/odo/util/completion"

"github.com/redhat-developer/odo/pkg/odo/util"
Expand Down Expand Up @@ -122,9 +123,7 @@ func NewCmdLink(name, fullName string) *cobra.Command {
Example: fmt.Sprintf(linkExample, fullName),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
util.LogErrorAndExit(o.Complete(name, cmd, args), "")
util.LogErrorAndExit(o.Validate(), "")
util.LogErrorAndExit(o.Run(), "")
genericclioptions.GenericRun(o, cmd, args)
},
}

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

appCmd "github.com/redhat-developer/odo/pkg/odo/cli/application"
projectCmd "github.com/redhat-developer/odo/pkg/odo/cli/project"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
"github.com/redhat-developer/odo/pkg/odo/util/completion"

"github.com/redhat-developer/odo/pkg/odo/util"
Expand Down Expand Up @@ -76,9 +77,7 @@ func NewCmdUnlink(name, fullName string) *cobra.Command {
Example: fmt.Sprintf(unlinkExample, fullName),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
util.LogErrorAndExit(o.Complete(name, cmd, args), "")
util.LogErrorAndExit(o.Validate(), "")
util.LogErrorAndExit(o.Run(), "")
genericclioptions.GenericRun(o, cmd, args)
},
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/odo/cli/service/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ func NewCmdServiceCreate(name, fullName string) *cobra.Command {
Example: fmt.Sprintf(createExample, fullName),
Args: cobra.RangeArgs(0, 2),
Run: func(cmd *cobra.Command, args []string) {
util.LogErrorAndExit(o.Complete(name, cmd, args), "")
util.LogErrorAndExit(o.Validate(), "")
util.LogErrorAndExit(o.Run(), "")
genericclioptions.GenericRun(o, cmd, args)
},
}
serviceCreateCmd.Flags().StringVar(&o.plan, "plan", "", "The name of the plan of the service to be created")
Expand Down
5 changes: 1 addition & 4 deletions pkg/odo/cli/service/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/golang/glog"
"github.com/redhat-developer/odo/pkg/log"
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
"github.com/redhat-developer/odo/pkg/odo/util"
"github.com/redhat-developer/odo/pkg/odo/util/completion"
svc "github.com/redhat-developer/odo/pkg/service"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -89,9 +88,7 @@ func NewCmdServiceDelete(name, fullName string) *cobra.Command {
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
glog.V(4).Infof("service delete called\n args: %#v", strings.Join(args, " "))
util.LogErrorAndExit(o.Complete(name, cmd, args), "")
util.LogErrorAndExit(o.Validate(), "")
util.LogErrorAndExit(o.Run(), "")
genericclioptions.GenericRun(o, cmd, args)
},
}
serviceDeleteCmd.Flags().BoolVarP(&o.serviceForceDeleteFlag, "force", "f", false, "Delete service without prompting")
Expand Down
Loading

0 comments on commit a36c516

Please sign in to comment.