update c/image

* progress bar: use spinners for unknown blob sizes
 * improve README.md and the review of the changes
 * use 'containers_image_ostree' as build tag
 * ostree: default is no OStree support
 * Add "Env" to ImageInspectInfo
 * config.go: improve debug message
 * config.go: log where credentials come from

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2019-07-17 08:05:37 +02:00
parent 5c1ce1e033
commit 36723bc118
33 changed files with 490 additions and 325 deletions

View File

@@ -597,15 +597,32 @@ func (c *copier) createProgressBar(pool *mpb.Progress, info types.BlobInfo, kind
prefix = prefix[:maxPrefixLen]
}
bar := pool.AddBar(info.Size,
mpb.BarClearOnComplete(),
mpb.PrependDecorators(
decor.Name(prefix),
),
mpb.AppendDecorators(
decor.OnComplete(decor.CountersKibiByte("%.1f / %.1f"), " "+onComplete),
),
)
// Use a normal progress bar when we know the size (i.e., size > 0).
// Otherwise, use a spinner to indicate that something's happening.
var bar *mpb.Bar
if info.Size > 0 {
bar = pool.AddBar(info.Size,
mpb.BarClearOnComplete(),
mpb.PrependDecorators(
decor.Name(prefix),
),
mpb.AppendDecorators(
decor.OnComplete(decor.CountersKibiByte("%.1f / %.1f"), " "+onComplete),
),
)
} else {
bar = pool.AddSpinner(info.Size,
mpb.SpinnerOnLeft,
mpb.BarClearOnComplete(),
mpb.SpinnerStyle([]string{".", "..", "...", "....", ""}),
mpb.PrependDecorators(
decor.Name(prefix),
),
mpb.AppendDecorators(
decor.OnComplete(decor.Name(""), " "+onComplete),
),
)
}
if c.progressOutput == ioutil.Discard {
c.Printf("Copying %s %s\n", kind, info.Digest)
}

View File

@@ -226,6 +226,7 @@ func (m *Schema1) Inspect(_ func(types.BlobInfo) ([]byte, error)) (*types.ImageI
}
if s1.Config != nil {
i.Labels = s1.Config.Labels
i.Env = s1.Config.Env
}
return i, nil
}

View File

@@ -241,6 +241,7 @@ func (m *Schema2) Inspect(configGetter func(types.BlobInfo) ([]byte, error)) (*t
}
if s2.Config != nil {
i.Labels = s2.Config.Labels
i.Env = s2.Config.Env
}
return i, nil
}

View File

@@ -116,6 +116,7 @@ func (m *OCI1) Inspect(configGetter func(types.BlobInfo) ([]byte, error)) (*type
Architecture: v1.Architecture,
Os: v1.OS,
Layers: layerInfosToStrings(m.LayerInfos()),
Env: d1.Config.Env,
}
return i, nil
}

View File

@@ -1,4 +1,4 @@
// +build !containers_image_ostree_stub
// +build containers_image_ostree
package ostree

View File

@@ -1,4 +1,4 @@
// +build !containers_image_ostree_stub
// +build containers_image_ostree
package ostree

View File

@@ -1,4 +1,4 @@
// +build !containers_image_ostree_stub
// +build containers_image_ostree
package ostree

View File

@@ -56,6 +56,7 @@ func SetAuthentication(sys *types.SystemContext, registry, username, password st
// If an entry is not found empty strings are returned for the username and password
func GetAuthentication(sys *types.SystemContext, registry string) (string, string, error) {
if sys != nil && sys.DockerAuthConfig != nil {
logrus.Debug("Returning credentials from DockerAuthConfig")
return sys.DockerAuthConfig.Username, sys.DockerAuthConfig.Password, nil
}
@@ -76,12 +77,15 @@ func GetAuthentication(sys *types.SystemContext, registry string) (string, strin
legacyFormat := path == dockerLegacyPath
username, password, err := findAuthentication(registry, path, legacyFormat)
if err != nil {
logrus.Debugf("Credentials not found")
return "", "", err
}
if username != "" && password != "" {
logrus.Debugf("Returning credentials from %s", path)
return username, password, nil
}
}
logrus.Debugf("Credentials not found")
return "", "", nil
}

View File

@@ -1,4 +1,4 @@
// +build !containers_image_ostree_stub,linux
// +build containers_image_ostree,linux
package alltransports

View File

@@ -1,4 +1,4 @@
// +build containers_image_ostree_stub !linux
// +build !containers_image_ostree !linux
package alltransports

View File

@@ -398,6 +398,7 @@ type ImageInspectInfo struct {
Architecture string
Os string
Layers []string
Env []string
}
// DockerAuthConfig contains authorization information for connecting to a registry.