-
Notifications
You must be signed in to change notification settings - Fork 63
/
push_option.go
37 lines (31 loc) · 1.04 KB
/
push_option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors.
// Licensed under the BSD-3-Clause License (the "License").
// You may not use this file except in compliance with the License.
package pack
// PushOptions contains the list of options which can be set whilst pushing a
// package.
type PushOptions struct {
onProgress func(progress float64)
}
// PushOption is an option function which is used to modify PushOptions.
type PushOption func(*PushOptions) error
// NewPushOptions creates PushOptions
func NewPushOptions(opts ...PushOption) (*PushOptions, error) {
options := &PushOptions{}
for _, o := range opts {
err := o(options)
if err != nil {
return nil, err
}
}
return options, nil
}
// WithPushProgressFunc set an optional progress function which is used as a
// callback during the transmission of the package and the host.
func WithPushProgressFunc(onProgress func(progress float64)) PushOption {
return func(opts *PushOptions) error {
opts.onProgress = onProgress
return nil
}
}