Skip to content

Commit

Permalink
Merge pull request fluxcd#2765 from dinosk/issues/2657-fluxctl-sync-e…
Browse files Browse the repository at this point in the history
…rror-message

Add detailed error message in fluxctl sync
  • Loading branch information
2opremio authored Jan 29, 2020
2 parents fd6e2da + f42ab00 commit ed1f54f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd/fluxctl/sync_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ func (opts *syncOpts) RunE(cmd *cobra.Command, args []string) error {
case git.RepoReady:
break
default:
return fmt.Errorf("git repository %s is not ready to sync (status: %s)", gitConfig.Remote.URL, string(gitConfig.Status))
if gitConfig.Error != "" {
return fmt.Errorf("git repository %s is not ready to sync\n\nFull error message: %v", gitConfig.Remote.URL, gitConfig.Error)
}
return fmt.Errorf("git repository %s is not ready to sync", gitConfig.Remote.URL)
}

fmt.Fprintf(cmd.OutOrStderr(), "Synchronizing with %s\n", gitConfig.Remote.URL)
Expand Down
1 change: 1 addition & 0 deletions pkg/api/v6/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type GitConfig struct {
Remote GitRemoteConfig `json:"remote"`
PublicSSHKey ssh.PublicKey `json:"publicSSHKey"`
Status git.GitRepoStatus `json:"status"`
Error string `json:"errors"`
}

type Deprecated interface {
Expand Down
8 changes: 7 additions & 1 deletion pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,12 @@ func (d *Daemon) GitRepoConfig(ctx context.Context, regenerate bool) (v6.GitConf
origin := d.Repo.Origin()
// Sanitize the URL before sharing it
origin.URL = origin.SafeURL()
status, _ := d.Repo.Status()
status, err := d.Repo.Status()
gitConfigError := ""
if err != nil {
gitConfigError = err.Error()
}

path := ""
if len(d.GitConfig.Paths) > 0 {
path = strings.Join(d.GitConfig.Paths, ",")
Expand All @@ -637,6 +642,7 @@ func (d *Daemon) GitRepoConfig(ctx context.Context, regenerate bool) (v6.GitConf
},
PublicSSHKey: publicSSHKey,
Status: status,
Error: gitConfigError,
}, nil
}

Expand Down

0 comments on commit ed1f54f

Please sign in to comment.