Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support os/arch param #144

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading