Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: type error when call DeploymentQuerySet.owned_by_module with env #1639

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions apiserver/paasng/paasng/platform/engine/models/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@
import logging
from dataclasses import dataclass
from pathlib import Path
from typing import Dict, List, Optional
from typing import Dict, List, Optional, Union

import cattr
from attrs import define
from django.db import models
from jsonfield import JSONField

from paasng.misc.metrics import DEPLOYMENT_STATUS_COUNTER, DEPLOYMENT_TIME_CONSUME_HISTOGRAM
from paasng.platform.applications.constants import AppEnvironment
from paasng.platform.applications.models import ModuleEnvironment
from paasng.platform.bkapp_model.constants import ImagePullPolicy
from paasng.platform.bkapp_model.entities import AutoscalingConfig, ProbeSet, ProcService
from paasng.platform.engine.constants import BuildStatus, JobStatus
from paasng.platform.engine.models.base import OperationVersionBase
from paasng.platform.modules.constants import SourceOrigin
from paasng.platform.modules.models import Module
from paasng.platform.modules.models.deploy_config import HookList, HookListField
from paasng.platform.sourcectl.constants import VersionType
from paasng.platform.sourcectl.models import VersionInfo
Expand All @@ -47,9 +49,12 @@ def filter_by_env(self, env: ModuleEnvironment):
"""Get all deploys under an env"""
return self.filter(app_environment=env)

def owned_by_module(self, module, environment=None):
def owned_by_module(self, module: Module, environment: Union[AppEnvironment, None] = None):
"""Return deployments owned by module"""
envs = module.get_envs(environment=environment)
envs = module.get_envs()
if environment:
envs = envs.filter(environment=environment)

return self.filter(app_environment__in=envs)

def latest_succeeded(self):
Expand Down