Skip to content
Merged
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[flake8]
ignore = F405, W503, E203
exclude =
*migrations*,
# python related
*.pyc,
.git,
__pycache__,
*/node_modules/*
./static/*
./blueking/*
*/blueking/*
./blueapps/*
*/blueapps/*
./pipeline/*
./sites/*
./config/default.py
./scripts_tools/*
./support-files/*
./upgrade.py
./iam/*


max-line-length=120
max-complexity=26
format=pylint
show_source=False
statistics=True
count=True
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
profile = black
known_first_party = bk_plugin_framework,bk_plugin_runtime
line_length = 120
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
default_stages: [pre-commit]
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-merge-conflict

- repo: https://github.com/psf/black
rev: 25.12.0
hooks:
- id: black
language_version: python3.10
args:
- "--line-length=120"

- repo: https://github.com/pycqa/isort
rev: 7.0.0
hooks:
- id: isort

- repo: https://github.com/pycqa/flake8
rev: 7.3.0
hooks:
- id: flake8
args:
- "--config"
- ".flake8"
23 changes: 0 additions & 23 deletions bk-plugin-framework/.flake8

This file was deleted.

1 change: 0 additions & 1 deletion bk-plugin-framework/bk_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down
1 change: 0 additions & 1 deletion bk-plugin-framework/bk_plugin/versions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down
1 change: 0 additions & 1 deletion bk-plugin-framework/bk_plugin_framework/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down
1 change: 0 additions & 1 deletion bk-plugin-framework/bk_plugin_framework/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion bk-plugin-framework/bk_plugin_framework/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand All @@ -9,6 +8,7 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""

from enum import Enum


Expand Down
5 changes: 3 additions & 2 deletions bk-plugin-framework/bk_plugin_framework/envs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand All @@ -9,15 +8,17 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
import os

import base64
import hashlib
import logging
import os

try:
from pydantic.v1 import BaseSettings
except ImportError:
from pydantic import BaseSettings

from django.conf import settings as default_settings

logger = logging.getLogger("bk_plugin")
Expand Down
4 changes: 2 additions & 2 deletions bk-plugin-framework/bk_plugin_framework/hub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand All @@ -10,9 +9,10 @@
specific language governing permissions and limitations under the License.
"""

import logging
import os
import typing
import logging

from bk_plugin_framework.utils.module_load import load_form_module_path

logger = logging.getLogger("bk-plugin-framework")
Expand Down
12 changes: 6 additions & 6 deletions bk-plugin-framework/bk_plugin_framework/kit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand All @@ -14,13 +13,14 @@
from pydantic.v1 import Field
except ImportError:
from pydantic import Field # noqa

from bk_plugin_framework.kit.plugin import ( # noqa
Plugin,
InputsModel,
Callback,
Context,
OutputsModel,
ContextRequire,
State,
Callback,
FormModel,
InputsModel,
OutputsModel,
Plugin,
State,
)
12 changes: 6 additions & 6 deletions bk-plugin-framework/bk_plugin_framework/kit/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand All @@ -9,18 +8,19 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""

import json

from django.utils.decorators import method_decorator
from apigw_manager.apigw.decorators import apigw_require
from bkoauth import get_app_access_token
from django.conf import settings as default_settings
from rest_framework.views import APIView
from django.utils.decorators import method_decorator
from rest_framework.request import Request
from bkoauth import get_app_access_token
from apigw_manager.apigw.decorators import apigw_require
from rest_framework.views import APIView

from bk_plugin_framework.envs import settings
from bk_plugin_framework.kit.decorators import login_exempt, inject_user_token
from bk_plugin_framework.kit.authentication import CsrfExemptSessionAuthentication
from bk_plugin_framework.kit.decorators import inject_user_token, login_exempt

custom_authentication_classes = (
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand All @@ -9,6 +8,7 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""

from rest_framework.authentication import SessionAuthentication


Expand Down
2 changes: 1 addition & 1 deletion bk-plugin-framework/bk_plugin_framework/kit/decorators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand All @@ -9,6 +8,7 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""

from functools import wraps

from bk_plugin_framework.envs import settings
Expand Down
12 changes: 7 additions & 5 deletions bk-plugin-framework/bk_plugin_framework/kit/plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand All @@ -10,18 +9,21 @@
specific language governing permissions and limitations under the License.
"""

import inspect
import re
import typing
import inspect

try:
from pydantic.v1 import BaseModel
except ImportError:
from pydantic import BaseModel

from bk_plugin_framework.hub import VersionHub
from bk_plugin_framework.constants import State
from bk_plugin_framework.runtime.callback.api import prepare_callback, CallbackPreparation
from bk_plugin_framework.hub import VersionHub
from bk_plugin_framework.runtime.callback.api import (
CallbackPreparation,
prepare_callback,
)

VALID_VERSION_PATTERN = re.compile(r"^[0-9]+\.[0-9]+\.[0-9][a-z0-9]*$")

Expand Down Expand Up @@ -50,7 +52,7 @@ class ContextRequire(BaseModel):
pass


class Callback(object):
class Callback:
def __init__(self, callback_id: str = "", callback_data: dict = {}):
self.id = callback_id
self.data = callback_data
Expand Down
13 changes: 7 additions & 6 deletions bk-plugin-framework/bk_plugin_framework/metrics.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
import os
import socket
import time
from functools import wraps

from prometheus_client import Counter, Histogram, Gauge
from prometheus_client import Counter, Gauge, Histogram


def get_hostname():
Expand Down Expand Up @@ -129,14 +128,16 @@ def _wrapper(*args, **kwargs):

# 正在执行的 EXECUTE 数量
BK_PLUGIN_EXECUTE_RUNNING_PROCESSES = Gauge(
name="bk_plugin_execute_running_processes", documentation="count running state processes",
labelnames=["hostname", "version"]
name="bk_plugin_execute_running_processes",
documentation="count running state processes",
labelnames=["hostname", "version"],
)

# 正在执行的 SCHEDULE 数量
BK_PLUGIN_SCHEDULE_RUNNING_PROCESSES = Gauge(
name="bk_plugin_schedule_running_processes", documentation="count running state schedules",
labelnames=["hostname", "version"]
name="bk_plugin_schedule_running_processes",
documentation="count running state schedules",
labelnames=["hostname", "version"],
)

# CALLBACK 异常次数
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down
12 changes: 6 additions & 6 deletions bk-plugin-framework/bk_plugin_framework/runtime/callback/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand All @@ -9,23 +8,24 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
import uuid
import time

import json
import logging
import time
import uuid

from django.conf import settings as default_settings
from celery import current_app
from cryptography.fernet import Fernet
from django.conf import settings as default_settings

from bk_plugin_framework.constants import State
from bk_plugin_framework.envs import settings
from bk_plugin_framework.runtime.schedule.models import Schedule
from bk_plugin_framework.constants import State

logger = logging.getLogger("bk_plugin")


class CallbackPreparation(object):
class CallbackPreparation:
def __init__(self, callback_id: str, callback_url: str):
self.id = callback_id
self.url = callback_url
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云 - PaaS平台 (BlueKing - PaaS System) available.
Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved.
Expand Down
Loading