Ver código fonte

Add logic to get shared overhead from values.yaml

Kaelan Patel 4 anos atrás
pai
commit
40815c4c6c
1 arquivos alterados com 17 adições e 0 exclusões
  1. 17 0
      pkg/cloud/providerconfig.go

+ 17 - 0
pkg/cloud/providerconfig.go

@@ -187,6 +187,23 @@ func DefaultPricing() *CustomPricing {
 }
 
 func SetCustomPricingField(obj *CustomPricing, name string, value string) error {
+
+	// shared overhead costs go into SharedCosts with key "total" in CustomPricing
+	if name == "SharedOverhead" {
+
+		value = sanitizePolicy.Sanitize(value)
+		val := reflect.ValueOf(value)
+
+		if reflect.ValueOf(obj.SharedCosts["total"]).Type() != val.Type() {
+			return fmt.Errorf("cannot insert value into custom pricing shared costs")
+		}
+
+		obj.SharedCosts["total"] = value
+
+		return nil
+
+	}
+
 	structValue := reflect.ValueOf(obj).Elem()
 	structFieldValue := structValue.FieldByName(name)