Compare commits

..

No commits in common. "24e0029d107efb97a49f49111819332334e12903" and "e9574ff7a84e803bb22e123fd559a36b53839a21" have entirely different histories.

6 changed files with 18 additions and 72 deletions

View File

@ -6,8 +6,7 @@ services:
platform-nginx: platform-nginx:
image: mathwave/sprint-repo:platform image: mathwave/sprint-repo:platform
networks: networks:
- common-infra-nginx-development - common-infra-nginx
- configurator-devlopment
environment: environment:
DB_HOST: "pg.develop.sprinthub.ru" DB_HOST: "pg.develop.sprinthub.ru"
DB_PASSWORD: $DB_PASSWORD_DEV DB_PASSWORD: $DB_PASSWORD_DEV
@ -75,7 +74,5 @@ services:
order: start-first order: start-first
networks: networks:
common-infra-nginx-development: common-infra-nginx:
external: true
configurator-development:
external: true external: true

View File

@ -7,7 +7,6 @@ services:
image: mathwave/sprint-repo:platform image: mathwave/sprint-repo:platform
networks: networks:
- common-infra-nginx - common-infra-nginx
- configurator
environment: environment:
DB_HOST: "pg.sprinthub.ru" DB_HOST: "pg.sprinthub.ru"
DB_PASSWORD: $DB_PASSWORD_PROD DB_PASSWORD: $DB_PASSWORD_PROD
@ -83,5 +82,3 @@ services:
networks: networks:
common-infra-nginx: common-infra-nginx:
external: true external: true
configurator:
external: true

View File

@ -28,7 +28,7 @@ jobs:
run: docker push mathwave/sprint-repo:platform run: docker push mathwave/sprint-repo:platform
deploy-dev: deploy-dev:
name: Deploy dev name: Deploy dev
runs-on: [prod] runs-on: [dev]
needs: push needs: push
steps: steps:
- name: login - name: login
@ -46,4 +46,4 @@ jobs:
RABBITMQ_PASSWORD: ${{ secrets.RABBITMQ_PASSWORD_DEV }} RABBITMQ_PASSWORD: ${{ secrets.RABBITMQ_PASSWORD_DEV }}
VK_SERVICE_TOKEN: ${{ secrets.VK_SERVICE_TOKEN }} VK_SERVICE_TOKEN: ${{ secrets.VK_SERVICE_TOKEN }}
YANDEX_SERVICE_TOKEN: ${{ secrets.YANDEX_SERVICE_TOKEN }} YANDEX_SERVICE_TOKEN: ${{ secrets.YANDEX_SERVICE_TOKEN }}
run: docker stack deploy --with-registry-auth -c ./.deploy/deploy-dev.yaml platform-development run: docker stack deploy --with-registry-auth -c ./.deploy/deploy-dev.yaml platform

View File

@ -1,43 +0,0 @@
from requests import get, put, post, delete
URL_CONFIGS = 'http://configurator/api/v1/configs'
URL_EXPERIMENTS = 'http://configurator/api/v1/configs'
def get_configs(project, stage):
response = get(URL_CONFIGS, params={'project': project, 'stage': stage})
if response.status_code != 200:
return []
return response.json()
def create_config(project, stage, name):
post(URL_CONFIGS, json={'project': project, 'stage': stage, 'name': name})
def update_config(id, value):
put(URL_CONFIGS, json={'id': id, 'value': value})
def delete_config(id):
delete(URL_CONFIGS, json={'id': id})
def get_experiments(project, stage):
response = get(URL_EXPERIMENTS, params={'project': project, 'stage': stage})
if response.status_code != 200:
return []
return response.json()
def create_experiment(project, stage, name):
post(URL_EXPERIMENTS, json={'project': project, 'stage': stage, 'name': name})
def update_experiment(id, enabled, condition):
put(URL_EXPERIMENTS, json={'id': id, 'enabled': enabled, 'condition': condition})
def delete_experiment(id):
delete(URL_CONFIGS, json={'id': id})

View File

@ -3,7 +3,6 @@ from json import loads
from django.http import HttpResponse, JsonResponse from django.http import HttpResponse, JsonResponse
from BaseLib.BaseView import BaseView from BaseLib.BaseView import BaseView
from BaseLib.configurator import *
from Platform import settings from Platform import settings
from configs.models import Config from configs.models import Config
@ -21,35 +20,31 @@ class ConfigsView(BaseView):
return '/configs/?stage=production' return '/configs/?stage=production'
self.stage = self.request.GET['stage'] self.stage = self.request.GET['stage']
self.context['stage'] = self.stage self.context['stage'] = self.stage
# self.context['configs'] = Config.objects.filter(project=self.request.user.selected_project, self.context['configs'] = Config.objects.filter(project=self.request.user.selected_project,
# stage=self.stage).order_by('name') stage=self.stage).order_by('name')
self.context['configs'] = get_configs(self.request.user.selected_project.name, self.stage)
def post_create_config(self): def post_create_config(self):
create_config(self.request.user.selected_project.name, self.stage, self.request.POST['name']) Config.objects.create(name=self.request.POST['name'], project=self.request.user.selected_project, stage=self.stage)
# Config.objects.create(name=self.request.POST['name'], project=self.request.user.selected_project, stage=self.stage)
return '/configs/?stage=' + self.stage return '/configs/?stage=' + self.stage
def post_delete(self): def post_delete(self):
# config = Config.objects.get(id=self.request.POST['config']) config = Config.objects.get(id=self.request.POST['config'])
# config.delete() config.delete()
delete_config(self.request.POST['config']) return '/configs/?stage=' + config.stage
return '/configs/?stage=' + self.stage
def post_save(self): def post_save(self):
data = self.request.POST['data'] data = self.request.POST['data']
# config = Config.objects.get(id=self.request.POST['config']) config = Config.objects.get(id=self.request.POST['config'])
try: try:
data = loads(data) data = loads(data)
except: except:
self.context['incorrect_config'] = self.request.POST['config'] self.context['incorrect_config'] = config
self.context['incorrect_data'] = data self.context['incorrect_data'] = data
self.context['error'] = True self.context['error'] = True
return return
update_config(self.request.POST['config'], data) config.data = data
# config.data = data config.save()
# config.save() return '/configs/?stage=' + config.stage
return '/configs/?stage=' + self.stage
def get_config(request): def get_config(request):

View File

@ -28,7 +28,7 @@
</div> </div>
{% if error %} {% if error %}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
Конфиг не имеет вид JSON! Конфиг {{ incorrect_config.name }} не имеет вид JSON!
</div> </div>
{% endif %} {% endif %}
<table class="table"> <table class="table">
@ -52,7 +52,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<textarea style="width: 100%; height: 800px;{% if config.id == incorrect_config %}border: 1px solid #f00;{% endif %}" name="data">{% if config.id == incorrect_config.id %}{{ incorrect_data }}{% else %}{{ config.data_pretty }}{% endif %}</textarea> <textarea style="width: 100%; height: 800px;{% if config.id == incorrect_config.id %}border: 1px solid #f00;{% endif %}" name="data">{% if config.id == incorrect_config.id %}{{ incorrect_data }}{% else %}{{ config.data_pretty }}{% endif %}</textarea>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" name="action" value="save" class="btn btn-secondary">Сохранить</button> <button type="submit" name="action" value="save" class="btn btn-secondary">Сохранить</button>