Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47738 from vvoland/c8d-walk-image-badimagetarget
c8d/list: Ignore unexpected image target
- Loading branch information
Showing
4 changed files
with
63 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package specialimage | ||
|
||
import ( | ||
"github.com/containerd/containerd/platforms" | ||
"github.com/distribution/reference" | ||
ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||
) | ||
|
||
// ConfigTarget creates an image index with an image config being used as an | ||
// image target instead of a manifest or index. | ||
func ConfigTarget(dir string) (*ocispec.Index, error) { | ||
const imageRef = "config:latest" | ||
|
||
ref, err := reference.ParseNormalizedNamed(imageRef) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
desc, err := writeJsonBlob(dir, ocispec.MediaTypeImageConfig, ocispec.Image{ | ||
Platform: platforms.MustParse("linux/amd64"), | ||
Config: ocispec.ImageConfig{ | ||
Env: []string{"FOO=BAR"}, | ||
}, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
desc.Annotations = map[string]string{ | ||
"io.containerd.image.name": ref.String(), | ||
} | ||
|
||
return ociImage(dir, ref, desc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters