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

feat: 沙盒开发测试环境 #1657

Merged
merged 36 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5243905
feat: 沙盒开发测试环境
SheepSheepChen Oct 12, 2024
68f4e05
feat: 获取账号密码
SheepSheepChen Oct 22, 2024
eb61e92
feat: 获取账号密码
SheepSheepChen Oct 23, 2024
17e9509
feat: 获取账号密码
SheepSheepChen Oct 23, 2024
0cbd919
Merge remote-tracking branch 'upstream/main' into dev-test-sandbox
SheepSheepChen Oct 23, 2024
c7b40c3
feat: 获取账号密码
SheepSheepChen Oct 23, 2024
0adbf0f
feat: migration 修复
SheepSheepChen Oct 23, 2024
129f5d1
feat: migration 修复
SheepSheepChen Oct 23, 2024
7b3d034
feat: migration 修复
SheepSheepChen Oct 23, 2024
5d3936e
feat: dev_sandbox rename
SheepSheepChen Oct 23, 2024
66549e0
feat: 返回沙箱环境变量
SheepSheepChen Oct 23, 2024
392a8b2
feat: 返回沙箱环境变量
SheepSheepChen Oct 23, 2024
f024249
feat: 返回沙箱环境变量
SheepSheepChen Oct 23, 2024
825e0c5
feat: 返回沙箱环境变量
SheepSheepChen Oct 24, 2024
ce19642
feat: 返回应用沙箱列表
SheepSheepChen Oct 24, 2024
290ffff
feat: 返回应用沙箱列表
SheepSheepChen Oct 24, 2024
ee6f092
feat: 沙箱地址直接跳转项目目录
SheepSheepChen Oct 24, 2024
61c9a74
feat: 沙箱地址直接跳转项目目录
SheepSheepChen Oct 24, 2024
8011c2f
feat: 调整
SheepSheepChen Oct 25, 2024
2cb80b4
feat: 调整
SheepSheepChen Oct 27, 2024
7039685
fix:调整
SheepSheepChen Oct 28, 2024
8b5433b
fix:调整
SheepSheepChen Oct 30, 2024
572d45f
fix:调整
SheepSheepChen Oct 30, 2024
45dc912
fix:调整
SheepSheepChen Oct 30, 2024
1c4b067
fix:调整
SheepSheepChen Oct 30, 2024
413ce03
fix:冲突解决
SheepSheepChen Oct 30, 2024
eba400c
fix:冲突解决
SheepSheepChen Oct 30, 2024
91903db
fix:冲突解决
SheepSheepChen Oct 30, 2024
482c079
fix:冲突解决
SheepSheepChen Oct 30, 2024
32971eb
fix:调整
SheepSheepChen Oct 30, 2024
97b5a9b
fix:调整
SheepSheepChen Oct 30, 2024
fc2532c
fix:调整
SheepSheepChen Oct 30, 2024
51c04aa
fix:调整
SheepSheepChen Oct 30, 2024
4846f3d
fix:调整
SheepSheepChen Nov 1, 2024
a5b8193
fix:gen_dev_sandbox_code 使用 django get_random_string
SheepSheepChen Nov 1, 2024
8211ed8
Merge branch 'main' into dev-test-sandbox
SheepSheepChen Nov 1, 2024
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
57 changes: 48 additions & 9 deletions apiserver/paasng/paas_wl/bk_app/dev_sandbox/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# We undertake not to change the open source license (MIT license) applicable
# to the current version of the project delivered to anyone in the future.

from typing import List
from typing import Dict, List

from django.conf import settings

from .entities import IngressPathBackend, ServicePortPair

_ingress_service_conf = [
_dev_sandbox_ingress_service_conf = [
# dev sandbox 中 devserver 的路径与端口映射
{
"path_prefix": "/devserver/",
Expand All @@ -30,23 +30,62 @@
"target_port": settings.DEV_SANDBOX_DEVSERVER_PORT,
},
# dev sandbox 中 saas 应用的路径与端口映射
{"path_prefix": "/", "service_port_name": "app", "port": 80, "target_port": settings.CONTAINER_PORT},
{"path_prefix": "/app/", "service_port_name": "app", "port": 80, "target_port": settings.CONTAINER_PORT},
SheepSheepChen marked this conversation as resolved.
Show resolved Hide resolved
]


DEV_SANDBOX_SVC_PORT_PAIRS: List[ServicePortPair] = [
ServicePortPair(name=conf["service_port_name"], port=conf["port"], target_port=conf["target_port"])
for conf in _ingress_service_conf
for conf in _dev_sandbox_ingress_service_conf
]

_code_editor_ingress_service_conf = [
# code editor 的路径与端口映射
{
"path_prefix": "/code-editor/",
"service_port_name": "code-editor",
"port": 10251,
"target_port": settings.CODE_EDITOR_PORT,
},
]

CODE_SVC_PORT_PAIRS: List[ServicePortPair] = [
ServicePortPair(name=conf["service_port_name"], port=conf["port"], target_port=conf["target_port"])
for conf in _code_editor_ingress_service_conf
]


def get_ingress_path_backends(service_name: str) -> List[IngressPathBackend]:
"""get ingress path backends from _ingress_service_conf with service_name"""
def get_ingress_path_backends(
service_name: str, service_confs: List[Dict], dev_sandbox_code: str = ""
) -> List[IngressPathBackend]:
"""get ingress path backends from service_confs with service_name and dev_sandbox_code

:param service_name: Service name
:param dev_sandbox_code: dev sandbox code.
:param service_confs: service configs
"""
if not dev_sandbox_code:
return [
IngressPathBackend(
path_prefix=conf["path_prefix"],
service_name=service_name,
service_port_name=conf["service_port_name"],
)
for conf in service_confs
]

return [
IngressPathBackend(
path_prefix=conf["path_prefix"],
path_prefix=f"/dev_sandbox/{dev_sandbox_code}{conf['path_prefix']}",
service_name=service_name,
service_port_name=conf["service_port_name"],
)
for conf in _ingress_service_conf
for conf in service_confs
]


def get_dev_sandbox_ingress_path_backends(service_name: str, dev_sandbox_code: str = "") -> List[IngressPathBackend]:
return get_ingress_path_backends(service_name, _dev_sandbox_ingress_service_conf, dev_sandbox_code)


def get_code_editor_ingress_path_backends(service_name: str, dev_sandbox_code: str = "") -> List[IngressPathBackend]:
return get_ingress_path_backends(service_name, _code_editor_ingress_service_conf, dev_sandbox_code)
31 changes: 31 additions & 0 deletions apiserver/paasng/paas_wl/bk_app/dev_sandbox/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# TencentBlueKing is pleased to support the open source community by making
# 蓝鲸智云 - PaaS 平台 (BlueKing - PaaS System) available.
# Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
# Licensed under the MIT License (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://opensource.org/licenses/MIT
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on 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.
#
# We undertake not to change the open source license (MIT license) applicable
# to the current version of the project delivered to anyone in the future.

from blue_krill.data_types.enum import EnumField, StrStructuredEnum


class SourceCodeFetchMethod(StrStructuredEnum):
HTTP = EnumField("HTTP")
GIT = EnumField("GIT")
BK_REPO = EnumField("BK_REPO")


class DevSandboxStatus(StrStructuredEnum):
"""沙箱状态"""

ACTIVE = EnumField("active", label="活跃")
ERROR = EnumField("error", label="错误")
Loading