name: "{{ project_name }}"
description: "{{ manifest_description }}"
schema_version: 1
version: "{{ "{{" }} version {{ "}}" }}"
api_version: "v1"

requirements:
  core:
    from_version: "0.0.0"
  dbaas:
    from_version: "0.0.0"


resources:

  # Compute
  $core.compute.sets:
    {{ project_name | replace('-', '_') }}_set:
      name: "{{ project_name | replace('_', '-') }}"
      project_id: "12345678-c625-4fee-81d5-f691897b8142"
      cores: ${{ project_name | replace('-', '_') }}.imports.$var_default_cores:value
      ram: ${{ project_name | replace('-', '_') }}.imports.$var_default_ram:value
      replicas: ${{ project_name | replace('-', '_') }}.imports.$var_default_replicas:value
      disk_spec:
        kind: "root_disk"
        size: 10
        image: "{{ "{{" }} repository | default('{{ repository }}') {{ "}}" }}/{{ project_name }}/{{ "{{" }} version {{ "}}" }}/images/{{ project_name | replace('_', '-') }}.raw.gz"
  
  # Secret
  $core.secret.passwords:
    db_password:
      project_id: "12345678-c625-4fee-81d5-f691897b8142"
      name: "{{ project_name | replace('_', '-') }}-pg-pass"
      description: "{{ project_name | replace('_', '-') }} password"

  # PG Cluster
  $dbaas.types.postgres.instances:
    cluster_pg:
      name: "{{ project_name | replace('_', '-') }}-cluster"
      nodes_number: 1
      project_id: "12345678-c625-4fee-81d5-f691897b8142"
      cpu: 1
      ram: 1024
      disk_size: 15
      version: ${{ project_name | replace('-', '_') }}.imports.$pg18:uuid

  $dbaas.types.postgres.instances.$cluster_pg.users:
    db_user:
      project_id: "12345678-c625-4fee-81d5-f691897b8142"
      name: "{{ pgsql_username }}"
      password: $core.secret.passwords.$db_password:value
      instance: $dbaas.types.postgres.instances.$cluster_pg:uuid

  $dbaas.types.postgres.instances.$cluster_pg.databases:
    database:
      project_id: "12345678-c625-4fee-81d5-f691897b8142"
      name: "{{ pgsql_database_name }}"
      owner: $dbaas.types.postgres.instances.$cluster_pg.users.$db_user:uuid
      instance: $dbaas.types.postgres.instances.$cluster_pg:uuid

imports:
  var_default_replicas:
    element: "$core"
    kind: "resource"
    link: "$core.vs.variables.$default_replicas"
  var_default_cores:
    element: "$core"
    kind: "resource"
    link: "$core.vs.variables.$default_cores"
  var_default_ram:
    element: "$core"
    kind: "resource"
    link: "$core.vs.variables.$default_ram"
  pg18:
    element: "$dbaas"
    kind: "resource"
    link: "$dbaas.types.postgres.versions.$pg18"