-
Notifications
You must be signed in to change notification settings - Fork 318
/
inspect.go
42 lines (35 loc) · 1.04 KB
/
inspect.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
39
40
41
42
package devcontainer
import (
"context"
"github.com/loft-sh/devpod/pkg/devcontainer/config"
"github.com/loft-sh/devpod/pkg/driver"
"github.com/loft-sh/devpod/pkg/image"
)
func (r *runner) inspectImage(ctx context.Context, imageName string) (*config.ImageDetails, error) {
dockerDriver, ok := r.Driver.(driver.DockerDriver)
if ok {
return dockerDriver.InspectImage(ctx, imageName)
}
// fallback to just looking into the remote registry
imageConfig, _, err := image.GetImageConfig(ctx, imageName)
if err != nil {
return nil, err
}
return &config.ImageDetails{
ID: imageName,
Config: config.ImageDetailsConfig{
User: imageConfig.Config.User,
Env: imageConfig.Config.Env,
Labels: imageConfig.Config.Labels,
Entrypoint: imageConfig.Config.Entrypoint,
Cmd: imageConfig.Config.Cmd,
},
}, nil
}
func (r *runner) getImageTag(ctx context.Context, imageID string) (string, error) {
dockerDriver, ok := r.Driver.(driver.DockerDriver)
if ok {
return dockerDriver.GetImageTag(ctx, imageID)
}
return "", nil
}