add info message when there is no hub index (#492)
This commit is contained in:
parent
0be78d4cbf
commit
a16fb1475d
|
@ -126,6 +126,7 @@ func NewCapiCmd() *cobra.Command {
|
||||||
}
|
}
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to load hub index : %s", err)
|
log.Fatalf("Failed to load hub index : %s", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
scenarios, err := cwhub.GetUpstreamInstalledScenariosAsString()
|
scenarios, err := cwhub.GetUpstreamInstalledScenariosAsString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -43,7 +43,8 @@ func NewCollectionsCmd() *cobra.Command {
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
InstallItem(name, cwhub.COLLECTIONS, forceInstall)
|
InstallItem(name, cwhub.COLLECTIONS, forceInstall)
|
||||||
|
@ -63,6 +64,7 @@ func NewCollectionsCmd() *cobra.Command {
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
|
|
||||||
if removeAll {
|
if removeAll {
|
||||||
|
@ -87,6 +89,7 @@ func NewCollectionsCmd() *cobra.Command {
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
if upgradeAll {
|
if upgradeAll {
|
||||||
UpgradeConfig(cwhub.COLLECTIONS, "", forceUpgrade)
|
UpgradeConfig(cwhub.COLLECTIONS, "", forceUpgrade)
|
||||||
|
@ -109,7 +112,8 @@ func NewCollectionsCmd() *cobra.Command {
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
InspectItem(name, cwhub.COLLECTIONS)
|
InspectItem(name, cwhub.COLLECTIONS)
|
||||||
|
@ -127,7 +131,8 @@ func NewCollectionsCmd() *cobra.Command {
|
||||||
Args: cobra.ExactArgs(0),
|
Args: cobra.ExactArgs(0),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
ListItem(cwhub.COLLECTIONS, args)
|
ListItem(cwhub.COLLECTIONS, args)
|
||||||
},
|
},
|
||||||
|
|
|
@ -297,7 +297,8 @@ func NewConfigCmd() *cobra.Command {
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var err error
|
var err error
|
||||||
if err = cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err = cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
if err = backupConfigToDirectory(args[0]); err != nil {
|
if err = backupConfigToDirectory(args[0]); err != nil {
|
||||||
log.Fatalf("Failed to backup configurations: %s", err)
|
log.Fatalf("Failed to backup configurations: %s", err)
|
||||||
|
@ -321,7 +322,8 @@ func NewConfigCmd() *cobra.Command {
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var err error
|
var err error
|
||||||
if err = cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err = cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
if err := restoreConfigFromDirectory(args[0]); err != nil {
|
if err := restoreConfigFromDirectory(args[0]); err != nil {
|
||||||
log.Fatalf("failed restoring configurations from %s : %s", args[0], err)
|
log.Fatalf("failed restoring configurations from %s : %s", args[0], err)
|
||||||
|
|
|
@ -42,6 +42,7 @@ cscli hub update # Download list of available configurations from the hub
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
|
|
||||||
cwhub.DisplaySummary()
|
cwhub.DisplaySummary()
|
||||||
|
|
|
@ -129,6 +129,7 @@ Keep in mind the machine needs to be validated by an administrator on LAPI side
|
||||||
}
|
}
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to load hub index : %s", err)
|
log.Fatalf("Failed to load hub index : %s", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
scenarios, err := cwhub.GetUpstreamInstalledScenariosAsString()
|
scenarios, err := cwhub.GetUpstreamInstalledScenariosAsString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -47,7 +47,8 @@ cscli parsers remove crowdsecurity/sshd-logs
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
InstallItem(name, cwhub.PARSERS, forceInstall)
|
InstallItem(name, cwhub.PARSERS, forceInstall)
|
||||||
|
@ -67,6 +68,7 @@ cscli parsers remove crowdsecurity/sshd-logs
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
|
|
||||||
if removeAll {
|
if removeAll {
|
||||||
|
@ -91,6 +93,7 @@ cscli parsers remove crowdsecurity/sshd-logs
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
if upgradeAll {
|
if upgradeAll {
|
||||||
UpgradeConfig(cwhub.PARSERS, "", forceUpgrade)
|
UpgradeConfig(cwhub.PARSERS, "", forceUpgrade)
|
||||||
|
@ -113,7 +116,8 @@ cscli parsers remove crowdsecurity/sshd-logs
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
InspectItem(args[0], cwhub.PARSERS)
|
InspectItem(args[0], cwhub.PARSERS)
|
||||||
},
|
},
|
||||||
|
@ -129,7 +133,8 @@ cscli parsers remove crowdsecurity/sshd-logs
|
||||||
cscli parser list crowdsecurity/xxx`,
|
cscli parser list crowdsecurity/xxx`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
ListItem(cwhub.PARSERS, args)
|
ListItem(cwhub.PARSERS, args)
|
||||||
},
|
},
|
||||||
|
|
|
@ -46,7 +46,8 @@ func NewPostOverflowsCmd() *cobra.Command {
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
InstallItem(name, cwhub.PARSERS_OVFLW, forceInstall)
|
InstallItem(name, cwhub.PARSERS_OVFLW, forceInstall)
|
||||||
|
@ -66,6 +67,7 @@ func NewPostOverflowsCmd() *cobra.Command {
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
|
|
||||||
if removeAll {
|
if removeAll {
|
||||||
|
@ -90,6 +92,7 @@ func NewPostOverflowsCmd() *cobra.Command {
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
if upgradeAll {
|
if upgradeAll {
|
||||||
UpgradeConfig(cwhub.PARSERS_OVFLW, "", forceUpgrade)
|
UpgradeConfig(cwhub.PARSERS_OVFLW, "", forceUpgrade)
|
||||||
|
@ -112,7 +115,8 @@ func NewPostOverflowsCmd() *cobra.Command {
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
InspectItem(args[0], cwhub.PARSERS_OVFLW)
|
InspectItem(args[0], cwhub.PARSERS_OVFLW)
|
||||||
},
|
},
|
||||||
|
@ -127,7 +131,8 @@ func NewPostOverflowsCmd() *cobra.Command {
|
||||||
cscli postoverflows list crowdsecurity/xxx`,
|
cscli postoverflows list crowdsecurity/xxx`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
ListItem(cwhub.PARSERS_OVFLW, args)
|
ListItem(cwhub.PARSERS_OVFLW, args)
|
||||||
},
|
},
|
||||||
|
|
|
@ -47,7 +47,8 @@ cscli scenarios remove crowdsecurity/ssh-bf
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
InstallItem(name, cwhub.SCENARIOS, forceInstall)
|
InstallItem(name, cwhub.SCENARIOS, forceInstall)
|
||||||
|
@ -67,6 +68,7 @@ cscli scenarios remove crowdsecurity/ssh-bf
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
|
|
||||||
if removeAll {
|
if removeAll {
|
||||||
|
@ -91,6 +93,7 @@ cscli scenarios remove crowdsecurity/ssh-bf
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("Failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
if upgradeAll {
|
if upgradeAll {
|
||||||
UpgradeConfig(cwhub.SCENARIOS, "", forceUpgrade)
|
UpgradeConfig(cwhub.SCENARIOS, "", forceUpgrade)
|
||||||
|
@ -113,7 +116,8 @@ cscli scenarios remove crowdsecurity/ssh-bf
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
InspectItem(args[0], cwhub.SCENARIOS)
|
InspectItem(args[0], cwhub.SCENARIOS)
|
||||||
},
|
},
|
||||||
|
@ -129,7 +133,8 @@ cscli scenarios remove crowdsecurity/ssh-bf
|
||||||
cscli scenarios list crowdsecurity/xxx`,
|
cscli scenarios list crowdsecurity/xxx`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
ListItem(cwhub.SCENARIOS, args)
|
ListItem(cwhub.SCENARIOS, args)
|
||||||
},
|
},
|
||||||
|
|
|
@ -126,7 +126,8 @@ cscli simulation disable crowdsecurity/ssh-bf`,
|
||||||
Example: `cscli simulation enable`,
|
Example: `cscli simulation enable`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
if err := cwhub.GetHubIdx(csConfig.Cscli); err != nil {
|
||||||
log.Fatalf("failed to get Hub index : %v", err)
|
log.Fatalf("Failed to get Hub index : %v", err)
|
||||||
|
log.Infoln("Run 'sudo cscli hub update' to get the hub index")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
|
|
|
@ -342,7 +342,6 @@ func GetHubIdx(cscli *csconfig.CscliCfg) error {
|
||||||
bidx, err := ioutil.ReadFile(cscli.HubIndexFile)
|
bidx, err := ioutil.ReadFile(cscli.HubIndexFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "unable to read index file")
|
return errors.Wrap(err, "unable to read index file")
|
||||||
log.Fatalf("Unable to read downloaded index : %v. Please run update", err)
|
|
||||||
}
|
}
|
||||||
ret, err := LoadPkgIndex(bidx)
|
ret, err := LoadPkgIndex(bidx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue