Ejemplo n.º 1
0
func deployBefore(c *cli.Context) error {
	if c.String("service-id") == "" {
		return errors.New("Service-id is empty")
	}

	if c.String("image") == "" {
		return errors.New("The name of the image is empty")
	}

	if c.String("tag") == "" {
		return errors.New("The Tag of the image is empty")
	}

	if c.String("memory") != "" {
		if _, err := strconv.ParseInt(c.String("memory"), 10, 64); err != nil {
			return errors.New("Invalid value of paramter memory")
		}
	}

	if c.Float64("cpu") < 0 {
		return errors.New("Cpu flag value should not be negative")
	}

	if c.String("framework") == "marathon" && c.Float64("cpu") > 1.0 { // Fix this: framework flag does not exist anymore
		return errors.New("Cpu flag value should not be > 1.0 for marathon")
	} else if c.String("framework") == "swarm" && c.Float64("cpu") > 1024 { // Fix this: framework flag does not exist anymore
		return errors.New("Cpu flag value should not be > 1024.0 for swarm")
	}

	for _, file := range c.StringSlice("env-file") {
		if err := util.FileExists(file); err != nil {
			return errors.New(fmt.Sprintf("El archivo %s con variables de entorno no existe", file))
		}
	}

	if c.Float64("minimumHealthCapacity") < 0.0 || c.Float64("minimumHealthCapacity") > 1.0 {
		return errors.New("MinimumHealthCapacity flag value should be between 0.0 and 1.0")
	}

	if c.Float64("maximumOverCapacity") < 0.0 || c.Float64("maximumOverCapacity") > 1.0 {
		return errors.New("MaximumOverCapacity flag value should be between 0.0 and 1.0")
	}

	return nil
}
Ejemplo n.º 2
0
func deployBefore(c *cli.Context) error {
	if c.String("service-id") == "" {
		return errors.New("Service-id is empty")
	}

	if c.String("tag") == "" {
		return errors.New("The Tag of the image is empty")
	}

	if c.String("namespace") == "" {
		return errors.New("Namespace is empty")
	}

	if c.Int64("memory") < 0 {
		return errors.New("Memory flag value should not be negative")
	}

	if c.Float64("cpu") < 0 {
		return errors.New("Cpu flag value should not be negative")
	}

	for _, file := range c.StringSlice("env-file") {
		if err := util.FileExists(file); err != nil {
			return errors.New(fmt.Sprintf("El archivo %s con variables de entorno no existe", file))
		}
	}

	if c.Float64("minimumHealthCapacity") < 0.0 || c.Float64("minimumHealthCapacity") > 1.0 {
		return errors.New("MinimumHealthCapacity flag value should be between 0.0 and 1.0")
	}

	if c.Float64("maximumOverCapacity") < 0.0 || c.Float64("maximumOverCapacity") > 1.0 {
		return errors.New("MaximumOverCapacity flag value should be between 0.0 and 1.0")
	}

	return nil
}