{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "title": "Values",
  "type": "object",
  "definitions": {
    "prometheusAlert": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "labels": {
          "type": "object",
          "additionalProperties": { "type": "string" }
        }
      },
      "required": [ "enabled" ]
    },
    "probe": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "failureThreshold": {
          "type": "integer"
        },
        "initialDelaySeconds": {
          "type": "integer"
        },
        "periodSeconds": {
          "type": "integer"
        },
        "successThreshold": {
          "type": "integer"
        },
        "timeoutSeconds": {
          "type": "integer"
        }
      },
      "required": [
        "failureThreshold",
        "initialDelaySeconds",
        "periodSeconds",
        "successThreshold",
        "timeoutSeconds"
      ]
    },
    "component": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "logLevel": {
          "type": "string",
          "enum": [ "all", "debug", "info", "warn", "error", "none" ]
        },
        "image": {
          "type": "object",
          "properties": {
            "repository": {
              "type": "string"
            },
            "tag": {
              "anyOf": [
                { "type": "string" },
                { "type": "null" }
              ]
            },
            "pullPolicy": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "string",
                  "enum": [ "Always", "IfNotPresent", "Never" ]
                }
              ]
            }
          }
        },
        "serviceAccount": {
          "type": "object",
          "properties": {
            "create": {
              "type": "boolean"
            },
            "name": {
              "type": "string"
            },
            "annotations": {
              "type": "object"
            }
          }
        },
        "resources": {
          "type": "object"
        },
        "nodeSelector": {
          "type": "object"
        },
        "tolerations": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "priorityClassName": {
          "type":"string"
        },
        "runtimeClassName": {
          "type":"string"
        },
        "affinity": {
          "type": "object"
        },
        "podAnnotations": {
          "type": "object"
        },
        "livenessProbe": {
          "$ref": "#/definitions/probe"
        },
        "readinessProbe": {
          "$ref": "#/definitions/probe"
        }
      },
      "required": [
        "image",
        "serviceAccount"
      ]
    }
  },
  "properties": {
    "imagePullSecrets": {
      "description": "Secrets used for pulling images",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        },
        "required": [ "name" ],
        "additionalProperties": false
      }
    },
    "nameOverride": {
      "description": "Override chart name",
      "type": "string"
    },
    "fullNameOverride": {
      "description": "Override fully qualified app name",
      "type": "string"
    },
    "configInLine": {
      "description": "MetalLB configuration",
      "type": "object"
    },
    "loadBalancerClass": {
      "type":"string"
    },
    "rbac": {
      "description": "RBAC configuration",
      "type": "object",
      "properties": {
        "create": {
          "description": "Enable RBAC",
          "type": "boolean"
        }
      }
    },
    "prometheus": {
      "description": "Prometheus monitoring config",
      "type": "object",
      "properties": {
        "scrapeAnnotations": { "type": "boolean" },
        "metricsPort": { "type": "integer" },
        "secureMetricsPort": { "type": "integer" },
        "rbacPrometheus": { "type": "boolean" },
        "serviceAccount": { "type": "string" },
        "namespace": { "type": "string" },
        "rbacProxy": {
          "description": "kube-rbac-proxy configuration",
          "type": "object",
          "properties": {
            "repository": { "type": "string" },
            "tag": { "type": "string" }
          }
        },
        "podMonitor": {
          "description": "Prometheus Operator PodMonitors",
          "type": "object",
          "properties": {
            "enabled": { "type": "boolean" },
            "additionalMonitors": { "type": "object" },
            "jobLabel": { "type": "string" },
            "interval": {
              "anyOf": [
                { "type": "integer" },
                { "type": "null" }
              ]
            },
            "metricRelabelings": {
              "type": "array",
              "items": {
                "type": "object"
              }
            },
            "relabelings": {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          }
        },
        "serviceMonitor": {
          "description": "Prometheus Operator ServiceMonitors",
          "type": "object",
          "properties": {
            "enabled": { "type": "boolean" },
            "jobLabel": { "type": "string" },
            "interval": {
              "anyOf": [
                { "type": "integer" },
                { "type": "null" }
              ]
            },
            "metricRelabelings": {
              "type": "array",
              "items": {
                "type": "object"
              }
            },
            "relabelings": {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          }
        },
        "prometheusRule": {
          "description": "Prometheus Operator alertmanager alerts",
          "type": "object",
          "properties": {
            "enabled": { "type": "boolean" },
            "additionalMonitors": { "type": "object" },
            "staleConfig": { "$ref": "#/definitions/prometheusAlert" },
            "configNotLoaded": { "$ref": "#/definitions/prometheusAlert" },
            "addressPoolExhausted": { "$ref": "#/definitions/prometheusAlert" },
            "addressPoolUsage": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean"
                },
                "thresholds": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "percent": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100
                      },
                      "labels": {
                        "type": "object",
                        "additionalProperties": { "type": "string" }
                      }
                    },
                    "required": [ "percent" ]
                  }
                }
              },
              "required": [ "enabled" ]
            },
            "bgpSessionDown": { "$ref": "#/definitions/prometheusAlert" },
            "extraAlerts": {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          },
          "required": [
            "enabled",
            "staleConfig",
            "configNotLoaded",
            "addressPoolExhausted",
            "addressPoolUsage",
            "bgpSessionDown"
          ]
        }
      },
      "required": [ "podMonitor", "prometheusRule" ]
    },
    "speaker": { 
      "allOf": [
        { "$ref": "#/definitions/component" },
        { "description": "MetalLB Speaker",
          "type": "object",
          "properties": {
            "tolerateMaster": {
              "type": "boolean"
            },
            "memberlist": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean"
                },
                "mlBindPort": {
                  "type": "integer"
                },
                "mlSecretKeyPath": {
                  "type": "string"
                }
              }
            },
            "excludeInterfaces": {
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean"
                }
              }
            },
            "updateStrategy": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                }
              },
              "required": [ "type" ]
            },
            "runtimeClassName": {
              "type": "string"
            },
            "secretName": {
              "type": "string"
            },
            "frr": {
              "description": "Install FRR container in speaker deployment",
              "type": "object",
              "properties": {
                "enabled": {
                  "type": "boolean"
                },
                "image": { "$ref": "#/definitions/component/properties/image" },
                "metricsPort": { "type": "integer" },
                "secureMetricsPort": { "type": "integer" },
                "resources:": { "type": "object" }
              },
              "required": [ "enabled" ]
            },
            "command" : {
              "type": "string"
            },
            "reloader": {
              "type": "object",
              "properties": {
                "resources": { "type": "object" }
              }
            },
            "frrMetrics": {
              "type": "object",
              "properties": {
                "resources": { "type": "object" }
              }
            }
          },
          "required": [ "tolerateMaster" ]
        }
      ]
    },
    "crds": {
      "description": "CRD configuration",
      "type": "object",
      "properties": {
        "enabled": {
          "description": "Enable CRDs",
          "type": "boolean"
        },
        "validationFailurePolicy": {
          "description": "Failure policy to use with validating webhooks",
          "type": "string",
          "enum": [ "Ignore", "Fail" ]
        }
      }
    }
  },
  "controller": { 
    "allOf": [
      { "$ref": "#/definitions/component" },
      { "description": "MetalLB Controller",
        "type": "object",
        "properties": {
          "strategy": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              }
            },
            "required": [ "type" ]
          },
          "command" : {
            "type": "string"
          },
          "webhookMode" : {
            "type": "string"
          }
        }
      }
    ]
  },
  "required": [
    "controller",
    "speaker"
  ]
}
