Skip to content

Commit

Permalink
Merge pull request #3 from stat-kwon/master
Browse files Browse the repository at this point in the history
refactor: change all for SpaceONE 2.0
  • Loading branch information
stat-kwon authored Dec 17, 2023
2 parents b5c8d13 + 0f04e70 commit 3dd615e
Show file tree
Hide file tree
Showing 34 changed files with 790 additions and 833 deletions.
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.config", "-m", "/opt"]
CMD ["run", "grpc-server", "spaceone.config", "-m", "/opt"]
2 changes: 1 addition & 1 deletion deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ description: SpaceONE config Helm chart for Kubernetes

type: application

version: 1.3.9
version: 1.3.10
appVersion: 1.x.y

29 changes: 4 additions & 25 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/config/config/database.yaml
- file:///opt/spaceone/config/config/shared.yaml
- file:///opt/spaceone/config/config/application.yaml
- file:///opt/spaceone/config/config/database.yaml
- file:///opt/spaceone/config/config/shared.yaml
- file:///opt/spaceone/config/config/application.yaml
GLOBAL:
MAX_WORKERS: 1000
DATABASES:
Expand All @@ -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,24 +29,4 @@ GLOBAL:
handlers:
file:
type: file
filename: /var/log/spaceone/config.log
HANDLERS:
authentication:
- backend: spaceone.core.handler.authentication_handler.AuthenticationGRPCHandler
uri: grpc://identity:50051/v1/Domain/get_public_key
authorization:
- backend: spaceone.core.handler.authorization_handler.AuthorizationGRPCHandler
uri: grpc://identity:50051/v1/Authorization/verify
CONNECTORS:
IdentityConnector:
endpoint:
v1: grpc://identity:50051
SecretConnector:
endpoint:
v1: grpc://secret:50051
PluginConnector:
endpoint:
v1: grpc://plugin:50051
RepositoryConnector:
endpoint:
v1: grpc://repository:50051
filename: /var/log/spaceone/config.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
2 changes: 1 addition & 1 deletion 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
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
25 changes: 11 additions & 14 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
Expand All @@ -14,22 +14,19 @@
# limitations under the License.

import os

from setuptools import setup, find_packages

setup(
name='spaceone-config',
version=os.environ.get('PACKAGE_VERSION'),
description='SpaceONE config service',
long_description='',
url='https://www.spaceone.dev/',
author='MEGAZONE SpaceONE Team',
author_email='[email protected]',
license='Apache License 2.0',
name="spaceone-config",
version=os.environ.get("PACKAGE_VERSION"),
description="SpaceONE config 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'
],
install_requires=["spaceone-core", "spaceone-api", "mongoengine", "mongomock"],
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__)
2 changes: 1 addition & 1 deletion src/spaceone/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
name = 'config'
name = "config"
Empty file.
53 changes: 0 additions & 53 deletions src/spaceone/config/api/v1/domain_config.py

This file was deleted.

53 changes: 0 additions & 53 deletions src/spaceone/config/api/v1/user_config.py

This file was deleted.

40 changes: 28 additions & 12 deletions src/spaceone/config/conf/global_conf.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
# Database Settings
DATABASE_AUTO_CREATE_INDEX = True
DATABASES = {
'default': {
'db': 'config',
'host': 'localhost',
'port': 27017,
'username': '',
'password': ''
"default": {
"db": "config",
"host": "localhost",
"port": 27017,
"username": "",
"password": "",
}
}

# Cache Settings
CACHES = {
'default': {},
'local': {
'backend': 'spaceone.core.cache.local_cache.LocalCache',
'max_size': 128,
'ttl': 300
}
"default": {},
"local": {
"backend": "spaceone.core.cache.local_cache.LocalCache",
"max_size": 128,
"ttl": 300,
},
}

# Handler Settings
HANDLERS = {
# "authentication": [{
# "backend": "spaceone.core.handler.authentication_handler:SpaceONEAuthenticationHandler"
# }],
# "authorization": [{
# "backend": "spaceone.core.handler.authorization_handler:SpaceONEAuthorizationHandler"
# }],
# "mutation": [{
# "backend": "spaceone.core.handler.mutation_handler:SpaceONEMutationHandler"
# }],
# "event": []
}

# Connector Settings
CONNECTORS = {}
4 changes: 0 additions & 4 deletions src/spaceone/config/conf/proto_conf.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/spaceone/config/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
28 changes: 17 additions & 11 deletions src/spaceone/config/info/domain_config_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,32 @@
from spaceone.core import utils
from spaceone.config.model.domain_config_model import DomainConfig

__all__ = ['DomainConfigInfo', 'DomainConfigsInfo']
__all__ = ["DomainConfigInfo", "DomainConfigsInfo"]


def DomainConfigInfo(domain_config_vo: DomainConfig, minimal=False):
info = {
'name': domain_config_vo.name,
"name": domain_config_vo.name,
}

if not minimal:
info.update({
'data': change_struct_type(domain_config_vo.data),
'tags': change_struct_type(domain_config_vo.tags),
'domain_id': domain_config_vo.domain_id,
'updated_at': utils.datetime_to_iso8601(domain_config_vo.updated_at),
'created_at': utils.datetime_to_iso8601(domain_config_vo.created_at)
})
info.update(
{
"data": change_struct_type(domain_config_vo.data),
"tags": change_struct_type(domain_config_vo.tags),
"domain_id": domain_config_vo.domain_id,
"updated_at": utils.datetime_to_iso8601(domain_config_vo.updated_at),
"created_at": utils.datetime_to_iso8601(domain_config_vo.created_at),
}
)

return domain_config_pb2.DomainConfigInfo(**info)


def DomainConfigsInfo(domain_config_vos, total_count, **kwargs):
return domain_config_pb2.DomainConfigsInfo(results=list(
map(functools.partial(DomainConfigInfo, **kwargs), domain_config_vos)), total_count=total_count)
return domain_config_pb2.DomainConfigsInfo(
results=list(
map(functools.partial(DomainConfigInfo, **kwargs), domain_config_vos)
),
total_count=total_count,
)
Loading

0 comments on commit 3dd615e

Please sign in to comment.