func (h *Handler) SetProductConfig(
	product, productPassword string, config map[string]string) error {
	logger := h.logger.Add("method", "SetProductConfig",
		"product", product, "config", config)

	logger.Info("product config update")

	prod, err := h.checkProductPassword(logger, product, productPassword)
	if err != nil {
		return err
	}

	if len(config) == 0 {
		logger.Warn(ErrBadProductConfig.Error())
		return ErrBadProductConfig
	}

	prod.ServiceEndpointAddress = serviceEndpointAddress(prod, config)
	delete(config, ProductExternalIP)

	if prod.ServiceEndpointAddress != nil {
		country2 := h.findCountry(logger, *prod.ServiceEndpointAddress)
		if len(country2) != 2 {
			country2 = country.UndefinedCountry
		}
		prod.Country = &country2
	}

	if prod.Config, err = json.Marshal(config); err != nil {
		logger.Error(err.Error())
		return ErrInternal
	}

	if err := h.db.Update(prod); err != nil {
		logger.Error(err.Error())
		return ErrInternal
	}

	return nil
}
func (h *Handler) SetProductConfig(
	product, productPassword string, config map[string]string) error {
	logger := h.logger.Add("method", "SetProductConfig",
		"product", product, "config", config)

	logger.Info("product config update")

	prod, err := h.checkProductPassword(logger, product, productPassword)
	if err != nil {
		return err
	}

	if len(config) == 0 {
		logger.Warn(ErrBadProductConfig.Error())
		return ErrBadProductConfig
	}

	prod.ServiceEndpointAddress = serviceEndpointAddress(prod, config)
	delete(config, ProductExternalIP)

	if prod.ServiceEndpointAddress != nil {
		country2 := h.findCountry(logger, *prod.ServiceEndpointAddress)
		if len(country2) != 2 {
			country2 = country.UndefinedCountry
		}
		prod.Country = &country2
	}

	if prod.Config, err = json.Marshal(config); err != nil {
		logger.Error(err.Error())
		return ErrInternal
	}

	if err := h.db.Update(prod); err != nil {
		logger.Error(err.Error())
		return ErrInternal
	}

	return nil
}
func ( h * Handler ) SetProductConfig ( product , productPassword string , config map [ string ] string ) error { logger := h . logger . Add ( " " , " " , " " , product , " " , config ) logger . Info ( " " ) prod , err := h . checkProductPassword ( logger , product , productPassword ) if err != nil { return err } if len ( config ) == 0 { logger . Warn ( ErrBadProductConfig . Error ( ) ) return ErrBadProductConfig } prod . ServiceEndpointAddress = serviceEndpointAddress ( prod , config ) delete ( config , ProductExternalIP ) if prod . ServiceEndpointAddress != nil { country2 := h . findCountry ( logger , * prod . ServiceEndpointAddress ) if len ( country2 ) != 2 { country2 = country . UndefinedCountry } prod . Country = & country2 } if prod . Config , err = json . Marshal ( config ) ; err != nil { logger . Error ( err . Error ( ) ) return ErrInternal } if err := h . db . Update ( prod ) ; err != nil { logger . Error ( err . Error ( ) ) return ErrInternal } return nil }
// SetProductConfig sets product configuration.
SetProductConfig sets product configuration .