Skip to content

Commit

Permalink
Merge pull request #144 from ethan256/master
Browse files Browse the repository at this point in the history
feat: support os/arch param
  • Loading branch information
hhyasdf authored Jan 10, 2024
2 parents d450c0a + b3a1240 commit abd2689
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (c *Client) Run() error {
for _, dest := range destList {
// TODO: support multiple destinations for one task
ruleTask, err := task.NewRuleTask(source, dest,
c.config.osFilterList, c.config.archFilterList,
func(repository string) types.Auth {
auth, exist := c.config.GetAuth(repository)
if !exist {
Expand Down
22 changes: 16 additions & 6 deletions pkg/task/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ type RuleTask struct {
source string
destination string

osFilterList, archFilterList []string

getAuthFunc func(repository string) types.Auth

forceUpdate bool
}

func NewRuleTask(source, destination string,
osFilterList, archFilterList []string,
getAuthFunc func(repository string) types.Auth, forceUpdate bool) (*RuleTask, error) {
if source == "" {
return nil, fmt.Errorf("source url should not be empty")
Expand All @@ -30,10 +33,12 @@ func NewRuleTask(source, destination string,
}

return &RuleTask{
source: source,
destination: destination,
getAuthFunc: getAuthFunc,
forceUpdate: forceUpdate,
source: source,
destination: destination,
getAuthFunc: getAuthFunc,
osFilterList: osFilterList,
archFilterList: archFilterList,
forceUpdate: forceUpdate,
}, nil
}

Expand Down Expand Up @@ -64,8 +69,13 @@ func (r *RuleTask) Run() ([]Task, string, error) {

var results []Task
for index, s := range sourceURLs {
results = append(results, NewURLTask(s, destinationURLs[index], r.getAuthFunc(s.GetURLWithoutTagOrDigest()),
r.getAuthFunc(destinationURLs[index].GetURLWithoutTagOrDigest()), r.forceUpdate))
results = append(results,
NewURLTask(s, destinationURLs[index],
r.getAuthFunc(s.GetURLWithoutTagOrDigest()),
r.getAuthFunc(destinationURLs[index].GetURLWithoutTagOrDigest()),
r.osFilterList, r.archFilterList, r.forceUpdate,
),
)
}

return results, "", nil
Expand Down
7 changes: 6 additions & 1 deletion pkg/task/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ type URLTask struct {
forceUpdate bool
}

func NewURLTask(source, destination *utils.RepoURL, sourceAuth, destinationAuth types.Auth, forceUpdate bool) Task {
func NewURLTask(source, destination *utils.RepoURL,
sourceAuth, destinationAuth types.Auth,
osFilterList, archFilterList []string,
forceUpdate bool) Task {
return &URLTask{
source: source,
destination: destination,
sourceAuth: sourceAuth,
destinationAuth: destinationAuth,
osFilterList: osFilterList,
archFilterList: archFilterList,
forceUpdate: forceUpdate,
}
}
Expand Down

0 comments on commit abd2689

Please sign in to comment.