Skip to content

Commit

Permalink
fix: DEFAULT_SUPPLIER_ACCOUNT 改存 settings (#1567)
Browse files Browse the repository at this point in the history
* fix: DEFAULT_SUPPLIER_ACCOUNT 改存 settings

* minor: BKCC_DEFAULT_SUPPLIER_ACCOUNT 支持从环境变量获取
  • Loading branch information
narasux committed Sep 28, 2021
1 parent 2618814 commit c4d7f1a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bcs-app/backend/components/cc/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(
username: str,
fields: List = None,
condition: Dict = None,
bk_supplier_account: str = constants.DEFAULT_SUPPLIER_ACCOUNT,
bk_supplier_account: str = settings.BKCC_DEFAULT_SUPPLIER_ACCOUNT,
):
"""
:param username: 查询者用户名
Expand Down
6 changes: 3 additions & 3 deletions bcs-app/backend/components/cc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BkCCConfig:
def __init__(self, host: str):
# 请求域名
self.host = host
self.prefix_path = '/api/c/compapi/v2/cc'
self.prefix_path = 'api/c/compapi/v2/cc'

# 请求地址
# 查询业务信息
Expand All @@ -55,7 +55,7 @@ def __init__(self, host: str):
class BkCCAuth(AuthBase):
"""用于蓝鲸配置平台接口的鉴权校验"""

def __init__(self, username: str, bk_supplier_account: Optional[str] = constants.DEFAULT_SUPPLIER_ACCOUNT):
def __init__(self, username: str, bk_supplier_account: Optional[str] = settings.BKCC_DEFAULT_SUPPLIER_ACCOUNT):
self.bk_app_code = settings.BCS_APP_CODE
self.bk_app_secret = settings.BCS_APP_SECRET
self.operator = username
Expand All @@ -78,7 +78,7 @@ def __call__(self, r: PreparedRequest):
class BkCCClient(BkApiClient):
""" CMDB API SDK """

def __init__(self, username: str, bk_supplier_account: Optional[str] = constants.DEFAULT_SUPPLIER_ACCOUNT):
def __init__(self, username: str, bk_supplier_account: Optional[str] = settings.BKCC_DEFAULT_SUPPLIER_ACCOUNT):
self._config = BkCCConfig(host=settings.COMPONENT_HOST)
self._client = BaseHttpClient(BkCCAuth(username, bk_supplier_account=bk_supplier_account))

Expand Down
3 changes: 0 additions & 3 deletions bcs-app/backend/components/cc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
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.
"""
# 默认开发商账号
DEFAULT_SUPPLIER_ACCOUNT = None

# 默认查询主机字段
DEFAULT_HOST_FIELDS = [
'bk_bak_operator',
Expand Down
3 changes: 2 additions & 1 deletion bcs-app/backend/components/cc/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import logging
from typing import Dict, List

from django.conf import settings
from django.utils.translation import ugettext_lazy as _

from backend.components.base import CompParseBkCommonResponseError
Expand All @@ -37,7 +38,7 @@ def __init__(
bk_set_ids: List = None,
bk_module_ids: List = None,
host_property_filter: Dict = None,
bk_supplier_account: str = constants.DEFAULT_SUPPLIER_ACCOUNT,
bk_supplier_account: str = settings.BKCC_DEFAULT_SUPPLIER_ACCOUNT,
):
"""
:param username: 查询者用户名
Expand Down
3 changes: 3 additions & 0 deletions bcs-app/backend/settings/ce/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,6 @@ def configure_workers(*args, **kwargs):
HELM_REPO_DOMAIN = os.environ.get('HELM_REPO_DOMAIN')
HELM_MERELY_REPO_URL = HELM_REPO_DOMAIN
BK_REPO_URL_PREFIX = os.environ.get('BK_REPO_URL_PREFIX')

# 默认 BKCC 设备供应方
BKCC_DEFAULT_SUPPLIER_ACCOUNT = os.environ.get('BKCC_DEFAULT_SUPPLIER_ACCOUNT', None)

0 comments on commit c4d7f1a

Please sign in to comment.