Skip to content

Commit

Permalink
Use GetContextFlag Function
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditi Sharma committed Nov 20, 2020
1 parent f0babb8 commit ff7dfbd
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions pkg/odo/genericclioptions/localprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (

"github.com/openshift/odo/pkg/config"
"github.com/openshift/odo/pkg/envinfo"
"github.com/openshift/odo/pkg/odo/util"
pkgUtil "github.com/openshift/odo/pkg/util"
"github.com/spf13/cobra"
"k8s.io/klog"
)
Expand All @@ -19,19 +17,7 @@ func GetValidEnvInfo(command *cobra.Command) (*envinfo.EnvSpecificInfo, error) {
// getValidEnvInfo accesses the environment file
func getValidEnvInfo(command *cobra.Command) (*envinfo.EnvSpecificInfo, error) {

// Get details from the env file
componentContext := FlagValueIfSet(command, ContextFlagName)

// Grab the absolute path of the env file
if componentContext != "" {
fAbs, err := pkgUtil.GetAbsPath(componentContext)
util.LogErrorAndExit(err, "")
componentContext = fAbs
} else {
fAbs, err := pkgUtil.GetAbsPath(".")
util.LogErrorAndExit(err, "")
componentContext = fAbs
}
componentContext := GetContextFlagValue(command)

// Access the env file
envInfo, err := envinfo.NewEnvSpecificInfo(componentContext)
Expand Down Expand Up @@ -59,15 +45,8 @@ func getValidEnvInfo(command *cobra.Command) (*envinfo.EnvSpecificInfo, error) {

func getValidConfig(command *cobra.Command, ignoreMissingConfiguration bool) (*config.LocalConfigInfo, error) {

// Get details from the local config file
contextDir := FlagValueIfSet(command, ContextFlagName)
contextDir := GetContextFlagValue(command)

// Grab the absolute path of the configuration
if contextDir != "" {
fAbs, err := pkgUtil.GetAbsPath(contextDir)
util.LogErrorAndExit(err, "")
contextDir = fAbs
}
// Access the local configuration
localConfiguration, err := config.NewLocalConfigInfo(contextDir)
if err != nil {
Expand Down

0 comments on commit ff7dfbd

Please sign in to comment.