civ/pkg/docker/docker.go
Markus Pesch b82578fbf0
All checks were successful
continuous-integration/drone/push Build is passing
Initial Commit
2022-01-26 16:34:42 +01:00

35 lines
703 B
Go

package docker
import (
"context"
"log"
"git.cryptic.systems/volker.raschek/dockerutils"
)
type Runtime struct {
dockerClient *dockerutils.Client
}
func (r *Runtime) GetImageLabels(ctx context.Context, image string) (map[string]string, error) {
log.Printf("Pull image: %v", image)
if err := r.dockerClient.PullQuiet(ctx, image); err != nil {
return nil, err
}
log.Printf("Image successfully pulled: %v", image)
imageSpec, _, err := r.dockerClient.ImageInspectWithRaw(ctx, image)
if err != nil {
return nil, err
}
return imageSpec.Config.Labels, nil
}
func NewRuntime(dockerClient *dockerutils.Client) (*Runtime, error) {
return &Runtime{
dockerClient: dockerClient,
}, nil
}