mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
make cscli use crowdsec version for hub (#194)
This commit is contained in:
parent
b81c735d81
commit
b7286d6a85
11 changed files with 89 additions and 7 deletions
|
@ -1,5 +1,11 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
||||
"github.com/crowdsecurity/crowdsec/pkg/cwversion"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func inSlice(s string, slice []string) bool {
|
||||
for _, str := range slice {
|
||||
if s == str {
|
||||
|
@ -17,3 +23,27 @@ func indexOf(s string, slice []string) int {
|
|||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func setHubBranch() error {
|
||||
/*
|
||||
if no branch has been specified in flags for the hub, then use the one corresponding to crowdsec version
|
||||
*/
|
||||
|
||||
if cwhub.HubBranch == "" {
|
||||
latest, err := cwversion.Latest()
|
||||
if err != nil {
|
||||
cwhub.HubBranch = "master"
|
||||
return err
|
||||
}
|
||||
|
||||
if cwversion.Version == latest {
|
||||
cwhub.HubBranch = "master"
|
||||
} else {
|
||||
log.Warnf("Crowdsec is not the latest version. Current version is '%s' and latest version is '%s'. Please update it!", cwversion.Version, latest)
|
||||
log.Warnf("As a result, you will not be able to use parsers/scenarios/collections added to Crowdsec Hub after CrowdSec %s", latest)
|
||||
cwhub.HubBranch = cwversion.Version
|
||||
}
|
||||
log.Debugf("Using branch '%s' for the hub", cwhub.HubBranch)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue