コード例 #1
0
ファイル: run.py プロジェクト: yuanbw/nauta
    def create(self,
               namespace: str,
               labels: Dict[str, str] = None,
               annotations: Dict[str, str] = None):
        run_kubernetes = KubernetesObject(
            self,
            client.V1ObjectMeta(name=self.name,
                                namespace=namespace,
                                labels=labels,
                                annotations=annotations),
            kind="Run",
            apiVersion=f"{self.api_group_name}/{self.crd_version}")
        schema = RunKubernetesSchema()
        body, err = schema.dump(run_kubernetes)
        if err:
            raise RuntimeError(
                f'preparing dump of RunKubernetes request object error - {err}'
            )
        self.body = body

        response = super().create(namespace=namespace)
        created_run, err = schema.load(response)
        if err:
            raise RuntimeError(
                f'load of RunKubernetes request object error - {err}')
        return created_run
コード例 #2
0
ファイル: run.py プロジェクト: yuanbw/nauta
    def update(self):
        run_kubernetes = KubernetesObject(
            self,
            client.V1ObjectMeta(name=self.name, namespace=self.namespace),
            kind="Run",
            apiVersion=f"{self.api_group_name}/{self.crd_version}")
        schema = RunKubernetesSchema()
        body, err = schema.dump(run_kubernetes)
        if err:
            raise RuntimeError(
                f'preparing dump of RunKubernetes request object error - {err}'
            )
        self.body = body

        response = super().update()
        updated_run, err = schema.load(response)
        if err:
            raise RuntimeError(
                f'load of RunKubernetes request object error - {err}')
        return updated_run