← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~lgp171188/lp-archive:charm-esm-snapshots into lp-archive:main

 

Guruprasad has proposed merging ~lgp171188/lp-archive:charm-esm-snapshots into lp-archive:main.

Commit message:
charm: Add support for ESM configuration

This adds support to specify ESM configuration via Juju options and
rendering them in config.toml configuration file used by lp-archive.


Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~lgp171188/lp-archive/+git/lp-archive/+merge/468589
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~lgp171188/lp-archive:charm-esm-snapshots into lp-archive:main.
diff --git a/charm/lp-archive/config.yaml b/charm/lp-archive/config.yaml
index e9a0ca6..2da8fd3 100644
--- a/charm/lp-archive/config.yaml
+++ b/charm/lp-archive/config.yaml
@@ -3,6 +3,47 @@ options:
     type: string
     default: http://xmlrpc-private.launchpad.test:8087/archive
     description: URL of private Launchpad XML-RPC archive endpoint.
+  enable_esm:
+    type: boolean
+    default: false
+    description: |
+      Whether to enable the snapshots for the ESM repositories
+      or not.
+  esm_auth_endpoint:
+    type: string
+    description: |
+      The HTTP endpoint to use for authenticating ESM credentials.
+      This is mandatory when the 'enable_esm' option is true.
+  esm_auth_required_path_prefix:
+    type: string
+    default: "pool/"
+    description: The path prefix under a repository that requires authentication.
+  esm_layouts:
+    type: string
+    default: ""
+    description: >
+      YAML-encoded list of ESM layouts offered by this deployment. Each layout
+      is a dictionary containing the following keys.
+        * host: The hostname that the layout will be accessible on. For
+          example, "snapshot.esm-apps-security.ubuntu.test:8000".
+        * purpose: The ESM resource that this layout corresponds to. For
+          example, "esm-apps".
+        * archive: The Launchpad ESM PPA that this layout is backed by. For
+          example, "~user/ubuntu/ppa".
+        * base_path: The base path, starting with a leading /, under which
+          the snapshot repository is available. For example, "/apps/ubuntu".
+        * pockets (optional): A list of pockets used in this repository,
+          in addition to the release pocket. This is used to translate the
+          suites on the ESM repository to the corresponding suites on the
+          backing Launchpad PPAs, which only support the release pocket. If
+          unspecified, no translation of suite names is performed. For example,
+          a suite named "jammy-apps-security" will get translated to "jammy"
+          on the backing PPA, if the "apps-security" pocket is specified in
+          the list of values for this key. Otherwise, the suite names are used
+          unmodified on the backing Launchpad PPAs.
+        * earliest_snapshot_timestamp (optional): The timestamp of the earliest
+          available snapshot for this layout. If unspecified, all provided
+          timestamps are queried in the history of the backing Launchpad PPAs.
   layouts:
     type: string
     default: ""
diff --git a/charm/lp-archive/reactive/lp-archive.py b/charm/lp-archive/reactive/lp-archive.py
index 28c8efe..d7c0de0 100644
--- a/charm/lp-archive/reactive/lp-archive.py
+++ b/charm/lp-archive/reactive/lp-archive.py
@@ -30,6 +30,7 @@ def configure(memcache):
         f"{host}:{port}" for host, port in memcache.memcache_hosts_ports()
     )
     config["layouts"] = yaml.safe_load(config["layouts"])
+    config["esm_layouts"] = yaml.safe_load(config["esm_layouts"])
 
     hookenv.log("Writing service config.")
     templating.render(
diff --git a/charm/lp-archive/templates/config.toml.j2 b/charm/lp-archive/templates/config.toml.j2
index 5512086..6cdd026 100644
--- a/charm/lp-archive/templates/config.toml.j2
+++ b/charm/lp-archive/templates/config.toml.j2
@@ -10,3 +10,27 @@ purpose = "{{ layout["purpose"] }}"
 {%- endfor %}
 {%- endif %}
 
+{%- if enable_esm %}
+
+[ESM]
+auth_required_path_prefix = "{{ esm_auth_required_path_prefix }}"
+esm_auth_endpoint = "{{ esm_auth_endpoint }}"
+
+{%- if esm_layouts %}
+{%- for esm_layout in esm_layouts %}
+
+[[ESM_LAYOUT]]
+host = "{{ esm_layout["host"] }}"
+purpose = "{{ esm_layout["purpose"] }}"
+archive = "{{ esm_layout["archive"] }}"
+base_path = "{{ esm_layout["base_path"] }}"
+{%- if "pockets" in esm_layout %}
+pockets = {{ esm_layout["pockets"] }}
+{%- endif %}
+{%- if "earliest_snapshot_timestamp" in esm_layout %}
+earliest_snapshot_timestamp = "{{ esm_layout["earliest_snapshot_timestamp"] }}"
+{%- endif %}
+{%- endfor %}
+{%- endif %}
+{%- endif %}
+