| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package docker
- import (
- "context"
- "fmt"
- fw "git.buran.team/main/fairwind"
- moby "github.com/moby/moby/client"
- )
- type Registry struct {
- ctx context.Context
- log *fw.Log
- client *Docker
- address string
- login string
- password string
- }
- func NewRegistry(ctx context.Context, log *fw.Log, client *Docker, address string, login string, password string) *Registry {
- return &Registry{
- ctx: ctx,
- log: log,
- client: client,
- address: address,
- login: login,
- password: password,
- }
- }
- func (this *Registry) Address() string {
- return this.address
- }
- func (this *Registry) Authorize() error {
- _, err := this.client.Docker.RegistryLogin(
- this.ctx,
- moby.RegistryLoginOptions{
- ServerAddress: this.address,
- Username: this.login,
- Password: this.password,
- },
- )
- if err != nil {
- return fmt.Errorf("can't authorize in registry: %w", err)
- }
- return nil
- }
|