Add image_username and image_password to charms 45/9945/1
authorDavid Garcia <david.garcia@canonical.com>
Wed, 4 Nov 2020 17:34:41 +0000 (18:34 +0100)
committerDavid Garcia <david.garcia@canonical.com>
Wed, 4 Nov 2020 17:34:41 +0000 (18:34 +0100)
This commit will allow us to pull images for OSM components from a
private docker registry, protected with username and password

Change-Id: I854028d6abbb1cae07c61692ba73d08825763212
Signed-off-by: David Garcia <david.garcia@canonical.com>
30 files changed:
installers/charm/lcm-k8s/config.yaml
installers/charm/lcm-k8s/reactive/lcm.py
installers/charm/lcm-k8s/reactive/spec_template.yaml
installers/charm/mon-k8s/config.yaml
installers/charm/mon-k8s/reactive/mon_k8s.py
installers/charm/mon-k8s/reactive/spec_template.yaml
installers/charm/nbi-k8s/config.yaml
installers/charm/nbi-k8s/reactive/nbi.py
installers/charm/nbi-k8s/reactive/spec_template.yaml
installers/charm/ng-ui/config.yaml
installers/charm/ng-ui/hooks/start [deleted symlink]
installers/charm/ng-ui/lib/ops [deleted symlink]
installers/charm/ng-ui/mod/operator [deleted submodule]
installers/charm/ng-ui/src/charm.py
installers/charm/pla/config.yaml
installers/charm/pla/hooks/install [deleted symlink]
installers/charm/pla/hooks/start [deleted symlink]
installers/charm/pla/hooks/upgrade-charm [deleted symlink]
installers/charm/pla/lib/ops [deleted symlink]
installers/charm/pla/mod/operator [deleted submodule]
installers/charm/pla/src/charm.py
installers/charm/pol-k8s/config.yaml
installers/charm/pol-k8s/reactive/pol_k8s.py
installers/charm/pol-k8s/reactive/spec_template.yaml
installers/charm/ro-k8s/config.yaml
installers/charm/ro-k8s/reactive/ro.py
installers/charm/ro-k8s/reactive/spec_template.yaml
installers/charm/ui-k8s/config.yaml
installers/charm/ui-k8s/reactive/spec_template.yaml
installers/charm/ui-k8s/reactive/ui.py

index 25f6a71..1f1c62b 100644 (file)
@@ -66,3 +66,11 @@ options:
     type: string
     description: OCI image
     default: opensourcemano/lcm:8
+  image_username:
+    description: Docker repository username
+    type: string
+    default: ""
+  image_password:
+    description: Docker repository password
+    type: string
+    default: ""
index 1cb4661..87b6b2c 100644 (file)
@@ -138,7 +138,6 @@ def make_pod_spec(ro_host, ro_port, kafka_host, kafka_port, mongo_uri):
 
     data = {
         "name": md.get("name"),
-        "docker_image": cfg.get("image"),
         "ro_host": ro_host,
         "ro_port": ro_port,
         "kafka_host": kafka_host,
index d8b51e7..b5f508b 100644 (file)
 version: 2
 containers:
   - name: %(name)s
-    image: %(docker_image)s
+    imageDetails:
+      imagePath: %(image)s
+      username: %(image_username)s
+      password: %(image_password)s
     ports:
     # This is a fake port; lcm doesn't listen, since it's just reading
     # and responding to the kafka bus. Fix this in post.
index ddf8a81..069758f 100644 (file)
@@ -68,3 +68,11 @@ options:
     type: string
     description: OCI image
     default: opensourcemano/mon:8
+  image_username:
+    description: Docker repository username
+    type: string
+    default: ""
+  image_password:
+    description: Docker repository password
+    type: string
+    default: ""
index 79780e0..cd4d568 100644 (file)
@@ -114,7 +114,6 @@ def make_pod_spec(kafka_host, kafka_port, mongo_uri, prometheus_url):
 
     data = {
         "name": md.get("name"),
-        "docker_image": cfg.get("image"),
         "kafka_host": kafka_host,
         "kafka_port": kafka_port,
         "mongo_uri": mongo_uri,
index c81e5a1..bc6cb07 100644 (file)
 version: 2
 containers:
   - name: %(name)s
-    image: %(docker_image)s
+    imageDetails:
+      imagePath: %(image)s
+      username: %(image_username)s
+      password: %(image_password)s
     ports:
     - containerPort: %(advertised-port)s
       protocol: TCP
index b947290..a594f6e 100755 (executable)
@@ -32,6 +32,14 @@ options:
     type: string
     description: OCI image
     default: opensourcemano/nbi:8
+  image_username:
+    description: Docker repository username
+    type: string
+    default: ""
+  image_password:
+    description: Docker repository password
+    type: string
+    default: ""
   auth-backend:
     type: string
     description: Authentication backend ('internal' or 'keystone')
index 855d800..50187ad 100644 (file)
@@ -222,7 +222,6 @@ def make_pod_spec(kafka_host, kafka_port, mongo_uri, prometheus_uri):
     prometheus_host, prometheus_port = parse_hostport(prometheus_uri)
     data = {
         "name": md.get("name"),
-        "docker_image": cfg.get("image"),
         "mongo_uri": mongo_uri,
         "kafka_host": "{}".format(kafka_host),
         "kafka_port": "{}".format(kafka_port),
index 5c030d9..f9a35b6 100644 (file)
 version: 2
 containers:
   - name: %(name)s
-    image: %(docker_image)s
+    imageDetails:
+      imagePath: %(image)s
+      username: %(image_username)s
+      password: %(image_password)s
     ports:
     - containerPort: %(advertised-port)s
       protocol: TCP
index a80a280..022d150 100644 (file)
@@ -20,6 +20,14 @@ options:
     description: Docker image name
     type: string
     default: opensourcemano/ng-ui:8
+  image_username:
+    description: Docker repository username
+    type: string
+    default: ""
+  image_password:
+    description: Docker repository password
+    type: string
+    default: ""
   port:
     description: Port number
     type: int
diff --git a/installers/charm/ng-ui/hooks/start b/installers/charm/ng-ui/hooks/start
deleted file mode 120000 (symlink)
index 25b1f68..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../src/charm.py
\ No newline at end of file
diff --git a/installers/charm/ng-ui/lib/ops b/installers/charm/ng-ui/lib/ops
deleted file mode 120000 (symlink)
index d934193..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../mod/operator/ops
\ No newline at end of file
diff --git a/installers/charm/ng-ui/mod/operator b/installers/charm/ng-ui/mod/operator
deleted file mode 160000 (submodule)
index a84ce87..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit a84ce8776b368a8b2bccdb173716e342db9a6b36
index d9ad8f2..6f5ca5b 100755 (executable)
@@ -32,9 +32,6 @@ from ops.model import (
 )
 
 
-sys.path.append("lib")
-
-
 logger = logging.getLogger(__name__)
 
 
@@ -130,7 +127,11 @@ class NGUICharm(CharmBase):
         ]
         port = config["https_port"] if ssl_enabled else config["port"]
         ports = [
-            {"name": "port", "containerPort": port, "protocol": "TCP", },
+            {
+                "name": "port",
+                "containerPort": port,
+                "protocol": "TCP",
+            },
         ]
 
         kubernetes = {
@@ -166,7 +167,11 @@ class NGUICharm(CharmBase):
             "containers": [
                 {
                     "name": self.framework.model.app.name,
-                    "image": "{}".format(config["image"]),
+                    "imageDetails": {
+                        "imagePath": config["image"],
+                        "username": config["image_username"],
+                        "password": config["image_password"],
+                    },
                     "ports": ports,
                     "kubernetes": kubernetes,
                     "files": files,
index e0aeca4..f3318fc 100644 (file)
@@ -20,6 +20,14 @@ options:
     description: Docker image name
     type: string
     default: opensourcemano/pla:8
+  image_username:
+    description: Docker repository username
+    type: string
+    default: ""
+  image_password:
+    description: Docker repository password
+    type: string
+    default: ""
   port:
     description: Port number
     type: int
diff --git a/installers/charm/pla/hooks/install b/installers/charm/pla/hooks/install
deleted file mode 120000 (symlink)
index 25b1f68..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../src/charm.py
\ No newline at end of file
diff --git a/installers/charm/pla/hooks/start b/installers/charm/pla/hooks/start
deleted file mode 120000 (symlink)
index 25b1f68..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../src/charm.py
\ No newline at end of file
diff --git a/installers/charm/pla/hooks/upgrade-charm b/installers/charm/pla/hooks/upgrade-charm
deleted file mode 120000 (symlink)
index 25b1f68..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../src/charm.py
\ No newline at end of file
diff --git a/installers/charm/pla/lib/ops b/installers/charm/pla/lib/ops
deleted file mode 120000 (symlink)
index d934193..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../mod/operator/ops
\ No newline at end of file
diff --git a/installers/charm/pla/mod/operator b/installers/charm/pla/mod/operator
deleted file mode 160000 (submodule)
index a84ce87..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit a84ce8776b368a8b2bccdb173716e342db9a6b36
index 785766d..16e7303 100755 (executable)
@@ -29,9 +29,6 @@ from ops.model import (
 )
 
 
-sys.path.append("lib")
-
-
 logger = logging.getLogger(__name__)
 
 
@@ -85,7 +82,11 @@ class PLACharm(CharmBase):
         config = self.framework.model.config
 
         ports = [
-            {"name": "port", "containerPort": config["port"], "protocol": "TCP", },
+            {
+                "name": "port",
+                "containerPort": config["port"],
+                "protocol": "TCP",
+            },
         ]
 
         config_spec = {
@@ -103,7 +104,11 @@ class PLACharm(CharmBase):
             "containers": [
                 {
                     "name": self.framework.model.app.name,
-                    "image": config["image"],
+                    "imageDetails": {
+                        "imagePath": config["image"],
+                        "username": config["image_username"],
+                        "password": config["image_password"],
+                    },
                     "ports": ports,
                     "config": config_spec,
                 }
@@ -136,9 +141,7 @@ class PLACharm(CharmBase):
         self._apply_spec()
 
     def on_mongo_relation_changed(self, event):
-        mongodb_uri = event.relation.data[event.unit].get(
-            "connection_string"
-        )
+        mongodb_uri = event.relation.data[event.unit].get("connection_string")
         if mongodb_uri and self.state.mongodb_uri != mongodb_uri:
             self.state.mongodb_uri = mongodb_uri
         self._apply_spec()
index 8cfd8bf..d33a715 100644 (file)
@@ -24,3 +24,11 @@ options:
     type: string
     description: OCI image
     default: opensourcemano/pol:8
+  image_username:
+    description: Docker repository username
+    type: string
+    default: ""
+  image_password:
+    description: Docker repository password
+    type: string
+    default: ""
index 5629b4b..5d56c27 100644 (file)
@@ -100,7 +100,6 @@ def make_pod_spec(kafka_host, kafka_port, mongo_uri):
     cfg = config()
     data = {
         "name": md.get("name"),
-        "docker_image": cfg.get("image"),
         "kafka_host": kafka_host,
         "kafka_port": kafka_port,
         "mongo_uri": mongo_uri,
index de7d4a2..d0c5823 100644 (file)
 version: 2
 containers:
   - name: %(name)s
-    image: %(docker_image)s
+    imageDetails:
+      imagePath: %(image)s
+      username: %(image_username)s
+      password: %(image_password)s
     ports:
     # This is a fake port; lcm doesn't listen, since it's just reading
     # and responding to the kafka bus. Fix this in post.
index a18e495..31eaca8 100755 (executable)
@@ -32,3 +32,11 @@ options:
     type: string
     description: OCI image
     default: opensourcemano/ro:8
+  image_username:
+    description: Docker repository username
+    type: string
+    default: ""
+  image_password:
+    description: Docker repository password
+    type: string
+    default: ""
index 8ad6f98..8f91b4b 100644 (file)
@@ -114,7 +114,6 @@ def make_pod_spec(
 
     data = {
         "name": md.get("name"),
-        "docker_image": cfg.get("image"),
         "mysql_host": mysql_host,
         "mysql_port": mysql_port,
         "mysql_user": mysql_user,
index f4f7c9c..f2b3535 100644 (file)
@@ -16,7 +16,10 @@ service:
   scalePolicy: serial
 containers:
   - name: %(name)s
-    image: %(docker_image)s
+    imageDetails:
+      imagePath: %(image)s
+      username: %(image_username)s
+      password: %(image_password)s
     kubernetes:
       readinessProbe:
         httpGet:
index 8e24da0..d4321ae 100755 (executable)
@@ -28,3 +28,11 @@ options:
     type: string
     description: OCI image
     default: opensourcemano/light-ui:8
+  image_username:
+    description: Docker repository username
+    type: string
+    default: ""
+  image_password:
+    description: Docker repository password
+    type: string
+    default: ""
index b63c210..4b3eef3 100644 (file)
 version: 2
 containers:
   - name: %(name)s
-    image: %(docker_image)s
+    imageDetails:
+      imagePath: %(image)s
+      username: %(image_username)s
+      password: %(image_password)s
     ports:
     - containerPort: %(advertised-port)s
       protocol: TCP
index 5ca8143..eb53daf 100644 (file)
@@ -111,7 +111,6 @@ def make_pod_spec(
 
     data = {
         "name": md.get("name"),
-        "docker_image": cfg.get("image"),
         "mysql_host": mysql_host,
         "mysql_port": mysql_port,
         "mysql_user": mysql_user,