<commit_before>package openstack

import (
	"github.com/ovh/cds/sdk"
	"github.com/ovh/cds/sdk/hatchery"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)

func init() {
	hatcheryOpenStack = &HatcheryCloud{}

	Cmd.Flags().StringVar(&hatcheryOpenStack.tenant, "openstack-tenant", "", "")
	viper.BindPFlag("openstack-tenant", Cmd.Flags().Lookup("openstack-tenant"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.user, "openstack-user", "", "")
	viper.BindPFlag("openstack-user", Cmd.Flags().Lookup("openstack-user"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.address, "openstack-auth-endpoint", "", "")
	viper.BindPFlag("openstack-auth-endpoint", Cmd.Flags().Lookup("openstack-auth-endpoint"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.password, "openstack-password", "", "")
	viper.BindPFlag("openstack-password", Cmd.Flags().Lookup("openstack-password"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.region, "openstack-region", "", "")
	viper.BindPFlag("openstack-region", Cmd.Flags().Lookup("openstack-region"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.network, "openstack-network", "Ext-Net", "")
	viper.BindPFlag("openstack-network", Cmd.Flags().Lookup("openstack-network"))

	Cmd.Flags().String("openstack-ip-range", "Ext-Net", "")
	viper.BindPFlag("openstack-ip-range", Cmd.Flags().Lookup("openstack-ip-range"))

	Cmd.Flags().IntVar(&hatcheryOpenStack.workerTTL, "worker-ttl", 30, "Worker TTL (minutes)")
	viper.BindPFlag("worker-ttl", Cmd.Flags().Lookup("worker-ttl"))

	Cmd.Flags().Int("spawn-threshold-critical", 480, "log critical if spawn take more than this value (in seconds)")
	viper.BindPFlag("spawn-threshold-critical", Cmd.Flags().Lookup("spawn-threshold-critical"))

	Cmd.Flags().Int("spawn-threshold-warning", 360, "log warning if spawn take more than this value (in seconds)")
	viper.BindPFlag("spawn-threshold-warning", Cmd.Flags().Lookup("spawn-threshold-warning"))
}

// Cmd configures comamnd for HatcheryCloud
var Cmd = &cobra.Command{
	Use:   "cloud",
	Short: "Hatchery Cloud commands: hatchery cloud --help",
	Long: `Hatchery Cloud commands: hatchery cloud <command>
Start worker on a docker openstack cluster.

$ cds generate token --group shared.infra --expiration persistent
2706bda13748877c57029598b915d46236988c7c57ea0d3808524a1e1a3adef4<commit_msg>fix (hatcheryCloud): default value for flag openstack-ip-range (#486)<commit_after>package openstack

import (
	"github.com/ovh/cds/sdk"
	"github.com/ovh/cds/sdk/hatchery"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)

func init() {
	hatcheryOpenStack = &HatcheryCloud{}

	Cmd.Flags().StringVar(&hatcheryOpenStack.tenant, "openstack-tenant", "", "")
	viper.BindPFlag("openstack-tenant", Cmd.Flags().Lookup("openstack-tenant"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.user, "openstack-user", "", "")
	viper.BindPFlag("openstack-user", Cmd.Flags().Lookup("openstack-user"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.address, "openstack-auth-endpoint", "", "")
	viper.BindPFlag("openstack-auth-endpoint", Cmd.Flags().Lookup("openstack-auth-endpoint"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.password, "openstack-password", "", "")
	viper.BindPFlag("openstack-password", Cmd.Flags().Lookup("openstack-password"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.region, "openstack-region", "", "")
	viper.BindPFlag("openstack-region", Cmd.Flags().Lookup("openstack-region"))

	Cmd.Flags().StringVar(&hatcheryOpenStack.network, "openstack-network", "Ext-Net", "")
	viper.BindPFlag("openstack-network", Cmd.Flags().Lookup("openstack-network"))

	Cmd.Flags().String("openstack-ip-range", "", "")
	viper.BindPFlag("openstack-ip-range", Cmd.Flags().Lookup("openstack-ip-range"))

	Cmd.Flags().IntVar(&hatcheryOpenStack.workerTTL, "worker-ttl", 30, "Worker TTL (minutes)")
	viper.BindPFlag("worker-ttl", Cmd.Flags().Lookup("worker-ttl"))

	Cmd.Flags().Int("spawn-threshold-critical", 480, "log critical if spawn take more than this value (in seconds)")
	viper.BindPFlag("spawn-threshold-critical", Cmd.Flags().Lookup("spawn-threshold-critical"))

	Cmd.Flags().Int("spawn-threshold-warning", 360, "log warning if spawn take more than this value (in seconds)")
	viper.BindPFlag("spawn-threshold-warning", Cmd.Flags().Lookup("spawn-threshold-warning"))
}

// Cmd configures comamnd for HatcheryCloud
var Cmd = &cobra.Command{
	Use:   "cloud",
	Short: "Hatchery Cloud commands: hatchery cloud --help",
	Long: `Hatchery Cloud commands: hatchery cloud <command>
Start worker on a docker openstack cluster.

$ cds generate token --group shared.infra --expiration persistent
2706bda13748877c<PASSWORD>29<PASSWORD>b<PASSWORD>46236988c7c57ea0d3808524a1e1a3adef4
{'fraction_non_alphanumeric': 0.17979710770559032, 'fraction_numerical': 0.023742715303259228, 'mean_word_length': 6.438202247191011, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4989241', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1616, 'n_words': 239}