mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-10 20:05:55 +02:00
CI: pin hub branch during functional tests (#3526)
This commit is contained in:
parent
ea1a1d733b
commit
2dcc3ae0df
3 changed files with 49 additions and 0 deletions
|
@ -46,6 +46,7 @@ cscli hub upgrade`,
|
|||
DisableAutoGenTag: true,
|
||||
}
|
||||
|
||||
cmd.AddCommand(cli.newBranchCmd())
|
||||
cmd.AddCommand(cli.newListCmd())
|
||||
cmd.AddCommand(cli.newUpdateCmd())
|
||||
cmd.AddCommand(cli.newUpgradeCmd())
|
||||
|
@ -84,6 +85,28 @@ func (cli *cliHub) List(out io.Writer, hub *cwhub.Hub, all bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (cli *cliHub) newBranchCmd() *cobra.Command {
|
||||
var all bool
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "branch",
|
||||
Short: "Show selected hub branch",
|
||||
Long: "Display the hub branch to be used, depending on configuration and crowdsec version",
|
||||
Args: args.NoArgs,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
branch := require.HubBranch(cmd.Context(), cli.cfg())
|
||||
fmt.Println(branch)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
flags := cmd.Flags()
|
||||
flags.BoolVarP(&all, "all", "a", false, "List all available items, including those not installed")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (cli *cliHub) newListCmd() *cobra.Command {
|
||||
var all bool
|
||||
|
||||
|
|
|
@ -61,6 +61,19 @@ config_prepare() {
|
|||
.api.server.listen_socket="/run/crowdsec.sock" |
|
||||
.config_paths.config_dir |= sub("/$", "")
|
||||
' "${CONFIG_DIR}/config.yaml"
|
||||
|
||||
# pin the branch to avoid having to query the last version repeatedly.
|
||||
# this means the fixture could possibly go stale (i.e. use the wrong branch) if a new version is released,
|
||||
# but that shouldn't impact the tests anyway.
|
||||
|
||||
HUB_BRANCH=$("$CSCLI" hub branch 2>/dev/null)
|
||||
export HUB_BRANCH
|
||||
|
||||
echo "Setting up tests with hub branch $HUB_BRANCH"
|
||||
|
||||
# need a working config, so we do it as a separate step.
|
||||
|
||||
yq -i e '.cscli.hub_branch=strenv(HUB_BRANCH)' "${CONFIG_DIR}/config.yaml"
|
||||
}
|
||||
|
||||
make_init_data() {
|
||||
|
|
|
@ -98,6 +98,19 @@ config_generate() {
|
|||
.api.server.console_path=strenv(CONFIG_DIR)+"/console.yaml" |
|
||||
del(.api.server.online_client)
|
||||
' ../config/config.yaml >"${CONFIG_DIR}/config.yaml"
|
||||
|
||||
# pin the branch to avoid having to query the last version repeatedly.
|
||||
# this means the fixture could possibly go stale (i.e. use the wrong branch) if a new version is released,
|
||||
# but that shouldn't impact the tests anyway.
|
||||
|
||||
HUB_BRANCH=$("$CSCLI" hub branch 2>/dev/null)
|
||||
export HUB_BRANCH
|
||||
|
||||
echo "Setting up tests with hub branch $HUB_BRANCH"
|
||||
|
||||
# need a working config, so we do it as a separate step.
|
||||
|
||||
yq -i e '.cscli.hub_branch=strenv(HUB_BRANCH)' "${CONFIG_DIR}/config.yaml"
|
||||
}
|
||||
|
||||
make_init_data() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue