max_file_size: int
site_url: Optional[str]
cluster_issuer: Optional[str]
+ ingress_class: Optional[str]
ingress_whitelist_source_range: Optional[str]
tls_secret_name: Optional[str]
mongodb_uri: Optional[str]
+ image_pull_policy: Optional[str]
@validator("auth_backend")
def validate_auth_backend(cls, v):
raise ValueError("mongodb_uri is not properly formed")
return v
+ @validator("image_pull_policy")
+ def validate_image_pull_policy(cls, v):
+ values = {
+ "always": "Always",
+ "ifnotpresent": "IfNotPresent",
+ "never": "Never",
+ }
+ v = v.lower()
+ if v not in values.keys():
+ raise ValueError("value must be always, ifnotpresent or never")
+ return values[v]
+
class NbiCharm(CharmedOsmBase):
def __init__(self, *args) -> NoReturn:
- super().__init__(*args, oci_image="image")
+ super().__init__(
+ *args,
+ oci_image="image",
+ debug_mode_config_key="debug_mode",
+ debug_pubkey_config_key="debug_pubkey",
+ vscode_workspace=VSCODE_WORKSPACE,
+ )
self.kafka_client = KafkaClient(self, "kafka")
self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
)
# Build Container
- container_builder = ContainerV3Builder(self.app.name, image_info)
+ container_builder = ContainerV3Builder(
+ self.app.name, image_info, config.image_pull_policy
+ )
container_builder.add_port(name=self.app.name, port=PORT)
container_builder.add_tcpsocket_readiness_probe(
PORT,
"OSMNBI_STORAGE_DRIVER": "mongo",
"OSMNBI_STORAGE_PATH": "/app/storage",
"OSMNBI_STORAGE_COLLECTION": "files",
- "OSMNBI_STORAGE_URI": self.mongodb_client.connection_string,
+ "OSMNBI_STORAGE_URI": config.mongodb_uri
+ or self.mongodb_client.connection_string,
# Prometheus configuration
"OSMNBI_PROMETHEUS_HOST": self.prometheus_client.hostname,
"OSMNBI_PROMETHEUS_PORT": self.prometheus_client.port,
),
"nginx.ingress.kubernetes.io/backend-protocol": "HTTPS",
}
+ if config.ingress_class:
+ annotations["kubernetes.io/ingress.class"] = config.ingress_class
ingress_resource_builder = IngressResourceV3Builder(
f"{self.app.name}-ingress", annotations
)
return pod_spec_builder.build()
+VSCODE_WORKSPACE = {
+ "folders": [
+ {"path": "/usr/lib/python3/dist-packages/osm_nbi"},
+ {"path": "/usr/lib/python3/dist-packages/osm_common"},
+ {"path": "/usr/lib/python3/dist-packages/osm_im"},
+ ],
+ "settings": {},
+ "launch": {
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "NBI",
+ "type": "python",
+ "request": "launch",
+ "module": "osm_nbi.nbi",
+ "justMyCode": False,
+ }
+ ],
+ },
+}
+
+
if __name__ == "__main__":
main(NbiCharm)