Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Add SafeURL helper method to GitRemoteConfig
Browse files Browse the repository at this point in the history
During the development of the (secure) Git HTTPS credential feature,
I did not take the response of the `GitRepoConfig` API method into
account. As a direct result, the `fluxctl sync` command still exposes
the full Git URL in the logs.

This commit embeds the `git.Remote` in the `GitRemoteConfig` structure,
so that we can re-use the `SafeURL` helper of this structure in the
`fluxctl` code. To ensure the JSON representation stays the same, a
JSON struct tag has been added to the `git.Remote` URL field.
  • Loading branch information
hiddeco committed Oct 24, 2019
1 parent 28db2f5 commit f4a94c0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/fluxctl/sync_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +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))
return fmt.Errorf("git repository %s is not ready to sync (status: %s)", gitConfig.Remote.SafeURL(), string(gitConfig.Status))
}

fmt.Fprintf(cmd.OutOrStderr(), "Synchronizing with %s\n", gitConfig.Remote.URL)
fmt.Fprintf(cmd.OutOrStderr(), "Synchronizing with %s\n", gitConfig.Remote.SafeURL())

updateSpec := update.Spec{
Type: update.Sync,
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v6/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type ControllerStatus struct {
// --- config types

type GitRemoteConfig struct {
URL string `json:"url"`
git.Remote
Branch string `json:"branch"`
Path string `json:"path"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ func (d *Daemon) GitRepoConfig(ctx context.Context, regenerate bool) (v6.GitConf
}
return v6.GitConfig{
Remote: v6.GitRemoteConfig{
URL: origin.URL,
Remote: origin,
Branch: d.GitConfig.Branch,
Path: path,
},
Expand Down
3 changes: 2 additions & 1 deletion pkg/git/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (

// Remote points at a git repo somewhere.
type Remote struct {
URL string // clone from here
// URL is where we clone from
URL string `json:"url"`
}

func (r Remote) SafeURL() string {
Expand Down

0 comments on commit f4a94c0

Please sign in to comment.