mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Rename CheckError to LogErrorAndExit
Signed-off-by: glefloch <glfloch@gmail.com>
This commit is contained in:
@@ -55,13 +55,13 @@ func main() {
|
|||||||
// before proceeding with fetching the latest version
|
// before proceeding with fetching the latest version
|
||||||
cfg, err := config.New()
|
cfg, err := config.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.CheckError(err, "")
|
util.LogErrorAndExit(err, "")
|
||||||
}
|
}
|
||||||
if cfg.GetUpdateNotification() {
|
if cfg.GetUpdateNotification() {
|
||||||
updateInfo := make(chan string)
|
updateInfo := make(chan string)
|
||||||
go version.GetLatestReleaseInfo(updateInfo)
|
go version.GetLatestReleaseInfo(updateInfo)
|
||||||
|
|
||||||
util.CheckError(root.Execute(), "")
|
util.LogErrorAndExit(root.Execute(), "")
|
||||||
select {
|
select {
|
||||||
case message := <-updateInfo:
|
case message := <-updateInfo:
|
||||||
fmt.Println(message)
|
fmt.Println(message)
|
||||||
@@ -69,7 +69,7 @@ func main() {
|
|||||||
glog.V(4).Info("Could not get the latest release information in time. Never mind, exiting gracefully :)")
|
glog.V(4).Info("Could not get the latest release information in time. Never mind, exiting gracefully :)")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
util.CheckError(root.Execute(), "")
|
util.LogErrorAndExit(root.Execute(), "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,25 +82,25 @@ If no app name is passed, a default app name will be auto-generated.
|
|||||||
// Desired app name is not passed so, generate a new app name
|
// Desired app name is not passed so, generate a new app name
|
||||||
// Fetch existing list of apps
|
// Fetch existing list of apps
|
||||||
apps, err := application.List(client)
|
apps, err := application.List(client)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
// Generate a random name that's not already in use for the existing apps
|
// Generate a random name that's not already in use for the existing apps
|
||||||
appName, err = application.GetDefaultAppName(apps)
|
appName, err = application.GetDefaultAppName(apps)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
}
|
}
|
||||||
// validate application name
|
// validate application name
|
||||||
err := odoutil.ValidateName(appName)
|
err := odoutil.ValidateName(appName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Progressf("Creating application: %v in project: %v", appName, projectName)
|
log.Progressf("Creating application: %v in project: %v", appName, projectName)
|
||||||
err = application.Create(client, appName)
|
err = application.Create(client, appName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
err = application.SetCurrent(client, appName)
|
err = application.SetCurrent(client, appName)
|
||||||
|
|
||||||
// TODO: updating the app name should be done via SetCurrent and passing the Context
|
// TODO: updating the app name should be done via SetCurrent and passing the Context
|
||||||
// not strictly needed here but Context should stay in sync
|
// not strictly needed here but Context should stay in sync
|
||||||
context.Application = appName
|
context.Application = appName
|
||||||
|
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Infof("Switched to application: %v in project: %v", appName, projectName)
|
log.Infof("Switched to application: %v in project: %v", appName, projectName)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -151,9 +151,9 @@ var applicationDeleteCmd = &cobra.Command{
|
|||||||
|
|
||||||
// Print App Information which will be deleted
|
// Print App Information which will be deleted
|
||||||
err := printDeleteAppInfo(client, appName)
|
err := printDeleteAppInfo(client, appName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
exists, err := application.Exists(client, appName)
|
exists, err := application.Exists(client, appName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("Application %v in project %v does not exist", appName, projectName)
|
log.Errorf("Application %v in project %v does not exist", appName, projectName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -168,7 +168,7 @@ var applicationDeleteCmd = &cobra.Command{
|
|||||||
|
|
||||||
if strings.ToLower(confirmDeletion) == "y" {
|
if strings.ToLower(confirmDeletion) == "y" {
|
||||||
err := application.Delete(client, appName)
|
err := application.Delete(client, appName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Infof("Deleted application: %s from project: %v", appName, projectName)
|
log.Infof("Deleted application: %s from project: %v", appName, projectName)
|
||||||
} else {
|
} else {
|
||||||
log.Infof("Aborting deletion of application: %v", appName)
|
log.Infof("Aborting deletion of application: %v", appName)
|
||||||
@@ -193,7 +193,7 @@ var applicationListCmd = &cobra.Command{
|
|||||||
projectName := context.Project
|
projectName := context.Project
|
||||||
|
|
||||||
apps, err := application.ListInProject(client)
|
apps, err := application.ListInProject(client)
|
||||||
odoutil.CheckError(err, "unable to get list of applications")
|
odoutil.LogErrorAndExit(err, "unable to get list of applications")
|
||||||
if len(apps) > 0 {
|
if len(apps) > 0 {
|
||||||
log.Infof("The project '%v' has the following applications:", projectName)
|
log.Infof("The project '%v' has the following applications:", projectName)
|
||||||
tabWriter := tabwriter.NewWriter(os.Stdout, 5, 2, 3, ' ', tabwriter.TabIndent)
|
tabWriter := tabwriter.NewWriter(os.Stdout, 5, 2, 3, ' ', tabwriter.TabIndent)
|
||||||
@@ -237,14 +237,14 @@ var applicationSetCmd = &cobra.Command{
|
|||||||
// error if application does not exist
|
// error if application does not exist
|
||||||
appName := args[0]
|
appName := args[0]
|
||||||
exists, err := application.Exists(client, appName)
|
exists, err := application.Exists(client, appName)
|
||||||
odoutil.CheckError(err, "unable to check if application exists")
|
odoutil.LogErrorAndExit(err, "unable to check if application exists")
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("Application %v does not exist", appName)
|
log.Errorf("Application %v does not exist", appName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = application.SetCurrent(client, appName)
|
err = application.SetCurrent(client, appName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Infof("Switched to application: %v in project: %v", args[0], projectName)
|
log.Infof("Switched to application: %v in project: %v", args[0], projectName)
|
||||||
|
|
||||||
// TODO: updating the app name should be done via SetCurrent and passing the Context
|
// TODO: updating the app name should be done via SetCurrent and passing the Context
|
||||||
@@ -276,7 +276,7 @@ var applicationDescribeCmd = &cobra.Command{
|
|||||||
appName = args[0]
|
appName = args[0]
|
||||||
//Check whether application exist or not
|
//Check whether application exist or not
|
||||||
exists, err := application.Exists(client, appName)
|
exists, err := application.Exists(client, appName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("Application with the name %s does not exist in %s ", appName, projectName)
|
log.Errorf("Application with the name %s does not exist in %s ", appName, projectName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -285,7 +285,7 @@ var applicationDescribeCmd = &cobra.Command{
|
|||||||
|
|
||||||
// List of Component
|
// List of Component
|
||||||
componentList, err := component.List(client, appName)
|
componentList, err := component.List(client, appName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if len(componentList) == 0 {
|
if len(componentList) == 0 {
|
||||||
log.Errorf("Application %s has no components deployed.", appName)
|
log.Errorf("Application %s has no components deployed.", appName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -293,7 +293,7 @@ var applicationDescribeCmd = &cobra.Command{
|
|||||||
fmt.Printf("Application Name: %s has %v components:\n--------------------------------------\n", appName, len(componentList))
|
fmt.Printf("Application Name: %s has %v components:\n--------------------------------------\n", appName, len(componentList))
|
||||||
for _, currentComponent := range componentList {
|
for _, currentComponent := range componentList {
|
||||||
componentDesc, err := component.GetComponentDesc(client, currentComponent.Name, appName)
|
componentDesc, err := component.GetComponentDesc(client, currentComponent.Name, appName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
odoutil.PrintComponentInfo(currentComponent.Name, componentDesc)
|
odoutil.PrintComponentInfo(currentComponent.Name, componentDesc)
|
||||||
fmt.Println("--------------------------------------")
|
fmt.Println("--------------------------------------")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ var catalogListComponentCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
client := genericclioptions.Client(cmd)
|
client := genericclioptions.Client(cmd)
|
||||||
catalogList, err := catalog.List(client)
|
catalogList, err := catalog.List(client)
|
||||||
odoutil.CheckError(err, "unable to list components")
|
odoutil.LogErrorAndExit(err, "unable to list components")
|
||||||
switch len(catalogList) {
|
switch len(catalogList) {
|
||||||
case 0:
|
case 0:
|
||||||
log.Errorf("No deployable components found")
|
log.Errorf("No deployable components found")
|
||||||
@@ -96,7 +96,7 @@ var catalogListServiceCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
client := genericclioptions.Client(cmd)
|
client := genericclioptions.Client(cmd)
|
||||||
catalogList, err := svc.ListCatalog(client)
|
catalogList, err := svc.ListCatalog(client)
|
||||||
odoutil.CheckError(err, "unable to list services because Service Catalog is not enabled in your cluster")
|
odoutil.LogErrorAndExit(err, "unable to list services because Service Catalog is not enabled in your cluster")
|
||||||
switch len(catalogList) {
|
switch len(catalogList) {
|
||||||
case 0:
|
case 0:
|
||||||
log.Errorf("No deployable services found")
|
log.Errorf("No deployable services found")
|
||||||
@@ -145,7 +145,7 @@ components.
|
|||||||
client := genericclioptions.Client(cmd)
|
client := genericclioptions.Client(cmd)
|
||||||
searchTerm := args[0]
|
searchTerm := args[0]
|
||||||
components, err := catalog.Search(client, searchTerm)
|
components, err := catalog.Search(client, searchTerm)
|
||||||
odoutil.CheckError(err, "unable to search for components")
|
odoutil.LogErrorAndExit(err, "unable to search for components")
|
||||||
|
|
||||||
switch len(components) {
|
switch len(components) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -176,7 +176,7 @@ services from service catalog.
|
|||||||
client := genericclioptions.Client(cmd)
|
client := genericclioptions.Client(cmd)
|
||||||
searchTerm := args[0]
|
searchTerm := args[0]
|
||||||
components, err := svc.Search(client, searchTerm)
|
components, err := svc.Search(client, searchTerm)
|
||||||
odoutil.CheckError(err, "unable to search for services")
|
odoutil.LogErrorAndExit(err, "unable to search for services")
|
||||||
|
|
||||||
switch len(components) {
|
switch len(components) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -219,7 +219,7 @@ This describes the service and the associated plans.
|
|||||||
client := genericclioptions.Client(cmd)
|
client := genericclioptions.Client(cmd)
|
||||||
serviceName := args[0]
|
serviceName := args[0]
|
||||||
service, plans, err := svc.GetServiceClassAndPlans(client, serviceName)
|
service, plans, err := svc.GetServiceClassAndPlans(client, serviceName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
table := tablewriter.NewWriter(os.Stdout)
|
table := tablewriter.NewWriter(os.Stdout)
|
||||||
table.SetBorder(false)
|
table.SetBorder(false)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ var componentSetCmd = &cobra.Command{
|
|||||||
componentName := context.Component(args[0])
|
componentName := context.Component(args[0])
|
||||||
|
|
||||||
err := component.SetCurrent(componentName, applicationName, projectName)
|
err := component.SetCurrent(componentName, applicationName, projectName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Infof("Switched to component: %v", componentName)
|
log.Infof("Switched to component: %v", componentName)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
if len(componentBinary) != 0 {
|
if len(componentBinary) != 0 {
|
||||||
componentPath = componentBinary
|
componentPath = componentBinary
|
||||||
path, err := util.GetAbsPath(componentPath)
|
path, err := util.GetAbsPath(componentPath)
|
||||||
odoutil.CheckError(err, "Failed to resolve %s to absolute path", componentPath)
|
odoutil.LogErrorAndExit(err, "Failed to resolve %s to absolute path", componentPath)
|
||||||
componentPath = path
|
componentPath = path
|
||||||
componentPathType = occlient.BINARY
|
componentPathType = occlient.BINARY
|
||||||
checkFlag++
|
checkFlag++
|
||||||
@@ -119,7 +119,7 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
if len(componentLocal) != 0 {
|
if len(componentLocal) != 0 {
|
||||||
componentPath = componentLocal
|
componentPath = componentLocal
|
||||||
path, err := util.GetAbsPath(componentPath)
|
path, err := util.GetAbsPath(componentPath)
|
||||||
odoutil.CheckError(err, "Failed to resolve %s to absolute path", componentPath)
|
odoutil.LogErrorAndExit(err, "Failed to resolve %s to absolute path", componentPath)
|
||||||
componentPath = path
|
componentPath = path
|
||||||
componentPathType = occlient.LOCAL
|
componentPathType = occlient.LOCAL
|
||||||
checkFlag++
|
checkFlag++
|
||||||
@@ -140,7 +140,7 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
|
|
||||||
// Fetch list of existing components in-order to attempt generation of unique component name
|
// Fetch list of existing components in-order to attempt generation of unique component name
|
||||||
componentList, err := component.List(client, applicationName)
|
componentList, err := component.List(client, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
// Generate unique name for component
|
// Generate unique name for component
|
||||||
componentName, err := component.GetDefaultComponentName(
|
componentName, err := component.GetDefaultComponentName(
|
||||||
@@ -149,11 +149,11 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
componentType,
|
componentType,
|
||||||
componentList,
|
componentList,
|
||||||
)
|
)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
// Check to see if the catalog type actually exists
|
// Check to see if the catalog type actually exists
|
||||||
exists, err := catalog.Exists(client, componentType)
|
exists, err := catalog.Exists(client, componentType)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("Invalid component type: %v", componentType)
|
log.Errorf("Invalid component type: %v", componentType)
|
||||||
log.Info("Run 'odo catalog list components' for a list of supported component types")
|
log.Info("Run 'odo catalog list components' for a list of supported component types")
|
||||||
@@ -162,7 +162,7 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
|
|
||||||
// Check to see if that particular version exists
|
// Check to see if that particular version exists
|
||||||
versionExists, err := catalog.VersionExists(client, componentType, componentVersion)
|
versionExists, err := catalog.VersionExists(client, componentType, componentVersion)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if !versionExists {
|
if !versionExists {
|
||||||
log.Errorf("Invalid component version: %v", componentVersion)
|
log.Errorf("Invalid component version: %v", componentVersion)
|
||||||
log.Info("Run 'odo catalog list components' to see a list of supported component type versions")
|
log.Info("Run 'odo catalog list components' to see a list of supported component type versions")
|
||||||
@@ -176,9 +176,9 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
|
|
||||||
// Validate component name
|
// Validate component name
|
||||||
err = odoutil.ValidateName(componentName)
|
err = odoutil.ValidateName(componentName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
exists, err = component.Exists(client, componentName, applicationName)
|
exists, err = component.Exists(client, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if exists {
|
if exists {
|
||||||
log.Errorf("component with the name %s already exists in the current application", componentName)
|
log.Errorf("component with the name %s already exists in the current application", componentName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -217,15 +217,15 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
ApplicationName: applicationName,
|
ApplicationName: applicationName,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
// Git is the only one using BuildConfig since we need to retrieve the git
|
// Git is the only one using BuildConfig since we need to retrieve the git
|
||||||
err = component.Build(client, componentName, applicationName, true, stdout)
|
err = component.Build(client, componentName, applicationName, true, stdout)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
} else if len(componentLocal) != 0 {
|
} else if len(componentLocal) != 0 {
|
||||||
fileInfo, err := os.Stat(componentPath)
|
fileInfo, err := os.Stat(componentPath)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if !fileInfo.IsDir() {
|
if !fileInfo.IsDir() {
|
||||||
log.Errorf("Please provide a path to the directory")
|
log.Errorf("Please provide a path to the directory")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -245,7 +245,7 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
ApplicationName: applicationName,
|
ApplicationName: applicationName,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
} else if len(componentBinary) != 0 {
|
} else if len(componentBinary) != 0 {
|
||||||
// Deploy the component with a binary
|
// Deploy the component with a binary
|
||||||
@@ -264,12 +264,12 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
ApplicationName: applicationName,
|
ApplicationName: applicationName,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If the user does not provide anything (local, git or binary), use the current absolute path and deploy it
|
// If the user does not provide anything (local, git or binary), use the current absolute path and deploy it
|
||||||
dir, err := util.GetAbsPath("./")
|
dir, err := util.GetAbsPath("./")
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
// Create
|
// Create
|
||||||
err = component.CreateFromPath(
|
err = component.CreateFromPath(
|
||||||
@@ -285,11 +285,11 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
ApplicationName: applicationName,
|
ApplicationName: applicationName,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
ports, err := component.GetComponentPorts(client, componentName, applicationName)
|
ports, err := component.GetComponentPorts(client, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
if len(ports) > 1 {
|
if len(ports) > 1 {
|
||||||
log.Successf("Component '%s' was created and ports %s were opened", componentName, strings.Join(ports, ","))
|
log.Successf("Component '%s' was created and ports %s were opened", componentName, strings.Join(ports, ","))
|
||||||
@@ -299,9 +299,9 @@ A full list of component types that can be deployed is available using: 'odo cat
|
|||||||
|
|
||||||
// after component is successfully created, set is as active
|
// after component is successfully created, set is as active
|
||||||
err = application.SetCurrent(client, applicationName)
|
err = application.SetCurrent(client, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
err = component.SetCurrent(componentName, applicationName, projectName)
|
err = component.SetCurrent(componentName, applicationName, projectName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Successf("Component '%s' is now set as active component", componentName)
|
log.Successf("Component '%s' is now set as active component", componentName)
|
||||||
|
|
||||||
if len(componentGit) == 0 {
|
if len(componentGit) == 0 {
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ var componentDeleteCmd = &cobra.Command{
|
|||||||
|
|
||||||
if strings.ToLower(confirmDeletion) == "y" {
|
if strings.ToLower(confirmDeletion) == "y" {
|
||||||
err := component.Delete(client, componentName, applicationName)
|
err := component.Delete(client, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Successf("Component %s from application %s has been deleted", componentName, applicationName)
|
log.Successf("Component %s from application %s has been deleted", componentName, applicationName)
|
||||||
|
|
||||||
currentComponent, err := component.GetCurrent(applicationName, projectName)
|
currentComponent, err := component.GetCurrent(applicationName, projectName)
|
||||||
odoutil.CheckError(err, "Unable to get current component")
|
odoutil.LogErrorAndExit(err, "Unable to get current component")
|
||||||
|
|
||||||
if currentComponent == "" {
|
if currentComponent == "" {
|
||||||
log.Info("No default component has been set")
|
log.Info("No default component has been set")
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ var describeCmd = &cobra.Command{
|
|||||||
componentName = context.Component(args[0])
|
componentName = context.Component(args[0])
|
||||||
}
|
}
|
||||||
componentDesc, err := component.GetComponentDesc(client, componentName, applicationName)
|
componentDesc, err := component.GetComponentDesc(client, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
odoutil.PrintComponentInfo(componentName, componentDesc)
|
odoutil.PrintComponentInfo(componentName, componentDesc)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -103,9 +103,9 @@ func NewCmdLink(name, fullName string) *cobra.Command {
|
|||||||
Example: fmt.Sprintf(linkExample, fullName),
|
Example: fmt.Sprintf(linkExample, fullName),
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
util.CheckError(o.Complete(name, cmd, args), "")
|
util.LogErrorAndExit(o.Complete(name, cmd, args), "")
|
||||||
util.CheckError(o.Validate(), "")
|
util.LogErrorAndExit(o.Validate(), "")
|
||||||
util.CheckError(o.Run(), "")
|
util.LogErrorAndExit(o.Run(), "")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ var componentListCmd = &cobra.Command{
|
|||||||
applicationName := context.Application
|
applicationName := context.Application
|
||||||
|
|
||||||
components, err := component.List(client, applicationName)
|
components, err := component.List(client, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if len(components) == 0 {
|
if len(components) == 0 {
|
||||||
log.Errorf("There are no components deployed.")
|
log.Errorf("There are no components deployed.")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ var logCmd = &cobra.Command{
|
|||||||
|
|
||||||
// Retrieve the log
|
// Retrieve the log
|
||||||
err := component.GetLogs(client, componentName, applicationName, logFollow, stdout)
|
err := component.GetLogs(client, componentName, applicationName, logFollow, stdout)
|
||||||
odoutil.CheckError(err, "Unable to retrieve logs, does your component exist?")
|
odoutil.LogErrorAndExit(err, "Unable to retrieve logs, does your component exist?")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ var pushCmd = &cobra.Command{
|
|||||||
log.Namef("Pushing changes to component: %v", componentName)
|
log.Namef("Pushing changes to component: %v", componentName)
|
||||||
|
|
||||||
sourceType, sourcePath, err := component.GetComponentSource(client, componentName, applicationName)
|
sourceType, sourcePath, err := component.GetComponentSource(client, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "unable to get component source")
|
odoutil.LogErrorAndExit(err, "unable to get component source")
|
||||||
switch sourceType {
|
switch sourceType {
|
||||||
case "local", "binary":
|
case "local", "binary":
|
||||||
// use value of '--dir' as source if it was used
|
// use value of '--dir' as source if it was used
|
||||||
@@ -73,7 +73,7 @@ var pushCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
u, err := url.Parse(sourcePath)
|
u, err := url.Parse(sourcePath)
|
||||||
odoutil.CheckError(err, fmt.Sprintf("unable to parse source %s from component %s", sourcePath, componentName))
|
odoutil.LogErrorAndExit(err, fmt.Sprintf("unable to parse source %s from component %s", sourcePath, componentName))
|
||||||
|
|
||||||
if u.Scheme != "" && u.Scheme != "file" {
|
if u.Scheme != "" && u.Scheme != "file" {
|
||||||
log.Errorf("Component %s has invalid source path %s", componentName, u.Scheme)
|
log.Errorf("Component %s has invalid source path %s", componentName, u.Scheme)
|
||||||
@@ -84,7 +84,7 @@ var pushCmd = &cobra.Command{
|
|||||||
|
|
||||||
_, err = os.Stat(localLocation)
|
_, err = os.Stat(localLocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
if sourceType == "local" {
|
if sourceType == "local" {
|
||||||
@@ -95,7 +95,7 @@ var pushCmd = &cobra.Command{
|
|||||||
glog.V(4).Infof("Copying file %s to pod", localLocation)
|
glog.V(4).Infof("Copying file %s to pod", localLocation)
|
||||||
err = component.PushLocal(client, componentName, applicationName, dir, os.Stdout, []string{localLocation})
|
err = component.PushLocal(client, componentName, applicationName, dir, os.Stdout, []string{localLocation})
|
||||||
}
|
}
|
||||||
odoutil.CheckError(err, fmt.Sprintf("Failed to push component: %v", componentName))
|
odoutil.LogErrorAndExit(err, fmt.Sprintf("Failed to push component: %v", componentName))
|
||||||
|
|
||||||
case "git":
|
case "git":
|
||||||
// currently we don't support changing build type
|
// currently we don't support changing build type
|
||||||
@@ -105,7 +105,7 @@ var pushCmd = &cobra.Command{
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
err := component.Build(client, componentName, applicationName, true, stdout)
|
err := component.Build(client, componentName, applicationName, true, stdout)
|
||||||
odoutil.CheckError(err, fmt.Sprintf("failed to push component: %v", componentName))
|
odoutil.LogErrorAndExit(err, fmt.Sprintf("failed to push component: %v", componentName))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Successf("Changes successfully pushed to component: %v", componentName)
|
log.Successf("Changes successfully pushed to component: %v", componentName)
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ func NewCmdUnlink(name, fullName string) *cobra.Command {
|
|||||||
Example: fmt.Sprintf(unlinkExample, fullName),
|
Example: fmt.Sprintf(unlinkExample, fullName),
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
util.CheckError(o.Complete(name, cmd, args), "")
|
util.LogErrorAndExit(o.Complete(name, cmd, args), "")
|
||||||
util.CheckError(o.Validate(), "")
|
util.LogErrorAndExit(o.Validate(), "")
|
||||||
util.CheckError(o.Run(), "")
|
util.LogErrorAndExit(o.Run(), "")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,26 +85,26 @@ var updateCmd = &cobra.Command{
|
|||||||
|
|
||||||
if len(componentGit) != 0 {
|
if len(componentGit) != 0 {
|
||||||
err := component.Update(client, componentName, applicationName, "git", componentGit, componentGitRef, stdout)
|
err := component.Update(client, componentName, applicationName, "git", componentGit, componentGitRef, stdout)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Successf("The component %s was updated successfully", componentName)
|
log.Successf("The component %s was updated successfully", componentName)
|
||||||
} else if len(componentLocal) != 0 {
|
} else if len(componentLocal) != 0 {
|
||||||
// we want to use and save absolute path for component
|
// we want to use and save absolute path for component
|
||||||
dir, err := pkgUtil.GetAbsPath(componentLocal)
|
dir, err := pkgUtil.GetAbsPath(componentLocal)
|
||||||
util.CheckError(err, "")
|
util.LogErrorAndExit(err, "")
|
||||||
fileInfo, err := os.Stat(dir)
|
fileInfo, err := os.Stat(dir)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if !fileInfo.IsDir() {
|
if !fileInfo.IsDir() {
|
||||||
log.Error("Please provide a path to the directory")
|
log.Error("Please provide a path to the directory")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
err = component.Update(client, componentName, applicationName, "local", dir, "", stdout)
|
err = component.Update(client, componentName, applicationName, "local", dir, "", stdout)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Successf("The component %s was updated successfully, please use 'odo push' to push your local changes", componentName)
|
log.Successf("The component %s was updated successfully, please use 'odo push' to push your local changes", componentName)
|
||||||
} else if len(componentBinary) != 0 {
|
} else if len(componentBinary) != 0 {
|
||||||
path, err := pkgUtil.GetAbsPath(componentBinary)
|
path, err := pkgUtil.GetAbsPath(componentBinary)
|
||||||
util.CheckError(err, "")
|
util.LogErrorAndExit(err, "")
|
||||||
err = component.Update(client, componentName, applicationName, "binary", path, "", stdout)
|
err = component.Update(client, componentName, applicationName, "binary", path, "", stdout)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Successf("The component %s was updated successfully, please use 'odo push' to push your local changes", componentName)
|
log.Successf("The component %s was updated successfully, please use 'odo push' to push your local changes", componentName)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ var watchCmd = &cobra.Command{
|
|||||||
var err error
|
var err error
|
||||||
glog.V(4).Info("No component name passed, assuming current component")
|
glog.V(4).Info("No component name passed, assuming current component")
|
||||||
componentName, err = component.GetCurrent(applicationName, projectName)
|
componentName, err = component.GetCurrent(applicationName, projectName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if componentName == "" {
|
if componentName == "" {
|
||||||
log.Infof("No component is set as active.")
|
log.Infof("No component is set as active.")
|
||||||
log.Infof("Use 'odo component set <component name> to set and existing component as active or call this command with component name as and argument.")
|
log.Infof("Use 'odo component set <component name> to set and existing component as active or call this command with component name as and argument.")
|
||||||
@@ -58,7 +58,7 @@ var watchCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
sourceType, sourcePath, err := component.GetComponentSource(client, componentName, applicationName)
|
sourceType, sourcePath, err := component.GetComponentSource(client, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "Unable to get source for %s component.", componentName)
|
odoutil.LogErrorAndExit(err, "Unable to get source for %s component.", componentName)
|
||||||
|
|
||||||
if sourceType != "binary" && sourceType != "local" {
|
if sourceType != "binary" && sourceType != "local" {
|
||||||
log.Errorf("Watch is supported by binary and local components only and source type of component %s is %s", componentName, sourceType)
|
log.Errorf("Watch is supported by binary and local components only and source type of component %s is %s", componentName, sourceType)
|
||||||
@@ -66,7 +66,7 @@ var watchCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
u, err := url.Parse(sourcePath)
|
u, err := url.Parse(sourcePath)
|
||||||
odoutil.CheckError(err, "Unable to parse source %s from component %s.", sourcePath, componentName)
|
odoutil.LogErrorAndExit(err, "Unable to parse source %s from component %s.", sourcePath, componentName)
|
||||||
|
|
||||||
if u.Scheme != "" && u.Scheme != "file" {
|
if u.Scheme != "" && u.Scheme != "file" {
|
||||||
log.Errorf("Component %s has invalid source path %s.", componentName, u.Scheme)
|
log.Errorf("Component %s has invalid source path %s.", componentName, u.Scheme)
|
||||||
@@ -88,7 +88,7 @@ var watchCmd = &cobra.Command{
|
|||||||
WatchHandler: component.PushLocal,
|
WatchHandler: component.PushLocal,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
odoutil.CheckError(err, "Error while trying to watch %s", watchPath)
|
odoutil.LogErrorAndExit(err, "Error while trying to watch %s", watchPath)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ var loginCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
err := auth.Login(server, userName, password, token, caAuth, skipTLS)
|
err := auth.Login(server, userName, password, token, caAuth, skipTLS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ var logoutCmd = &cobra.Command{
|
|||||||
context := genericclioptions.NewContext(cmd)
|
context := genericclioptions.NewContext(cmd)
|
||||||
client := context.Client
|
client := context.Client
|
||||||
err := client.RunLogout(os.Stdout)
|
err := client.RunLogout(os.Stdout)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,14 +55,14 @@ var projectSetCmd = &cobra.Command{
|
|||||||
current := context.Project
|
current := context.Project
|
||||||
|
|
||||||
exists, err := project.Exists(client, projectName)
|
exists, err := project.Exists(client, projectName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("The project %s does not exist", projectName)
|
log.Errorf("The project %s does not exist", projectName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = project.SetCurrent(client, projectName)
|
err = project.SetCurrent(client, projectName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if projectShortFlag {
|
if projectShortFlag {
|
||||||
fmt.Print(projectName)
|
fmt.Print(projectName)
|
||||||
} else {
|
} else {
|
||||||
@@ -107,9 +107,9 @@ var projectCreateCmd = &cobra.Command{
|
|||||||
projectName := args[0]
|
projectName := args[0]
|
||||||
client := genericclioptions.Client(cmd)
|
client := genericclioptions.Client(cmd)
|
||||||
err := project.Create(client, projectName)
|
err := project.Create(client, projectName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
err = project.SetCurrent(client, projectName)
|
err = project.SetCurrent(client, projectName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Successf("New project created and now using project : %v", projectName)
|
log.Successf("New project created and now using project : %v", projectName)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ var projectDeleteCmd = &cobra.Command{
|
|||||||
|
|
||||||
// Validate existence of the project to be deleted
|
// Validate existence of the project to be deleted
|
||||||
isValidProject, err := project.Exists(client, projectName)
|
isValidProject, err := project.Exists(client, projectName)
|
||||||
odoutil.CheckError(err, "Failed to delete project %s", projectName)
|
odoutil.LogErrorAndExit(err, "Failed to delete project %s", projectName)
|
||||||
if !isValidProject {
|
if !isValidProject {
|
||||||
log.Errorf("The project %s does not exist. Please check the list of projects using `odo project list`", projectName)
|
log.Errorf("The project %s does not exist. Please check the list of projects using `odo project list`", projectName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -149,7 +149,7 @@ var projectDeleteCmd = &cobra.Command{
|
|||||||
|
|
||||||
currentProject, err := project.Delete(client, projectName)
|
currentProject, err := project.Delete(client, projectName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Deleted project : %v", projectName)
|
log.Infof("Deleted project : %v", projectName)
|
||||||
@@ -175,7 +175,7 @@ var projectListCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
client := genericclioptions.Client(cmd)
|
client := genericclioptions.Client(cmd)
|
||||||
projects, err := project.List(client)
|
projects, err := project.List(client)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if len(projects) == 0 {
|
if len(projects) == 0 {
|
||||||
log.Errorf("You are not a member of any projects. You can request a project to be created using the `odo project create <project_name>` command")
|
log.Errorf("You are not a member of any projects. You can request a project to be created using the `odo project create <project_name>` command")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -123,9 +123,9 @@ func NewCmdServiceCreate(name, fullName string) *cobra.Command {
|
|||||||
Example: fmt.Sprintf(createExample, fullName),
|
Example: fmt.Sprintf(createExample, fullName),
|
||||||
Args: cobra.RangeArgs(1, 2),
|
Args: cobra.RangeArgs(1, 2),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
util.CheckError(o.Complete(name, cmd, args), "")
|
util.LogErrorAndExit(o.Complete(name, cmd, args), "")
|
||||||
util.CheckError(o.Validate(), "")
|
util.LogErrorAndExit(o.Validate(), "")
|
||||||
util.CheckError(o.Run(), "")
|
util.LogErrorAndExit(o.Run(), "")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
serviceCreateCmd.Flags().StringVar(&o.plan, "plan", "", "The name of the plan of the service to be created")
|
serviceCreateCmd.Flags().StringVar(&o.plan, "plan", "", "The name of the plan of the service to be created")
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ func NewCmdServiceDelete(name, fullName string) *cobra.Command {
|
|||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
glog.V(4).Infof("service delete called\n args: %#v", strings.Join(args, " "))
|
glog.V(4).Infof("service delete called\n args: %#v", strings.Join(args, " "))
|
||||||
util.CheckError(o.Complete(name, cmd, args), "")
|
util.LogErrorAndExit(o.Complete(name, cmd, args), "")
|
||||||
util.CheckError(o.Validate(), "")
|
util.LogErrorAndExit(o.Validate(), "")
|
||||||
util.CheckError(o.Run(), "")
|
util.LogErrorAndExit(o.Run(), "")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
serviceDeleteCmd.Flags().BoolVarP(&o.serviceForceDeleteFlag, "force", "f", false, "Delete service without prompting")
|
serviceDeleteCmd.Flags().BoolVarP(&o.serviceForceDeleteFlag, "force", "f", false, "Delete service without prompting")
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ func NewCmdServiceList(name, fullName string) *cobra.Command {
|
|||||||
Example: fmt.Sprintf(listExample, fullName),
|
Example: fmt.Sprintf(listExample, fullName),
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
util.CheckError(o.Complete(name, cmd, args), "")
|
util.LogErrorAndExit(o.Complete(name, cmd, args), "")
|
||||||
util.CheckError(o.Validate(), "")
|
util.LogErrorAndExit(o.Validate(), "")
|
||||||
util.CheckError(o.Run(), "")
|
util.LogErrorAndExit(o.Run(), "")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return serviceListCmd
|
return serviceListCmd
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ var storageCreateCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
// validate storage path
|
// validate storage path
|
||||||
err := validateStoragePath(client, storagePath, componentName, applicationName)
|
err := validateStoragePath(client, storagePath, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
_, err = storage.Create(client, storageName, storageSize, storagePath, componentName, applicationName)
|
_, err = storage.Create(client, storageName, storageSize, storagePath, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Successf("Added storage %v to %v", storageName, componentName)
|
log.Successf("Added storage %v to %v", storageName, componentName)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ var storageUnmountCmd = &cobra.Command{
|
|||||||
if string(args[0][0]) == "/" {
|
if string(args[0][0]) == "/" {
|
||||||
path := args[0]
|
path := args[0]
|
||||||
storageName, err = storage.GetStorageNameFromMountPath(client, path, componentName, applicationName)
|
storageName, err = storage.GetStorageNameFromMountPath(client, path, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "Unable to get storage name from mount path")
|
odoutil.LogErrorAndExit(err, "Unable to get storage name from mount path")
|
||||||
if storageName == "" {
|
if storageName == "" {
|
||||||
log.Errorf("No storage is mounted to %s in the component %s", path, componentName)
|
log.Errorf("No storage is mounted to %s in the component %s", path, componentName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -111,7 +111,7 @@ var storageUnmountCmd = &cobra.Command{
|
|||||||
} else {
|
} else {
|
||||||
storageName = args[0]
|
storageName = args[0]
|
||||||
exists, err := storage.IsMounted(client, storageName, componentName, applicationName)
|
exists, err := storage.IsMounted(client, storageName, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "Unable to check if storage is mounted or not")
|
odoutil.LogErrorAndExit(err, "Unable to check if storage is mounted or not")
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("Storage %v does not exist in component %v", storageName, componentName)
|
log.Errorf("Storage %v does not exist in component %v", storageName, componentName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -119,7 +119,7 @@ var storageUnmountCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = storage.Unmount(client, storageName, componentName, applicationName, true)
|
err = storage.Unmount(client, storageName, componentName, applicationName, true)
|
||||||
odoutil.CheckError(err, "Unable to unmount storage %v from component %v", storageName, componentName)
|
odoutil.LogErrorAndExit(err, "Unable to unmount storage %v from component %v", storageName, componentName)
|
||||||
|
|
||||||
log.Infof("Unmounted storage %v from %v", storageName, componentName)
|
log.Infof("Unmounted storage %v from %v", storageName, componentName)
|
||||||
},
|
},
|
||||||
@@ -143,7 +143,7 @@ var storageDeleteCmd = &cobra.Command{
|
|||||||
storageName := args[0]
|
storageName := args[0]
|
||||||
|
|
||||||
exists, err := storage.Exists(client, storageName, applicationName)
|
exists, err := storage.Exists(client, storageName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
if !exists {
|
if !exists {
|
||||||
|
|
||||||
log.Errorf("The storage %v does not exists in the application %v", storageName, applicationName)
|
log.Errorf("The storage %v does not exists in the application %v", storageName, applicationName)
|
||||||
@@ -152,7 +152,7 @@ var storageDeleteCmd = &cobra.Command{
|
|||||||
|
|
||||||
componentName, err := storage.GetComponentNameFromStorageName(client, storageName)
|
componentName, err := storage.GetComponentNameFromStorageName(client, storageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
odoutil.CheckError(err, "Unable to get component associated with %s storage.", storageName)
|
odoutil.LogErrorAndExit(err, "Unable to get component associated with %s storage.", storageName)
|
||||||
}
|
}
|
||||||
|
|
||||||
var confirmDeletion string
|
var confirmDeletion string
|
||||||
@@ -169,7 +169,7 @@ var storageDeleteCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
if strings.ToLower(confirmDeletion) == "y" {
|
if strings.ToLower(confirmDeletion) == "y" {
|
||||||
componentName, err = storage.Delete(client, storageName, applicationName)
|
componentName, err = storage.Delete(client, storageName, applicationName)
|
||||||
odoutil.CheckError(err, "failed to delete storage")
|
odoutil.LogErrorAndExit(err, "failed to delete storage")
|
||||||
if componentName != "" {
|
if componentName != "" {
|
||||||
log.Infof("Deleted storage %v from %v", storageName, componentName)
|
log.Infof("Deleted storage %v from %v", storageName, componentName)
|
||||||
} else {
|
} else {
|
||||||
@@ -229,19 +229,19 @@ var storageMountCmd = &cobra.Command{
|
|||||||
storageName := args[0]
|
storageName := args[0]
|
||||||
|
|
||||||
exists, err := storage.Exists(client, storageName, applicationName)
|
exists, err := storage.Exists(client, storageName, applicationName)
|
||||||
odoutil.CheckError(err, "unable to check if the storage exists in the current application")
|
odoutil.LogErrorAndExit(err, "unable to check if the storage exists in the current application")
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("The storage %v does not exists in the current application '%v'", storageName, applicationName)
|
log.Errorf("The storage %v does not exists in the current application '%v'", storageName, applicationName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
isMounted, err := storage.IsMounted(client, storageName, componentName, applicationName)
|
isMounted, err := storage.IsMounted(client, storageName, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "unable to check if the component is already mounted or not")
|
odoutil.LogErrorAndExit(err, "unable to check if the component is already mounted or not")
|
||||||
if isMounted {
|
if isMounted {
|
||||||
log.Errorf("The storage %v is already mounted on the current component '%v'", storageName, componentName)
|
log.Errorf("The storage %v is already mounted on the current component '%v'", storageName, componentName)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
err = storage.Mount(client, storagePath, storageName, componentName, applicationName)
|
err = storage.Mount(client, storagePath, storageName, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Infof("The storage %v is successfully mounted to the current component '%v'", storageName, componentName)
|
log.Infof("The storage %v is successfully mounted to the current component '%v'", storageName, componentName)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -322,7 +322,7 @@ func printMountedStorageInComponent(client *occlient.Client, componentName strin
|
|||||||
fmt.Fprintln(tabWriterMounted, "NAME", "\t", "SIZE", "\t", "PATH")
|
fmt.Fprintln(tabWriterMounted, "NAME", "\t", "SIZE", "\t", "PATH")
|
||||||
|
|
||||||
storageListMounted, err := storage.ListMounted(client, componentName, applicationName)
|
storageListMounted, err := storage.ListMounted(client, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "could not get mounted storage list")
|
odoutil.LogErrorAndExit(err, "could not get mounted storage list")
|
||||||
|
|
||||||
// iterating over all mounted storage and put in the mount storage table
|
// iterating over all mounted storage and put in the mount storage table
|
||||||
if len(storageListMounted) > 0 {
|
if len(storageListMounted) > 0 {
|
||||||
@@ -342,7 +342,7 @@ func printMountedStorageInComponent(client *occlient.Client, componentName strin
|
|||||||
// printMountedStorageInAllComponent prints all the mounted storage in all the components of the application and project
|
// printMountedStorageInAllComponent prints all the mounted storage in all the components of the application and project
|
||||||
func printMountedStorageInAllComponent(client *occlient.Client, applicationName string) {
|
func printMountedStorageInAllComponent(client *occlient.Client, applicationName string) {
|
||||||
componentList, err := component.List(client, applicationName)
|
componentList, err := component.List(client, applicationName)
|
||||||
odoutil.CheckError(err, "could not get component list")
|
odoutil.LogErrorAndExit(err, "could not get component list")
|
||||||
|
|
||||||
// iterating over all the components in the given aplication and project
|
// iterating over all the components in the given aplication and project
|
||||||
for _, component := range componentList {
|
for _, component := range componentList {
|
||||||
@@ -360,7 +360,7 @@ func printUnmountedStorage(client *occlient.Client, applicationName string) {
|
|||||||
fmt.Fprintln(tabWriterUnmounted, "NAME", "\t", "SIZE")
|
fmt.Fprintln(tabWriterUnmounted, "NAME", "\t", "SIZE")
|
||||||
|
|
||||||
storageListUnmounted, err := storage.ListUnmounted(client, applicationName)
|
storageListUnmounted, err := storage.ListUnmounted(client, applicationName)
|
||||||
odoutil.CheckError(err, "could not get unmounted storage list")
|
odoutil.LogErrorAndExit(err, "could not get unmounted storage list")
|
||||||
|
|
||||||
// iterating over all unmounted storage and put in the unmount storage table
|
// iterating over all unmounted storage and put in the unmount storage table
|
||||||
if len(storageListUnmounted) > 0 {
|
if len(storageListUnmounted) > 0 {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ The created URL can be used to access the specified component from outside the O
|
|||||||
componentName := context.Component()
|
componentName := context.Component()
|
||||||
|
|
||||||
componentPort, err := url.GetValidPortNumber(client, urlPort, componentName, applicationName)
|
componentPort, err := url.GetValidPortNumber(client, urlPort, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
var urlName string
|
var urlName string
|
||||||
switch len(args) {
|
switch len(args) {
|
||||||
@@ -90,7 +90,7 @@ The created URL can be used to access the specified component from outside the O
|
|||||||
|
|
||||||
log.Infof("Adding URL to component: %v", componentName)
|
log.Infof("Adding URL to component: %v", componentName)
|
||||||
urlRoute, err := url.Create(client, urlName, componentPort, componentName, applicationName)
|
urlRoute, err := url.Create(client, urlName, componentPort, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
urlCreated := url.GetURLString(*urlRoute)
|
urlCreated := url.GetURLString(*urlRoute)
|
||||||
log.Successf("URL created for component: %v\n\n"+
|
log.Successf("URL created for component: %v\n\n"+
|
||||||
@@ -98,7 +98,7 @@ The created URL can be used to access the specified component from outside the O
|
|||||||
|
|
||||||
if urlOpenFlag {
|
if urlOpenFlag {
|
||||||
err := util.OpenBrowser(urlCreated)
|
err := util.OpenBrowser(urlCreated)
|
||||||
odoutil.CheckError(err, "Unable to open URL within default browser")
|
odoutil.LogErrorAndExit(err, "Unable to open URL within default browser")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ var urlDeleteCmd = &cobra.Command{
|
|||||||
urlName := args[0]
|
urlName := args[0]
|
||||||
|
|
||||||
exists, err := url.Exists(client, urlName, componentName, applicationName)
|
exists, err := url.Exists(client, urlName, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("The URL %s does not exist within the component %s", urlName, componentName)
|
log.Errorf("The URL %s does not exist within the component %s", urlName, componentName)
|
||||||
@@ -138,7 +138,7 @@ var urlDeleteCmd = &cobra.Command{
|
|||||||
if strings.ToLower(confirmDeletion) == "y" {
|
if strings.ToLower(confirmDeletion) == "y" {
|
||||||
|
|
||||||
err = url.Delete(client, urlName, applicationName)
|
err = url.Delete(client, urlName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
log.Infof("Deleted URL: %v", urlName)
|
log.Infof("Deleted URL: %v", urlName)
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("Aborting deletion of url: %v", urlName)
|
log.Errorf("Aborting deletion of url: %v", urlName)
|
||||||
@@ -162,7 +162,7 @@ var urlListCmd = &cobra.Command{
|
|||||||
componentName := context.Component()
|
componentName := context.Component()
|
||||||
|
|
||||||
urls, err := url.List(client, componentName, applicationName)
|
urls, err := url.List(client, componentName, applicationName)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
if len(urls) == 0 {
|
if len(urls) == 0 {
|
||||||
log.Errorf("No URLs found for component %v in application %v", componentName, applicationName)
|
log.Errorf("No URLs found for component %v in application %v", componentName, applicationName)
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ var configurationViewCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
cfg, err := config.New()
|
cfg, err := config.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
odoutil.CheckError(err, "unable to view configuration")
|
odoutil.LogErrorAndExit(err, "unable to view configuration")
|
||||||
}
|
}
|
||||||
w := tabwriter.NewWriter(os.Stdout, 5, 2, 2, ' ', tabwriter.TabIndent)
|
w := tabwriter.NewWriter(os.Stdout, 5, 2, 2, ' ', tabwriter.TabIndent)
|
||||||
fmt.Fprintln(w, "PARAMETER", "\t", "CURRENT_VALUE")
|
fmt.Fprintln(w, "PARAMETER", "\t", "CURRENT_VALUE")
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ This will append your PS1 environment variable with Odo component and applicatio
|
|||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
err := TerminalGenerate(os.Stdout, cmd, args)
|
err := TerminalGenerate(os.Stdout, cmd, args)
|
||||||
odoutil.CheckError(err, "")
|
odoutil.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func client(command *cobra.Command, shouldSkipConnectionCheck ...bool) *occlient
|
|||||||
case 0:
|
case 0:
|
||||||
var err error
|
var err error
|
||||||
skipConnectionCheck, err = command.Flags().GetBool(SkipConnectionCheckFlagName)
|
skipConnectionCheck, err = command.Flags().GetBool(SkipConnectionCheckFlagName)
|
||||||
util.CheckError(err, "")
|
util.LogErrorAndExit(err, "")
|
||||||
case 1:
|
case 1:
|
||||||
skipConnectionCheck = shouldSkipConnectionCheck[0]
|
skipConnectionCheck = shouldSkipConnectionCheck[0]
|
||||||
default:
|
default:
|
||||||
@@ -54,7 +54,7 @@ func client(command *cobra.Command, shouldSkipConnectionCheck ...bool) *occlient
|
|||||||
}
|
}
|
||||||
|
|
||||||
client, err := occlient.New(skipConnectionCheck)
|
client, err := occlient.New(skipConnectionCheck)
|
||||||
util.CheckError(err, "")
|
util.LogErrorAndExit(err, "")
|
||||||
|
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ func newContext(command *cobra.Command, createAppIfNeeded bool) *Context {
|
|||||||
if len(projectFlag) > 0 {
|
if len(projectFlag) > 0 {
|
||||||
// if project flag was set, check that the specified project exists and use it
|
// if project flag was set, check that the specified project exists and use it
|
||||||
_, err := project.Exists(client, projectFlag)
|
_, err := project.Exists(client, projectFlag)
|
||||||
util.CheckError(err, "")
|
util.LogErrorAndExit(err, "")
|
||||||
ns = projectFlag
|
ns = projectFlag
|
||||||
} else {
|
} else {
|
||||||
// otherwise use the current project
|
// otherwise use the current project
|
||||||
@@ -83,7 +83,7 @@ func newContext(command *cobra.Command, createAppIfNeeded bool) *Context {
|
|||||||
if len(appFlag) > 0 {
|
if len(appFlag) > 0 {
|
||||||
// if we specified an application via flag, check that it exists and use it
|
// if we specified an application via flag, check that it exists and use it
|
||||||
_, err := application.Exists(client, appFlag)
|
_, err := application.Exists(client, appFlag)
|
||||||
util.CheckError(err, "")
|
util.LogErrorAndExit(err, "")
|
||||||
app = appFlag
|
app = appFlag
|
||||||
} else {
|
} else {
|
||||||
var err error
|
var err error
|
||||||
@@ -94,7 +94,7 @@ func newContext(command *cobra.Command, createAppIfNeeded bool) *Context {
|
|||||||
// if we asked an app to be created if missing, get the existing one or creating one if needed
|
// if we asked an app to be created if missing, get the existing one or creating one if needed
|
||||||
app, err = application.GetCurrentOrGetCreateSetDefault(client)
|
app, err = application.GetCurrentOrGetCreateSetDefault(client)
|
||||||
}
|
}
|
||||||
util.CheckError(err, "unable to get current application")
|
util.LogErrorAndExit(err, "unable to get current application")
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the internal context representation based on calculated values
|
// create the internal context representation based on calculated values
|
||||||
@@ -116,7 +116,7 @@ func newContext(command *cobra.Command, createAppIfNeeded bool) *Context {
|
|||||||
// retrieve the current component if it exists if we didn't set the component flag
|
// retrieve the current component if it exists if we didn't set the component flag
|
||||||
var err error
|
var err error
|
||||||
cmp, err = component.GetCurrent(app, ns)
|
cmp, err = component.GetCurrent(app, ns)
|
||||||
util.CheckError(err, "could not get current component")
|
util.LogErrorAndExit(err, "could not get current component")
|
||||||
} else {
|
} else {
|
||||||
// if flag is set, check that the specified component exists
|
// if flag is set, check that the specified component exists
|
||||||
context.checkComponentExistsOrFail(cmpFlag)
|
context.checkComponentExistsOrFail(cmpFlag)
|
||||||
@@ -190,7 +190,7 @@ func (o *Context) ComponentAllowingEmpty(allowEmpty bool, optionalComponent ...s
|
|||||||
// existsOrExit checks if the specified component exists with the given context and exits the app if not.
|
// existsOrExit checks if the specified component exists with the given context and exits the app if not.
|
||||||
func (o *Context) checkComponentExistsOrFail(cmp string) {
|
func (o *Context) checkComponentExistsOrFail(cmp string) {
|
||||||
exists, err := component.Exists(o.Client, cmp, o.Application)
|
exists, err := component.Exists(o.Client, cmp, o.Application)
|
||||||
util.CheckError(err, "")
|
util.LogErrorAndExit(err, "")
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("Component %v does not exist in application %s", cmp, o.Application)
|
log.Errorf("Component %v does not exist in application %s", cmp, o.Application)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import (
|
|||||||
"github.com/redhat-developer/odo/pkg/url"
|
"github.com/redhat-developer/odo/pkg/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CheckError prints the cause of the given error and exits the code with an
|
// LogErrorAndExit prints the cause of the given error and exits the code with an
|
||||||
// exit code of 1.
|
// exit code of 1.
|
||||||
// If the context is provided, then that is printed, if not, then the cause is
|
// If the context is provided, then that is printed, if not, then the cause is
|
||||||
// detected using errors.Cause(err)
|
// detected using errors.Cause(err)
|
||||||
func CheckError(err error, context string, a ...interface{}) {
|
func LogErrorAndExit(err error, context string, a ...interface{}) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(4).Infof("Error:\n%v", err)
|
glog.V(4).Infof("Error:\n%v", err)
|
||||||
if context == "" {
|
if context == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user