Skip to content

Commit

Permalink
Merge pull request #8 from stat-kwon/master
Browse files Browse the repository at this point in the history
Apply SpaceONE 2.0
  • Loading branch information
stat-kwon authored Dec 12, 2023
2 parents 4c3d495 + 4be3da3 commit 2eddfb3
Show file tree
Hide file tree
Showing 39 changed files with 905 additions and 963 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ RUN pip install --upgrade spaceone-api
EXPOSE ${SPACEONE_PORT}

ENTRYPOINT ["spaceone"]
CMD ["grpc", "spaceone.board", "-m", "/opt"]
CMD ["run", "grpc-server","spaceone.board", "-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
18 changes: 4 additions & 14 deletions deploy/helm/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REMOTE_URL:
- file:///opt/spaceone/board/config/database.yaml
- file:///opt/spaceone/board/config/shared.yaml
- file:///opt/spaceone/board/config/application.yaml
- file:///opt/spaceone/board/config/database.yaml
- file:///opt/spaceone/board/config/shared.yaml
- file:///opt/spaceone/board/config/application.yaml
GLOBAL:
MAX_WORKERS: 1000
DATABASES:
Expand Down Expand Up @@ -30,14 +30,4 @@ GLOBAL:
handlers:
file:
type: file
filename: /var/log/spaceone/board.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/board.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 @@ -84,7 +84,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 "_" }}']
command: ['spaceone', 'run','scheduler', 'spaceone.{{ regexReplaceAll "-" .Values.name "_" }}']
volumeMounts:
- name: default-conf
mountPath: /opt/spaceone/{{ .Values.name }}/config/config.yaml
Expand Down
24 changes: 9 additions & 15 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@
from setuptools import setup, find_packages

setup(
name='spaceone-board',
version=os.environ.get('PACKAGE_VERSION'),
description='SpaceONE board service',
long_description='',
url='https://www.spaceone.dev/',
author='MEGAZONE SpaceONE Team',
author_email='[email protected]',
license='Apache License 2.0',
name="spaceone-board",
version=os.environ.get("PACKAGE_VERSION"),
description="SpaceONE board 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',
'redis'
],
install_requires=["spaceone-core", "spaceone-api", "mongoengine", "boto3", "redis"],
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__)
6 changes: 1 addition & 5 deletions src/spaceone/board/conf/board_conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
DEFAULT_BOARDS = [
{
'name': 'Notice'
}
]
DEFAULT_BOARDS = [{"name": "Notice"}]
37 changes: 18 additions & 19 deletions src/spaceone/board/conf/global_conf.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Database Settings
DATABASES = {
'default': {
'db': 'board',
'host': 'localhost',
'port': 27017,
'username': '',
'password': ''
"default": {
"db": "board",
"host": "localhost",
"port": 27017,
"username": "",
"password": "",
}
}

# Cache Settings
CACHES = {
'default': {
"default": {
# Redis Example
# 'backend': 'spaceone.core.cache.redis_cache.RedisCache',
# 'host': '<host>',
Expand All @@ -22,35 +22,34 @@

# 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',
'file_manager': 'grpc://file-manager:50051',
}
"SpaceConnector": {
"backend": "spaceone.core.connector.space_connector.SpaceConnector",
"endpoints": {
"identity": "grpc://identity:50051",
"file_manager": "grpc://file-manager:50051",
},
}
}

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

This file was deleted.

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


class ERROR_BOARD_CATEGORIES_NOT_ALLOW_EMPTY(ERROR_INVALID_ARGUMENT):
_message = 'The board categories does not allow empty. (board_id = {board_id})'
_message = "The board categories does not allow empty. (board_id = {board_id})"
12 changes: 7 additions & 5 deletions src/spaceone/board/error/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@


class ERROR_SETTING_CATEGORIES(ERROR_BASE):
_message = 'First, you need to set the categories of the board.'
_message = "First, you need to set the categories of the board."


class ERROR_INVALID_CATEGORY(ERROR_BASE):
_message = 'Invalid category (category = {category}), you must choose one of {categories}'
_message = (
"Invalid category (category = {category}), you must choose one of {categories}"
)


class ERROR_INVALID_KEY_IN_OPTIONS(ERROR_BASE):
_message = 'Invalid key in options'
_message = "Invalid key in options"


class ERROR_NOT_FOUND_FILE(ERROR_BASE):
_message = '{file_id} does not exist in {domain_id}'
_message = "{file_id} does not exist in {domain_id}"


class ERROR_INVALID_FILE_STATE(ERROR_BASE):
_message = 'file state is invalid (file_id = {file_id}, state = {state})'
_message = "file state is invalid (file_id = {file_id}, state = {state})"
2 changes: 1 addition & 1 deletion src/spaceone/board/info/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from spaceone.board.info.common_info import *
from spaceone.board.info.board_info import *
from spaceone.board.info.post_info import *
from spaceone.board.info.post_info import *
22 changes: 13 additions & 9 deletions src/spaceone/board/info/board_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@

def BoardInfo(board_vo: Board, minimal=False):
info = {
'board_id': board_vo.board_id,
'name': board_vo.name,
'categories': board_vo.categories,
"board_id": board_vo.board_id,
"name": board_vo.name,
"categories": board_vo.categories,
}

if not minimal:
info.update({
'tags': change_struct_type(board_vo.tags),
'created_at': utils.datetime_to_iso8601(board_vo.created_at)
})
info.update(
{
"tags": change_struct_type(board_vo.tags),
"created_at": utils.datetime_to_iso8601(board_vo.created_at),
}
)

return board_pb2.BoardInfo(**info)


def BoardsInfo(board_vos, total_count, **kwargs):
return board_pb2.BoardsInfo(results=list(
map(functools.partial(BoardInfo, **kwargs), board_vos)), total_count=total_count)
return board_pb2.BoardsInfo(
results=list(map(functools.partial(BoardInfo, **kwargs), board_vos)),
total_count=total_count,
)
2 changes: 1 addition & 1 deletion src/spaceone/board/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
47 changes: 25 additions & 22 deletions src/spaceone/board/info/post_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,43 @@

from spaceone.board.model.post_model import Post

__all__ = ['PostInfo', 'PostsInfo']
__all__ = ["PostInfo", "PostsInfo"]


def PostInfo(post_vo: Post, minimal=False, files_info=None):
info = {
'board_id': post_vo.board_id,
'post_id': post_vo.post_id,
'post_type': post_vo.post_type,
'category': post_vo.category,
'title': post_vo.title,
'scope': post_vo.scope,
'domain_id': post_vo.domain_id,
"board_id": post_vo.board_id,
"post_id": post_vo.post_id,
"category": post_vo.category,
"title": post_vo.title,
"permission_group": post_vo.permission_group,
"domain_id": post_vo.domain_id,
}

if not minimal:
info.update({
'contents': post_vo.contents,
'view_count': post_vo.view_count,
'writer': post_vo.writer,
'options': change_struct_type(post_vo.options),
'user_id': post_vo.user_id,
'user_domain_id': post_vo.user_domain_id,
'created_at': utils.datetime_to_iso8601(post_vo.created_at),
'updated_at': utils.datetime_to_iso8601(post_vo.updated_at)
})
info.update(
{
"contents": post_vo.contents,
"view_count": post_vo.view_count,
"writer": post_vo.writer,
"options": change_struct_type(post_vo.options),
"user_id": post_vo.user_id,
"user_domain_id": post_vo.user_domain_id,
"created_at": utils.datetime_to_iso8601(post_vo.created_at),
"updated_at": utils.datetime_to_iso8601(post_vo.updated_at),
}
)

if files_info:
info['files'] = change_list_value_type(files_info)
info["files"] = change_list_value_type(files_info)
else:
info['files'] = change_list_value_type(post_vo.files)
info["files"] = change_list_value_type(post_vo.files)

return post_pb2.PostInfo(**info)


def PostsInfo(post_vos, total_count, **kwargs):
return post_pb2.PostsInfo(results=list(
map(functools.partial(PostInfo, **kwargs), post_vos)), total_count=total_count)
return post_pb2.PostsInfo(
results=list(map(functools.partial(PostInfo, **kwargs), post_vos)),
total_count=total_count,
)
9 changes: 9 additions & 0 deletions src/spaceone/board/interface/grpc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from spaceone.core.pygrpc.server import GRPCServer
from spaceone.board.interface.grpc.board import Board
from spaceone.board.interface.grpc.post import Post

_all_ = ["app"]

app = GRPCServer()
app.add_service(Board)
app.add_service(Post)
Loading

0 comments on commit 2eddfb3

Please sign in to comment.