Skip to content

Commit

Permalink
Manifest List Interface (#191)
Browse files Browse the repository at this point in the history
Implement image index interface in support of https://github.com/buildpacks/rfcs/blob/main/text/0124-pack-manifest-list-commands.md
and buildpacks/pack#1705

Signed-off-by: Husni Faiz <[email protected]>
Signed-off-by: Juan Bustamante <[email protected]>
Signed-off-by: Natalie Arellano <[email protected]>
Signed-off-by: Sai Kiran <[email protected]>
Signed-off-by: Sai Kiran Maggidi <[email protected]>
Signed-off-by: WYGIN <[email protected]>
Signed-off-by: WYGIN <[email protected]>
  • Loading branch information
husni-faiz authored May 7, 2024
1 parent 30b0025 commit 9f7b96c
Show file tree
Hide file tree
Showing 26 changed files with 2,183 additions and 217 deletions.
4 changes: 2 additions & 2 deletions acceptance/reproducibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ func testReproducibility(t *testing.T, _ spec.G, it spec.S) {
it.Before(func() {
dockerClient = h.DockerCli(t)

daemonInfo, err := dockerClient.Info(context.TODO())
daemonInfo, err := dockerClient.ServerVersion(context.TODO())
h.AssertNil(t, err)

daemonOS := daemonInfo.OSType
daemonOS := daemonInfo.Os

runnableBaseImageName = h.RunnableBaseImage(daemonOS)
h.PullIfMissing(t, dockerClient, runnableBaseImageName)
Expand Down
37 changes: 35 additions & 2 deletions cnb_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,25 @@ func (i *CNBImageCore) OSVersion() (string, error) {
return configFile.OSVersion, nil
}

func (i *CNBImageCore) OSFeatures() ([]string, error) {
configFile, err := getConfigFile(i.Image)
if err != nil {
return nil, err
}
return configFile.OSFeatures, nil
}

func (i *CNBImageCore) Annotations() (map[string]string, error) {
manifest, err := getManifest(i.Image)
if err != nil {
return nil, err
}
if manifest.Annotations == nil {
return make(map[string]string), nil
}
return manifest.Annotations, nil
}

func (i *CNBImageCore) TopLayer() (string, error) {
layers, err := i.Image.Layers()
if err != nil {
Expand Down Expand Up @@ -202,18 +221,26 @@ func (i *CNBImageCore) WorkingDir() (string, error) {
}

func (i *CNBImageCore) AnnotateRefName(refName string) error {
return i.SetAnnotations(map[string]string{
"org.opencontainers.image.ref.name": refName,
})
}

func (i *CNBImageCore) SetAnnotations(annotations map[string]string) error {
manifest, err := getManifest(i.Image)
if err != nil {
return err
}
if manifest.Annotations == nil {
manifest.Annotations = make(map[string]string)
}
manifest.Annotations["org.opencontainers.image.ref.name"] = refName
for k, v := range annotations {
manifest.Annotations[k] = v
}
mutated := mutate.Annotations(i.Image, manifest.Annotations)
image, ok := mutated.(v1.Image)
if !ok {
return fmt.Errorf("failed to add annotation")
return fmt.Errorf("failed to add annotations")
}
i.Image = image
return nil
Expand Down Expand Up @@ -285,6 +312,12 @@ func (i *CNBImageCore) SetOS(osVal string) error {
})
}

func (i *CNBImageCore) SetOSFeatures(osFeatures []string) error {
return i.MutateConfigFile(func(c *v1.ConfigFile) {
c.OSFeatures = osFeatures
})
}

// TBD Deprecated: SetOSVersion
func (i *CNBImageCore) SetOSVersion(osVersion string) error {
return i.MutateConfigFile(func(c *v1.ConfigFile) {
Expand Down
Loading

0 comments on commit 9f7b96c

Please sign in to comment.