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

refactor: change all apis for SpaceONE 2.0 #33

Merged
merged 2 commits into from
Dec 18, 2023
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
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM cloudforet/python-core:1.12
FROM cloudforet/python-core:2.0
ARG PACKAGE_VERSION
ENV PYTHONUNBUFFERED 1
ENV SPACEONE_PORT 50051
Expand All @@ -9,7 +9,8 @@ ENV PACKAGE_VERSION=$PACKAGE_VERSION

COPY pkg/pip_requirements.txt pip_requirements.txt

RUN pip install --upgrade -r pip_requirements.txt
RUN pip install --upgrade pip && \
pip install --upgrade -r pip_requirements.txt

COPY src ${SRC_DIR}
WORKDIR ${SRC_DIR}
Expand All @@ -21,4 +22,4 @@ RUN pip install --upgrade spaceone-api
EXPOSE ${SPACEONE_PORT}

ENTRYPOINT ["spaceone"]
CMD ["grpc", "spaceone.dashboard", "-m", "/opt"]
CMD ["run", "grpc-server", "spaceone.dashboard", "-m", "/opt"]
2 changes: 1 addition & 1 deletion deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.3.10
version: 1.3.11

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
13 changes: 1 addition & 12 deletions deploy/helm/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ GLOBAL:
backend: spaceone.core.cache.redis_cache.RedisCache
host: redis
port: 6379
db: 1
encoding: utf-8
socket_timeout: 10
socket_connect_timeout: 10
Expand All @@ -30,14 +29,4 @@ GLOBAL:
handlers:
file:
type: file
filename: /var/log/spaceone/dashboard.log

HANDLERS:
authentication:
- backend: spaceone.core.handler.authentication_handler.AuthenticationGRPCHandler
uri: grpc+ssl://identity.dev.spaceone.dev:443/v1/Domain/get_public_key
authorization:
- backend: spaceone.core.handler.authorization_handler.AuthorizationGRPCHandler
uri: grpc+ssl://identity.dev.spaceone.dev:443/v1/Authorization/verify
mutation:
- backend: spaceone.core.handler.mutation_handler.SpaceONEMutationHandler
filename: /var/log/spaceone/dashboard.log
2 changes: 1 addition & 1 deletion deploy/helm/templates/deployment-rest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
resources:
{{- toYaml .Values.resources.rest | nindent 12 }}
{{- end }}
command: ['spaceone', 'rest', 'spaceone.{{ regexReplaceAll "-" .Values.name "_" }}', '-p', '8000']
command: ['spaceone', 'run', 'rest-server', 'spaceone.{{ regexReplaceAll "-" .Values.name "_" }}', '-p', '8000']
ports:
- containerPort: 8000
volumeMounts:
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/templates/deployment-scheduler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
resources:
{{- toYaml .Values.resources.scheduler | nindent 12 }}
{{- end }}
command: ['spaceone', 'scheduler', 'spaceone.{{ regexReplaceAll "-" .Values.name "_" }}']
command: ['spaceone', 'run', 'scheduler', 'spaceone.{{ regexReplaceAll "-" .Values.name "_" }}']
volumeMounts:
- name: default-conf
mountPath: /opt/spaceone/{{ .Values.name }}/config/config.yaml
Expand Down Expand Up @@ -85,7 +85,7 @@ spec:
{{- end }}

volumes:
- name: default-conf
- name: default-conf
configMap:
name: {{ .Values.name }}-conf
- name: database-conf
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
resources:
{{- toYaml .Values.resources.worker | nindent 12 }}
{{- end }}
command: ['spaceone', 'scheduler', 'spaceone.{{ regexReplaceAll "-" .Values.name "_" }}', '-m', '/opt']
command: ['spaceone', 'run', 'scheduler', 'spaceone.{{ regexReplaceAll "-" .Values.name "_" }}', '-m', '/opt']
volumeMounts:
- name: default-conf
mountPath: /opt/spaceone/{{ .Values.name }}/config/config.yaml
Expand Down
23 changes: 9 additions & 14 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@
from setuptools import setup, find_packages

setup(
name='spaceone-dashboard',
version=os.environ.get('PACKAGE_VERSION'),
description='SpaceONE dashboard service',
long_description='',
url='https://www.spaceone.dev/',
author='MEGAZONE SpaceONE Team',
author_email='[email protected]',
license='Apache License 2.0',
name="spaceone-dashboard",
version=os.environ.get("PACKAGE_VERSION"),
description="SpaceONE dashboard service",
long_description="",
url="https://www.spaceone.dev/",
author="MEGAZONE SpaceONE Team",
author_email="[email protected]",
license="Apache License 2.0",
packages=find_packages(),
install_requires=[
'spaceone-core',
'spaceone-api',
'mongoengine',
'boto3'
],
install_requires=["spaceone-core", "spaceone-api", "mongoengine", "boto3"],
zip_safe=False,
)
2 changes: 1 addition & 1 deletion src/spaceone/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
36 changes: 17 additions & 19 deletions src/spaceone/dashboard/conf/global_conf.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
# Database Settings
DATABASES = {
'default': {
'db': 'dashboard',
'host': 'localhost',
'port': 27017,
'username': '',
'password': ''
"default": {
"db": "dashboard",
"host": "localhost",
"port": 27017,
"username": "",
"password": "",
}
}

# Cache Settings
CACHES = {
'default': {
"default": {
# Redis Example
# 'backend': 'spaceone.core.cache.redis_cache.RedisCache',
# 'host': '<host>',
# 'port': 6379,
# 'db': 0
}
}

# Handler Configuration
HANDLERS = {
'authentication': [
"authentication": [
# Default Authentication Handler
# {
# 'backend': 'spaceone.core.handler.authentication_handler.AuthenticationGRPCHandler',
# 'uri': 'grpc://identity:50051/v1/Domain/get_public_key'
# }
],
'authorization': [
"authorization": [
# Default Authorization Handler
# {
# 'backend': 'spaceone.core.handler.authorization_handler.AuthorizationGRPCHandler',
# 'uri': 'grpc://identity:50051/v1/Authorization/verify'
# }
],
'mutation': [],
'event': []
"mutation": [],
"event": [],
}

# Connector Settings
CONNECTORS = {
'SpaceConnector': {
'backend': 'spaceone.core.connector.space_connector.SpaceConnector',
'endpoints': {
'identity': 'grpc://identity:50051',
}
"SpaceConnector": {
"backend": "spaceone.core.connector.space_connector:SpaceConnector",
"endpoints": {
"identity": "grpc://identity:50051",
},
}
}

# Log Settings
LOG = {
}
LOG = {}
5 changes: 0 additions & 5 deletions src/spaceone/dashboard/conf/proto_conf.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/spaceone/dashboard/error/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from spaceone.dashboard.error.common_dashboard import *
from spaceone.dashboard.error.dashboard import *
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class ERROR_LATEST_VERSION(ERROR_INVALID_ARGUMENT):
_message = 'Do not remove latest version. (version = {version})'
_message = "Do not remove latest version. (version = {version})"
7 changes: 2 additions & 5 deletions src/spaceone/dashboard/info/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from spaceone.dashboard.info.dashboard_info import *
from spaceone.dashboard.info.dashboard_version_info import *
from spaceone.dashboard.info.common_info import *
from spaceone.dashboard.info.domain_dashboard_info import *
from spaceone.dashboard.info.domain_dashboard_version_info import *
from spaceone.dashboard.info.project_dashboard_info import *
from spaceone.dashboard.info.project_dashboard_version_info import *
from spaceone.dashboard.info.custom_widget_info import *
2 changes: 1 addition & 1 deletion src/spaceone/dashboard/info/common_info.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from google.protobuf.empty_pb2 import Empty
from spaceone.core.pygrpc.message_type import *

__all__ = ['EmptyInfo', 'StatisticsInfo']
__all__ = ["EmptyInfo", "StatisticsInfo"]


def EmptyInfo():
Expand Down
36 changes: 0 additions & 36 deletions src/spaceone/dashboard/info/custom_widget_info.py

This file was deleted.

46 changes: 46 additions & 0 deletions src/spaceone/dashboard/info/dashboard_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import functools
from spaceone.api.dashboard.v1 import dashboard_pb2
from spaceone.core.pygrpc.message_type import *
from spaceone.core import utils
from spaceone.dashboard.model.dashboard_model import Dashboard

__all__ = ["DashboardInfo", "DashboardsInfo"]


def DashboardInfo(dashboard_vo: Dashboard, minimal=False):
info = {
"dashboard_id": dashboard_vo.dashboard_id,
"name": dashboard_vo.name,
"dashboard_type": dashboard_vo.dashboard_type,
"version": dashboard_vo.version,
"labels": change_list_value_type(dashboard_vo.labels),
"resource_group": dashboard_vo.resource_group,
"user_id": dashboard_vo.user_id,
"project_id": dashboard_vo.project_id,
"workspace_id": dashboard_vo.workspace_id,
"domain_id": dashboard_vo.domain_id,
}

if not minimal:
info.update(
{
"layouts": change_list_value_type(dashboard_vo.layouts)
if dashboard_vo.layouts
else None,
"variables": change_struct_type(dashboard_vo.variables),
"settings": change_struct_type(dashboard_vo.settings),
"variables_schema": change_struct_type(dashboard_vo.variables_schema),
"tags": change_struct_type(dashboard_vo.tags),
"created_at": utils.datetime_to_iso8601(dashboard_vo.created_at),
"updated_at": utils.datetime_to_iso8601(dashboard_vo.updated_at),
}
)

return dashboard_pb2.DashboardInfo(**info)


def DashboardsInfo(dashboard_vos, total_count, **kwargs):
return dashboard_pb2.DashboardsInfo(
results=list(map(functools.partial(DashboardInfo, **kwargs), dashboard_vos)),
total_count=total_count,
)
52 changes: 52 additions & 0 deletions src/spaceone/dashboard/info/dashboard_version_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import functools
from spaceone.api.dashboard.v1 import dashboard_pb2
from spaceone.core.pygrpc.message_type import *
from spaceone.core import utils
from spaceone.dashboard.model import DashboardVersion

__all__ = ["DashboardVersionInfo", "DashboardVersionsInfo"]


def DashboardVersionInfo(
dashboard_version_vo: DashboardVersion, minimal=False, latest_version=None
):
info = {
"dashboard_id": dashboard_version_vo.dashboard_id,
"version": dashboard_version_vo.version,
"created_at": utils.datetime_to_iso8601(dashboard_version_vo.created_at),
"domain_id": dashboard_version_vo.domain_id,
}

if latest_version:
if latest_version == dashboard_version_vo.version:
info.update({"latest": True})
else:
info.update({"latest": False})

if not minimal:
info.update(
{
"layouts": change_list_value_type(dashboard_version_vo.layouts)
if dashboard_version_vo.layouts
else None,
"variables": change_struct_type(dashboard_version_vo.variables),
"settings": change_struct_type(dashboard_version_vo.settings),
"variables_schema": change_struct_type(
dashboard_version_vo.variables_schema
),
}
)

return dashboard_pb2.DashboardVersionInfo(**info)


def DashboardVersionsInfo(dashboard_version_vos, total_count, **kwargs):
return dashboard_pb2.DashboardVersionsInfo(
results=list(
map(
functools.partial(DashboardVersionInfo, **kwargs),
dashboard_version_vos,
)
),
total_count=total_count,
)
Loading