Skip to content

Commit

Permalink
Implement tape pull
Browse files Browse the repository at this point in the history
  • Loading branch information
errordeveloper committed Sep 18, 2023
1 parent 8033508 commit 1e1d9db
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tape/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ func Run() int {
tape: tape,
InputManifestDirOptions: InputManifestDirOptions{}},
},
{
name: "pull",
short: "Pull an artefact",
options: &TapePullCommand{
tape: tape,
OutputManifestDirOptions: OutputManifestDirOptions{},
},
},
}

for _, c := range commands {
Expand Down
38 changes: 38 additions & 0 deletions tape/app/pull.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package app

import (
"context"
"fmt"

"github.com/docker/labs-brown-tape/oci"
)

type TapePullCommand struct {
tape *TapeCommand
OutputManifestDirOptions

Image string `short:"I" long:"image" description:"Name of the image to pull" required:"true"`
}

func (c *TapePullCommand) Execute(args []string) error {
ctx := context.WithValue(c.tape.ctx, "command", "pull")
if len(args) != 0 {
return fmt.Errorf("unexpected arguments: %v", args)
}

if err := c.tape.Init(); err != nil {
return err
}

client := oci.NewClient(nil)

artefacts, err := client.SelectArtefacts(ctx, c.Image) // oci.ContentMediaType, oci.AttestMediaType)
if err != nil {
return err
}

for i := range artefacts {
fmt.Println(artefacts[i].MediaType, artefacts[i].Annotations)
}
return nil
}

0 comments on commit 1e1d9db

Please sign in to comment.