civ/pkg/docker/docker.go

35 lines
703 B
Go
Raw Permalink Normal View History

2022-01-26 10:15:28 +00:00
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
}