Skip to content

Commit

Permalink
fix: change PathSeparator and PushPath description
Browse files Browse the repository at this point in the history
Signed-off-by: lukeb2e <12938238+lukeb2e@users.noreply.github.com>
  • Loading branch information
lukeb2e committed Apr 9, 2019
1 parent a12e764 commit 81f6cc8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions api/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type PushConfig struct {
Registry string
// UpdateChanged tells us if we will re-push (update/overwrite) images having same tag, but different digest
UpdateChanged bool
// PathSeperator defines which path seperator to use (default: "/")
PathSeperator string
// PathSeparator defines which path separator to use (default: "/")
PathSeparator string
}

// API represents configured application API instance,
Expand Down Expand Up @@ -243,7 +243,7 @@ func (api *API) CollectPushTags(cn *collection.Collection, push PushConfig) (*co
pushRef := fmt.Sprintf(
"%s%s~/.*/",
push.Registry,
getPushPrefix(push.Prefix, repo.PushPrefix())+repo.PushPath(push.PathSeperator),
getPushPrefix(push.Prefix, repo.PushPrefix())+repo.PushPath(push.PathSeparator),
)

log.Debugf("%s 'push' reference: %+v", fn(repo.Ref()), pushRef)
Expand Down Expand Up @@ -385,7 +385,7 @@ func (api *API) PushTags(cn *collection.Collection, push PushConfig) error {
go func(repo *repository.Repository, tags []*tag.Tag, done chan error) {
for _, tg := range tags {
srcRef := repo.Name() + ":" + tg.Name()
dstRef := push.Registry + getPushPrefix(push.Prefix, repo.PushPrefix()) + repo.PushPath(push.PathSeperator) + ":" + tg.Name()
dstRef := push.Registry + getPushPrefix(push.Prefix, repo.PushPrefix()) + repo.PushPath(push.PathSeparator) + ":" + tg.Name()

log.Infof("[PULL/PUSH] PUSHING %s => %s", srcRef, dstRef)

Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Options struct {
PushRegistry string `short:"r" long:"push-registry" description:"[Re]Push pulled images to a specified remote registry" env:"PUSH_REGISTRY"`
PushPrefix string `short:"R" long:"push-prefix" description:"[Re]Push pulled images with a specified repo path prefix" env:"PUSH_PREFIX"`
PushUpdate bool `short:"U" long:"push-update" description:"Update our pushed images if remote image digest changes" env:"PUSH_UPDATE"`
PathSeperator string `short:"s" long:"path-seperator" default:"/" description:"Configure path seperator for registries that only allow single folder depth" env:"PATH_SEPERATOR"`
PathSeparator string `short:"s" long:"path-separator" default:"/" description:"Configure path separator for registries that only allow single folder depth" env:"PATH_SEPARATOR"`
ConcurrentRequests int `short:"c" long:"concurrent-requests" default:"32" description:"Limit of concurrent requests to the registry" env:"CONCURRENT_REQUESTS"`
WaitBetween time.Duration `short:"w" long:"wait-between" default:"0" description:"Time to wait between batches of requests (incl. pulls and pushes)" env:"WAIT_BETWEEN"`
RetryRequests int `short:"y" long:"retry-requests" default:"2" description:"Number of retries for failed Docker registry requests" env:"RETRY_REQUESTS"`
Expand Down Expand Up @@ -163,7 +163,7 @@ func main() {
Registry: o.PushRegistry,
Prefix: o.PushPrefix,
UpdateChanged: o.PushUpdate,
PathSeperator: o.PathSeperator,
PathSeparator: o.PathSeparator,
}

pushCollection, err := api.CollectPushTags(collection, pushConfig)
Expand Down
6 changes: 3 additions & 3 deletions repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func (r *Repository) Path() string {
return path
}

// PushPath gives us sanitized repository path and checks if subdirectories are allowed
func (r *Repository) PushPath(pathSeperator string) string {
// PushPath returns a repository path with a custom path element separator
func (r *Repository) PushPath(pathSeparator string) string {
path := r.Path()

path = strings.Join(strings.Split(path, "/"), pathSeperator)
path = strings.Join(strings.Split(path, "/"), pathSeparator)

return path
}
Expand Down

0 comments on commit 81f6cc8

Please sign in to comment.