---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: osdu-entitlements
  namespace: osdu-core
  annotations:
    clusterconfig.azure.com/use-managed-source: "true"
spec:
  dependsOn:
  - name: osdu-partition
    namespace: osdu-core
  targetNamespace: osdu-core
  chart:
    spec:
      chart: ./charts/osdu-developer-service
      sourceRef:
        kind: GitRepository
        name: flux-system
        namespace: flux-system
  interval: 5m0s
  timeout: 6m
  install:
    remediation:
      retries: 3
  valuesFrom:
    - kind: ConfigMap
      name: configmap-software
      valuesKey: value.yaml
    - kind: ConfigMap
      name: configmap-repo-override
      optional: true
      valuesKey: repository.yaml
  values:
    nameOverride: entitlements
    installationType: osduCore
    subset: m24
    replicaCount: 1
    service:
      type: ClusterIP
      port: 80
    configuration:
    - service: entitlements
      path: /api/entitlements/v2/
      hosts:
        - "*"
      cors:
        - "http://localhost:8080"
      gateways:
        - istio-system/internal-gateway
        - istio-system/external-gateway
      repository: community.opengroup.org:5555/osdu/platform/security-and-compliance/entitlements/entitlements-
      tag: latest
      probe:
        path: /actuator/health
        port: 8081
        liveness:
          delay: 250
          seconds: 10
      keyvault: true
      auth:
        disable:
          - "*/actuator/health"
          - "*/health"
          - "*/_ah/**"
          - "*/configuration/ui"
          - "*/configuration/security"
          - "/api/entitlements/v2/info"
          - "/api/entitlements/v2/swagger*"
          - "/api/entitlements/v2/api-docs*"
          - "/api/entitlements/v2/webjars/*"
      env:
      - name: KEYVAULT_URI
        secret:
          name: azure-resources
          key: keyvault-uri
      - name: AAD_CLIENT_ID
        secret:
          name: active-directory
          key: principal-clientid
      - name: APPINSIGHTS_KEY
        secret:
          name: azure-resources
          key: insights-key
      - name: APPLICATIONINSIGHTS_CONNECTION_STRING
        secret:
          name: azure-resources
          key: insights-connection
      - name: AZURE_ISTIOAUTH_ENABLED
        value: "true"
      - name: AZURE_PAAS_WORKLOADIDENTITY_ISENABLED
        value: "true"
      - name: SERVER_SERVLET_CONTEXTPATH
        value: "/api/entitlements/v2/"
      - name: SERVER_PORT
        value: "80"
      - name: ACCEPT_HTTP
        value: "true"
      - name: SPRING_APPLICATION_NAME
        value: "entitlements"
      - name: SPRING_CONFIG_NAME
        value: "common,application"
      - name: LOG_PREFIX
        value: "entitlements"
      - name: LOGGING_LEVEL
        value: "DEBUG"
      - name: SERVICE_DOMAIN_NAME
        value: "dataservices.energy"
      - name: ROOT_DATA_GROUP_QUOTA
        value: "5000"
      - name: REDIS_TTL_SECONDS
        value: "1"
      - name: PARTITION_SERVICE_ENDPOINT
        value: "http://partition/api/partition/v1"
---
# Retrigger:  kubectl annotate helmrelease osdu-entitlements-init fluxcd.io/retrigger=$(date +%s) -n osdu-core
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: osdu-entitlements-init
  namespace: osdu-core
  annotations:
    clusterconfig.azure.com/use-managed-source: "true"
    fluxcd.io/retrigger: "initial"
spec:
  dependsOn:
    - name: osdu-entitlements
      namespace: osdu-core
  targetNamespace: osdu-core
  chart:
    spec:
      chart: ./charts/osdu-developer-init
      sourceRef:
        kind: GitRepository
        name: flux-system
        namespace: flux-system
  interval: 5m0s
  install:
    remediation:
      retries: 3
  values:
    installationType: osduCore
    jobs:
      partitionInit: false
      entitlementInit: true
      userInit: false
      elasticInit: false
      schemaInit: false
    partition: opendes
    clientSecret:
      name: active-directory
      key: principal-clientpassword
  valuesFrom:
    - kind: ConfigMap
      name: configmap-software
      valuesKey: value.yaml
    - kind: ConfigMap
      name: configmap-services
      targetPath: clientId
      valuesKey: client_id
    - kind: ConfigMap
      name: configmap-services
      targetPath: tenantId
      valuesKey: tenant_id
