mirror of
https://github.com/containers/skopeo.git
synced 2025-07-21 09:59:55 +00:00
Merge branch 'cmd-test' into HEAD
This commit is contained in:
commit
aa627d0844
@ -43,7 +43,7 @@ var inspectCmd = cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if c.Bool("raw") {
|
if c.Bool("raw") {
|
||||||
fmt.Println(string(rawManifest))
|
fmt.Fprintln(c.App.Writer, string(rawManifest))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
imgInspect, err := img.Inspect()
|
imgInspect, err := img.Inspect()
|
||||||
@ -77,7 +77,7 @@ var inspectCmd = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(string(out))
|
fmt.Fprintln(c.App.Writer, string(out))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@ const (
|
|||||||
usage = `interact with registries`
|
usage = `interact with registries`
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
// createApp returns a cli.App to be run or tested.
|
||||||
|
func createApp() *cli.App {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "skopeo"
|
app.Name = "skopeo"
|
||||||
if gitCommit != "" {
|
if gitCommit != "" {
|
||||||
@ -67,6 +68,11 @@ func main() {
|
|||||||
standaloneSignCmd,
|
standaloneSignCmd,
|
||||||
standaloneVerifyCmd,
|
standaloneVerifyCmd,
|
||||||
}
|
}
|
||||||
|
return app
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := createApp()
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
14
cmd/skopeo/main_test.go
Normal file
14
cmd/skopeo/main_test.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "bytes"
|
||||||
|
|
||||||
|
// runSkopeo creates an app object and runs it with args, with an implied first "skopeo".
|
||||||
|
// Returns output intended for stdout and the returned error, if any.
|
||||||
|
func runSkopeo(args ...string) (string, error) {
|
||||||
|
app := createApp()
|
||||||
|
stdout := bytes.Buffer{}
|
||||||
|
app.Writer = &stdout
|
||||||
|
args = append([]string{"skopeo"}, args...)
|
||||||
|
err := app.Run(args)
|
||||||
|
return stdout.String(), err
|
||||||
|
}
|
@ -70,7 +70,6 @@ func standaloneVerify(context *cli.Context) error {
|
|||||||
|
|
||||||
mech, err := signature.NewGPGSigningMechanism()
|
mech, err := signature.NewGPGSigningMechanism()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
return fmt.Errorf("Error initializing GPG: %v", err)
|
return fmt.Errorf("Error initializing GPG: %v", err)
|
||||||
}
|
}
|
||||||
sig, err := signature.VerifyDockerManifestSignature(unverifiedSignature, unverifiedManifest, expectedDockerReference, mech, expectedFingerprint)
|
sig, err := signature.VerifyDockerManifestSignature(unverifiedSignature, unverifiedManifest, expectedDockerReference, mech, expectedFingerprint)
|
||||||
@ -78,7 +77,7 @@ func standaloneVerify(context *cli.Context) error {
|
|||||||
return fmt.Errorf("Error verifying signature: %v", err)
|
return fmt.Errorf("Error verifying signature: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Signature verified, digest %s\n", sig.DockerManifestDigest)
|
fmt.Fprintf(context.App.Writer, "Signature verified, digest %s\n", sig.DockerManifestDigest)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user