Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 343f135

Browse files
committed
Fixed loading of metadata
1 parent f167540 commit 343f135

File tree

5 files changed

+47
-2
lines changed

5 files changed

+47
-2
lines changed

cmd/docker-setup/describe.go

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"gopkg.in/yaml.v3"
99

10+
log "github.com/sirupsen/logrus"
1011
"github.com/spf13/cobra"
1112
)
1213

@@ -25,6 +26,14 @@ var describeCmd = &cobra.Command{
2526
Long: header + "\nShow detailed information about tools",
2627
Args: cobra.ExactArgs(1),
2728
ValidArgs: tools.GetNames(),
29+
PreRunE: func(cmd *cobra.Command, args []string) error {
30+
if fileExists(prefix + "/" + metadataFile) {
31+
log.Tracef("Loaded metadata file from %s", prefix+"/"+metadataFile)
32+
loadMetadata()
33+
}
34+
35+
return nil
36+
},
2837
RunE: func(cmd *cobra.Command, args []string) error {
2938
assertMetadataFileExists()
3039
assertMetadataIsLoaded()

cmd/docker-setup/inspect.go

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55

6+
log "github.com/sirupsen/logrus"
67
"github.com/spf13/cobra"
78
//log "github.com/sirupsen/logrus"
89
//"github.com/fatih/color"
@@ -18,6 +19,14 @@ var inspectCmd = &cobra.Command{
1819
Long: header + "\nInspect tools",
1920
Args: cobra.ExactArgs(1),
2021
ValidArgs: tools.GetNames(),
22+
PreRunE: func(cmd *cobra.Command, args []string) error {
23+
if fileExists(prefix + "/" + metadataFile) {
24+
log.Tracef("Loaded metadata file from %s", prefix+"/"+metadataFile)
25+
loadMetadata()
26+
}
27+
28+
return nil
29+
},
2130
RunE: func(cmd *cobra.Command, args []string) error {
2231
assertMetadataFileExists()
2332
assertMetadataIsLoaded()

cmd/docker-setup/list.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
log "github.com/sirupsen/logrus"
45
"github.com/spf13/cobra"
56
)
67

@@ -14,7 +15,15 @@ var listCmd = &cobra.Command{
1415
Short: "List tools",
1516
Long: header + "\nList tools",
1617
Args: cobra.NoArgs,
17-
RunE: func(cmd *cobra.Command, args []string) error {
18+
PreRunE: func(cmd *cobra.Command, args []string) error {
19+
if fileExists(prefix + "/" + metadataFile) {
20+
log.Tracef("Loaded metadata file from %s", prefix+"/"+metadataFile)
21+
loadMetadata()
22+
}
23+
24+
return nil
25+
},
26+
RunE: func(cmd *cobra.Command, args []string) error {
1827
assertMetadataFileExists()
1928
assertMetadataIsLoaded()
2029

cmd/docker-setup/search.go

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55

6+
log "github.com/sirupsen/logrus"
67
"github.com/spf13/cobra"
78
)
89

@@ -24,6 +25,14 @@ var searchCmd = &cobra.Command{
2425
Long: header + "\nSearch for tools",
2526
Args: cobra.ExactArgs(1),
2627
ValidArgs: tools.GetNames(),
28+
PreRunE: func(cmd *cobra.Command, args []string) error {
29+
if fileExists(prefix + "/" + metadataFile) {
30+
log.Tracef("Loaded metadata file from %s", prefix+"/"+metadataFile)
31+
loadMetadata()
32+
}
33+
34+
return nil
35+
},
2736
RunE: func(cmd *cobra.Command, args []string) error {
2837
assertMetadataFileExists()
2938
assertMetadataIsLoaded()

cmd/docker-setup/tags.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"sort"
66

77
"github.com/jedib0t/go-pretty/v6/table"
8+
log "github.com/sirupsen/logrus"
89
"github.com/spf13/cobra"
910
)
1011

@@ -18,7 +19,15 @@ var tagsCmd = &cobra.Command{
1819
Short: "List tags",
1920
Long: header + "\nList tags",
2021
Args: cobra.NoArgs,
21-
RunE: func(cmd *cobra.Command, args []string) error {
22+
PreRunE: func(cmd *cobra.Command, args []string) error {
23+
if fileExists(prefix + "/" + metadataFile) {
24+
log.Tracef("Loaded metadata file from %s", prefix+"/"+metadataFile)
25+
loadMetadata()
26+
}
27+
28+
return nil
29+
},
30+
RunE: func(cmd *cobra.Command, args []string) error {
2231
assertMetadataFileExists()
2332
assertMetadataIsLoaded()
2433

0 commit comments

Comments
 (0)