Skip to content

Commit e907e82

Browse files
committed
style(review): update after review
Signed-off-by: Christopher Haar <[email protected]>
1 parent 10d95ec commit e907e82

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

cmd/crank/xpkg/extract.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@ const (
5252
errCreateOutputFile = "failed to create output file"
5353
errCreateGzipWriter = "failed to create gzip writer"
5454
errExtractPackageContents = "failed to extract package contents"
55-
)
56-
57-
const (
58-
layerAnnotation = "io.crossplane.xpkg"
59-
baseAnnotationValue = "base"
60-
cacheContentExt = ".gz"
55+
cacheContentExt = ".gz"
6156
)
6257

6358
// fetchFn fetches a package from a source.
@@ -129,8 +124,8 @@ type extractCmd struct {
129124
fetch fetchFn
130125

131126
Package string `arg:"" help:"Name of the package to extract. Must be a valid OCI image tag or a path if using --from-xpkg." optional:""`
132-
FromDaemon bool `help:"Indicates that the image should be fetched from the Docker daemon." xor:"xp-extract-from"`
133-
FromXpkg bool `help:"Indicates that the image should be fetched from a local xpkg. If package is not specified and only one exists in current directory it will be used." xor:"xp-extract-from"`
127+
FromDaemon bool `help:"Indicates that the image should be fetched from the Docker daemon."`
128+
FromXpkg bool `help:"Indicates that the image should be fetched from a local xpkg. If package is not specified and only one exists in current directory it will be used."`
134129
Output string `default:"out.gz" help:"Package output file path. Extension must be .gz or will be replaced." short:"o"`
135130

136131
// Common API configuration
@@ -158,7 +153,7 @@ func (c *extractCmd) Run(logger logging.Logger) error { //nolint:gocyclo // xpkg
158153
var tarc io.ReadCloser
159154
foundAnnotated := false
160155
for _, l := range manifest.Layers {
161-
if a, ok := l.Annotations[layerAnnotation]; !ok || a != baseAnnotationValue {
156+
if a, ok := l.Annotations[xpkg.AnnotationKey]; !ok || a != xpkg.PackageAnnotation {
162157
continue
163158
}
164159
if foundAnnotated {

cmd/crank/xpkg/extract_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ func TestExtractRun(t *testing.T) {
4848
randImg, _ := mutate.Append(empty.Image, mutate.Addendum{
4949
Layer: randLayer,
5050
Annotations: map[string]string{
51-
layerAnnotation: baseAnnotationValue,
51+
xpkg.AnnotationKey: xpkg.PackageAnnotation,
5252
},
5353
})
5454

5555
randImgDup, _ := mutate.Append(randImg, mutate.Addendum{
5656
Layer: randLayer,
5757
Annotations: map[string]string{
58-
layerAnnotation: baseAnnotationValue,
58+
xpkg.AnnotationKey: xpkg.PackageAnnotation,
5959
},
6060
})
6161

0 commit comments

Comments
 (0)