Commit c086a657 authored by Pavel Kuzmenko's avatar Pavel Kuzmenko
Browse files

Merge branch 'mike/specs-fix' into 'master'

fix(specs): removed specs config map

See merge request !1999
parents 2fef8126 b6002a16
......@@ -10,7 +10,6 @@ GIT_STAMP ?= $(shell git describe || echo v0.1.0)
GIT_TAG ?= $(shell git describe --abbrev=0)
TWINE_USERNAME ?= unknown
TWINE_PASSWORD ?= unknown
SPECS_URL = https://gitlab.prozorro.sale/api/v4/projects/16/jobs/artifacts/master/download?job=build-specs-artifacts
CI_COMMIT_REF_NAME ?= ''
CI_PIPELINE_ID ?= 1
COMPOSE_PROJECT_NAME ?= $(PROJECT_NAME)-$(CI_PIPELINE_ID)
......@@ -183,20 +182,6 @@ generate-swagger-client:
publish-swagger-client:
cd python_client && python setup.py sdist bdist_wheel && twine upload dist/*.whl -u $(TWINE_PUBLIC_USERNAME) -p $(TWINE_PUBLIC_PASSWORD)
## Load specs
load-specs:
curl --output specs.zip --header "PRIVATE-TOKEN: $(DEPLOYMENT_API_TOKEN)" $(SPECS_URL) --fail
mkdir -p tmp_raw_specs; unzip -o specs.zip -d tmp_raw_specs
python unpack_specs.py
rm -r specs.zip tmp_raw_specs #cleanup
patch-local-specs:
curl --output specs.zip --header "PRIVATE-TOKEN: $(DEPLOYMENT_API_TOKEN)" $(SPECS_URL) --fail
mkdir -p tmp_raw_specs; unzip -o specs.zip -d tmp_raw_specs
python patch_local_specs.py
rm -r specs.zip tmp_raw_specs #cleanup
## Build swagger
build-swagger:
@docker rm -f procedure-$(CI_COMMIT_SHORT_SHA)-swagger || true
......
......@@ -76,21 +76,7 @@ Each procedure must have swagger schema (in the `models/schema` folder) to gener
* docker
* docker-compose
### Local spec update
To get specs locally you should set DEPLOYMENT_API_TOKEN variable, with value of gitlab personal access [token](https://gitlab.prozorro.sale/profile/personal_access_tokens), read_api rights.
```
export DEPLOYMENT_API_TOKEN=<personal_access_token>
```
to update specs run:
```
make load-specs
```
### Running locally
Ensure that you have [spec files](#local-spec-update) locally.
And run:
```
make run
```
......
{{- $Context := dict "ArchitectComponent" "specs" "Release" .Release "Chart" .Chart "Values" .Values.configMaps.specs "Global" . -}}
{{- include "prozorro-helm-template.base-config-map" $Context -}}
rootLogLevel: INFO
consoleLogLevel: DEBUG
spec: {}
swaggerDoc: '1'
authApiBlockStrict: '1'
auction_url: https://auction-dev.prozorro.sale
......@@ -15,7 +14,7 @@ document_service_databridge: document-storage-databridge
archivist_databridge: archivist-databridge
notifications_url: notification-databridge
auth_url: https://procedure-dev.prozorro.sale
imagePullSecrets: []
imagePullSecrets: [ ]
mongoWriteConcernValue: "1"
procedureApps: "basicSell, dgf, legitimatePropertyLease, landRental, landSell, railwayCargo, renewables, subsoil, timber, arrestedAssets, alienation, commercialSell, bankRuptcy, regulationsPropertyLease, commercialPropertyLease, simpleSell"
procedureCustomSpecs: "0"
......@@ -75,8 +74,6 @@ env:
value: "{{ .Values.procedureCustomSpecs }}"
volumeMounts:
- name: specs
mountPath: /specs/
- name: config
mountPath: /config/logging.yml
subPath: logging.yml
......@@ -91,9 +88,6 @@ volumes:
- name: config
configMap:
name: "{{ .Release.Name }}-{{ .Chart.Name }}-config"
- name: specs
configMap:
name: "{{ .Release.Name }}-{{ .Chart.Name }}-specs"
- name: date-config
configMap:
name: date-config
......@@ -233,11 +227,3 @@ configMaps:
class: 'prozorro_sale.tools.logger.LogFormatter'
format: '[%(asctime)s.%(msecs)03dZ] | %(name)s | %(levelname)s - %(message)s'
datefmt: '%Y-%m-%dT%H:%M:%S'
specs:
enabled: true
data: |
{{- range $value := .Values.spec }}
{{ $value._proc_name }}.yml: |
procedure: {{ $value | toYaml | nindent 8 }}
{{- end -}}
import os
import shutil
import yaml
RAW_SPECS_PATH = 'tmp_raw_specs/specs'
OUTPUT_DIR = 'specs'
def clean_folder(folder):
for filename in os.listdir(folder):
file_path = os.path.join(folder, filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception as e:
print('Failed to delete %s. Reason: %s' % (file_path, e)) # noqa
if __name__ == '__main__':
os.makedirs(OUTPUT_DIR, exist_ok=True)
clean_folder(OUTPUT_DIR)
base_specs_data = {}
files = [file for file in os.listdir(RAW_SPECS_PATH) if file.endswith('yaml')]
for base_spec_file in files:
with open(os.path.join(RAW_SPECS_PATH, base_spec_file), 'r') as f:
data = yaml.safe_load(f)
procedure_spec_data = data['procedure']['spec']
base_specs_data.update(procedure_spec_data)
for spec_name, spec_content in base_specs_data.items():
f_name = os.path.join(OUTPUT_DIR, spec_name + '.yml')
with open(f_name, 'w') as f:
data = yaml.dump({'procedure': spec_content}, f)
print('Specs unpacked successfully!') # noqa
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment