-
Notifications
You must be signed in to change notification settings - Fork 24
/
push.go
38 lines (32 loc) · 976 Bytes
/
push.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
38
package images
import (
"github.com/containers/podman-tui/pdcs/registry"
"github.com/containers/podman/v5/pkg/bindings/images"
"github.com/rs/zerolog/log"
)
// ImagePushOptions image push options.
type ImagePushOptions struct {
Destination string
Compress bool
Format string
SkipTLSVerify bool
AuthFile string
Username string
Password string
}
// Push push a source image to a specified destination.
func Push(id string, opts ImagePushOptions) error {
log.Debug().Msgf("pdcs: podman image push %s", id)
conn, err := registry.GetConnection()
if err != nil {
return err
}
pushOptions := new(images.PushOptions)
pushOptions.WithCompress(opts.Compress)
pushOptions.WithFormat(opts.Format)
pushOptions.WithSkipTLSVerify(opts.SkipTLSVerify)
pushOptions.WithAuthfile(opts.AuthFile)
pushOptions.WithUsername(opts.Username)
pushOptions.WithPassword(opts.Password)
return images.Push(conn, id, opts.Destination, pushOptions)
}