From a6223cc8b65b897647b1673be1336d30c8010459 Mon Sep 17 00:00:00 2001 From: Pallab Pain Date: Fri, 24 Feb 2023 10:16:11 +0530 Subject: [PATCH] feat(deployment): adds vpn client toggle in manifest This commit adds support for enabling vpn client in a deployment via the deployment manifest. Here's an example on how to enable VPN apiVersion: "apiextensions.rapyuta.io/v1" kind: Deployment metadata: name: "dep-nginx" depends: kind: package nameOrGUID: "nginx" version: "1.0.0" spec: runtime: cloud features: vpn: enabled: true --- riocli/deployment/model.py | 27 +++++++++++++------ .../jsonschema/schemas/deployment-schema.yaml | 11 ++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/riocli/deployment/model.py b/riocli/deployment/model.py index 410da101..7b7f5b35 100644 --- a/riocli/deployment/model.py +++ b/riocli/deployment/model.py @@ -64,11 +64,11 @@ def create_object(self, client: Client) -> typing.Any: runtime = internal_component['runtime'] if 'runtime' in self.spec and runtime != self.spec.runtime: - click.secho('>> runtime mismatch => ' + - 'deployment:{}.runtime !== package:{}.runtime '.format( - self.metadata.name, pkg['packageName'] - ), fg='red' - ) + click.secho( + '>> runtime mismatch => ' + + 'deployment:{}.runtime !== package:{}.runtime '.format( + self.metadata.name, pkg['packageName'] + ), fg='red') return provision_config = pkg.get_provision_configuration(__planId) @@ -142,15 +142,26 @@ def create_object(self, client: Client) -> typing.Any: }) provision_config.context['managedServices'] = managed_services + # inject the vpn managedservice instance if the flag is set to + # true. 'rio-internal-headscale' is the default vpn instance + if 'features' in self.spec: + if 'vpn' in self.spec.features and self.spec.features.vpn.enabled: + provision_config.context['managedServices'] = [{ + "instance": "rio-internal-headscale" + }] + if self.spec.runtime == 'device': - device_guid, device = self.rc.find_depends(self.spec.device.depends) + device_guid, device = self.rc.find_depends( + self.spec.device.depends) if device is None and device_guid: device = client.get_device(device_guid) - provision_config.add_device(__componentName, device=device, set_component_alias=False) + provision_config.add_device(__componentName, device=device, + set_component_alias=False) if 'restart' in self.spec: provision_config.add_restart_policy( - __componentName, self.RESTART_POLICY[self.spec.restart.lower()]) + __componentName, + self.RESTART_POLICY[self.spec.restart.lower()]) # Add Network # if self.spec.rosNetworks: diff --git a/riocli/jsonschema/schemas/deployment-schema.yaml b/riocli/jsonschema/schemas/deployment-schema.yaml index f1edc33b..a1a2c927 100644 --- a/riocli/jsonschema/schemas/deployment-schema.yaml +++ b/riocli/jsonschema/schemas/deployment-schema.yaml @@ -170,6 +170,17 @@ definitions: enum: - cloud + features: + type: object + properties: + vpn: + type: object + properties: + enabled: + type: boolean + required: + - enabled + envArgs: type: array items: