This repository was archived by the owner on Jul 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +43
-11
lines changed Expand file tree Collapse file tree 2 files changed +43
-11
lines changed Original file line number Diff line number Diff line change @@ -2,29 +2,26 @@ package cmd
2
2
3
3
import (
4
4
"fmt"
5
+ "os"
5
6
7
+ "github.com/docker/lunchbox/packager"
6
8
"github.com/spf13/cobra"
7
9
)
8
10
9
11
// inspectCmd represents the inspect command
10
12
var inspectCmd = & cobra.Command {
11
13
Use : "inspect <app-name>" ,
12
14
Short : "Retrieve metadata for a given app package" ,
15
+ Args : cobra .ExactArgs (1 ),
13
16
Run : func (cmd * cobra.Command , args []string ) {
14
- fmt .Println ("inspect called" )
17
+ err := packager .Inspect (args [0 ])
18
+ if err != nil {
19
+ fmt .Printf ("%v\n " , err )
20
+ os .Exit (1 )
21
+ }
15
22
},
16
23
}
17
24
18
25
func init () {
19
26
rootCmd .AddCommand (inspectCmd )
20
-
21
- // Here you will define your flags and configuration settings.
22
-
23
- // Cobra supports Persistent Flags which will work for this command
24
- // and all subcommands, e.g.:
25
- // inspectCmd.PersistentFlags().String("foo", "", "A help for foo")
26
-
27
- // Cobra supports local flags which will only run when this command
28
- // is called directly, e.g.:
29
- // inspectCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
30
27
}
Original file line number Diff line number Diff line change
1
+ package packager
2
+
3
+ import (
4
+ "fmt"
5
+ "io/ioutil"
6
+ "path"
7
+
8
+ "github.com/docker/lunchbox/types"
9
+ yaml "gopkg.in/yaml.v2"
10
+ )
11
+
12
+ // Inspect dumps the metadata of an app
13
+ func Inspect (appname string ) error {
14
+ appname , cleanup , err := Extract (appname )
15
+ if err != nil {
16
+ return err
17
+ }
18
+ defer cleanup ()
19
+ metaFile := path .Join (appname , "metadata.yml" )
20
+ metaContent , err := ioutil .ReadFile (metaFile )
21
+ if err != nil {
22
+ return err
23
+ }
24
+ var meta types.AppMetadata
25
+ err = yaml .Unmarshal (metaContent , & meta )
26
+ if err != nil {
27
+ return err
28
+ }
29
+ smeta , err := yaml .Marshal (meta )
30
+ if err != nil {
31
+ return err
32
+ }
33
+ fmt .Println (string (smeta ))
34
+ return nil
35
+ }
You can’t perform that action at this time.
0 commit comments