[docs]defdeploy(self,deployments:list[RunwayDeploymentDefinition]|None=None)->None:"""Deploy action. Args: deployments: List of deployments to run. If not provided, all deployments in the config will be run. """self.__run_action("deploy",deploymentsifdeploymentsisnotNoneelseself.deployments)
[docs]defdestroy(self,deployments:list[RunwayDeploymentDefinition]|None=None)->None:"""Destroy action. Args: deployments: List of deployments to run. If not provided, all deployments in the config will be run in reverse. """self.__run_action("destroy",(deploymentsifdeploymentsisnotNoneelseself.reverse_deployments(self.deployments)),)ifnotdeployments:# return config attribute to original stateself.reverse_deployments(self.deployments)
[docs]defget_env_vars(self,deployments:list[RunwayDeploymentDefinition]|None=None)->dict[str,Any]:"""Get env_vars defined in the config. Args: deployments: List of deployments to get env_vars from. Returns: Resolved env_vars from the deployments. """deployments=deploymentsorself.deploymentsresult:dict[str,str]={}fordeploymentindeployments:obj=components.Deployment(context=self.ctx,definition=deployment,variables=self.variables)result.update(obj.env_vars_config)returnresult
[docs]definit(self,deployments:list[RunwayDeploymentDefinition]|None=None)->None:"""Init action. Args: deployments: List of deployments to run. If not provided, all deployments in the config will be run. """self.__run_action("init",deploymentsifdeploymentsisnotNoneelseself.deployments)
[docs]defplan(self,deployments:list[RunwayDeploymentDefinition]|None=None)->None:"""Plan action. Args: deployments: List of deployments to run. If not provided, all deployments in the config will be run. """self.__run_action("plan",deploymentsifdeploymentsisnotNoneelseself.deployments)
[docs]@staticmethoddefreverse_deployments(deployments:list[RunwayDeploymentDefinition],)->list[RunwayDeploymentDefinition]:"""Reverse deployments and the modules within them. Args: deployments: List of deployments to reverse. Returns: Deployments and modules in reverse order. """result:list[RunwayDeploymentDefinition]=[]fordeploymentindeployments:deployment.reverse()result.insert(0,deployment)returnresult
def__assert_config_version(self)->None:"""Assert the config supports this version of Runway."""ifnotself.required_version:LOGGER.debug("required Runway version not specified")returnif__version__inself.required_version:LOGGER.debug('current Runway version "%s" matches "%s" required by this config file',__version__,self.required_version,)returnif__version__.startswith("0.")and"dev"in__version__:LOGGER.warning("Runway is being used from a shallow clone of the repo; ""config version will not be enforced as version cannot be determined")returnLOGGER.error('current Runway version "%s" does not match "%s" required by this config file',__version__,self.required_version,)_sys.exit(1)def__run_action(self,action:type_defs.RunwayActionTypeDef,deployments:list[RunwayDeploymentDefinition]|None,)->None:"""Run an action on a list of deployments. Args: action: Name of the action. deployments: List of deployments to run. """self.ctx.command=actioncomponents.Deployment.run_list(action=action,context=self.ctx,deployments=deploymentsor[],future=self.future,variables=self.variables,)