Skip to content

Commit

Permalink
Showing error in case of update failure, Fixes #25
Browse files Browse the repository at this point in the history
  • Loading branch information
dtchanpura committed Aug 16, 2020
1 parent 19589ab commit f54c3da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package cmd

import (
"fmt"
"os"

"github.com/dtchanpura/deployment-agent/config"
Expand Down Expand Up @@ -54,12 +55,12 @@ var addCmd = &cobra.Command{
project.WorkDir = workDir
// bts, _ := yaml.Marshal(project)
if err := project.ValidateProjectConfiguration(); err.Error() == constants.ErrorInvalidConfiguration {
// fmt.Println(err)
fmt.Println(err)
os.Exit(1)
}
err := manage.AddProject(cfgFile, project)
if err != nil {
// fmt.Println(err)
fmt.Println(err)
os.Exit(1)
}
// fmt.Println(string(bts[:]))
Expand Down
7 changes: 3 additions & 4 deletions config/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@ func UpdateConfiguration(cfgFile string, configuration Configuration, overwrite
func UpdateProject(cfgFile string, project Project) error {
_, err := FindProject(project.Name, project.UUID)
if err != nil && err.Error() == constants.ErrorNoProjectFound {
updateProjects(cfgFile, project)
// fmt.Println(err)
return nil
return updateProjects(cfgFile, project)
}
return errors.New(constants.ErrorProjectAlreadyExists)
}

func updateProjects(cfgFile string, projects ...Project) {
func updateProjects(cfgFile string, projects ...Project) error {
StoredProjects = append(StoredProjects, projects...)
configuration := Configuration{
ServeConfig: StoredServe,
ProjectConfigs: StoredProjects,
}
UpdateConfiguration(cfgFile, configuration, true)
return UpdateConfiguration(cfgFile, configuration, true)
}

func generateHash(input string) string {
Expand Down

0 comments on commit f54c3da

Please sign in to comment.