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

377 version param #991

Merged
merged 4 commits into from
Jan 23, 2024
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
16 changes: 12 additions & 4 deletions deploy/stacks/deploy_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class _DeployConfig:

def __init__(self):
self._config = self._read_config_file()
self._version = self._read_version_file()

def get_dataall_version(self) -> str:
return json.dumps(self._version)

def get_property(self, key: str, default=None) -> Any:
"""
Expand Down Expand Up @@ -52,20 +56,24 @@ def set_property(self, key: str, value: Any) -> None:

@classmethod
def _read_config_file(cls) -> Dict[str, Any]:
with open(cls._path_to_file()) as config_file:
with open(cls._path_to_file("config.json")) as config_file:
return json.load(config_file)

@classmethod
def _read_version_file(cls) -> Dict[str, Any]:
with open(cls._path_to_file("version.json")) as version_file:
return json.load(version_file)

@staticmethod
def _path_to_file() -> str:
def _path_to_file(filename) -> str:
"""Tries to get a property. If not defined it tries to resolve the config from the current file's directory"""
path = os.getenv("config_location")
if path:
return path
return os.path.join(Path(__file__).parents[2], "config.json")
return os.path.join(Path(__file__).parents[2], filename)

def __repr__(self):
return str(self._config)


deploy_config = _DeployConfig()

10 changes: 10 additions & 0 deletions deploy/stacks/param_store_stack.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import random
import string

Expand All @@ -8,6 +9,7 @@
)

from .pyNestedStack import pyNestedClass
from .deploy_config import deploy_config


class ParamStoreStack(pyNestedClass):
Expand Down Expand Up @@ -122,6 +124,14 @@ def __init__(
description=f"Stores dataall external id for environment {envname}",
)

aws_ssm.StringParameter(
self,
f'dataall_{envname}_version',
parameter_name=f'/dataall/{envname}/version',
string_value=str(json.dumps(deploy_config.get_dataall_version())),
description='Deployed data all version'
)

def _get_external_id_value(envname, account_id, region):
"""
For first deployments and upgrades from <=V1.5.6 to >=v1.6 - returns False and a new ssm parameter created,
Expand Down
1 change: 1 addition & 0 deletions deploy/stacks/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ def set_quality_gate_stage(self):
f'aws codeartifact login --tool npm --repository {self.codeartifact.codeartifact_npm_repo_name} --domain {self.codeartifact.codeartifact_domain_name} --domain-owner {self.codeartifact.domain.attr_owner}',
'npm install',
'npm run copy-config',
'npm run copy-version',
'npm run lint -- --quiet',
],
role=self.baseline_codebuild_role.without_policy_updates(),
Expand Down
2 changes: 2 additions & 0 deletions frontend/docker/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ COPY --chown=${CONTAINER_USER}:root ./frontend .

# Copy config.json to docker root, because app scripts read it from ".."
COPY --chown=${CONTAINER_USER}:root ./config.json /
# Copy vesion.json to docker root, because app scripts read it from ".."
COPY --chown=${CONTAINER_USER}:root ./version.json /

# Disable linting before starting the server
ENV DISABLE_ESLINT_PLUGIN=true
Expand Down
2 changes: 2 additions & 0 deletions frontend/docker/prod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ RUN . ~/.nvm/nvm.sh && npm install -g npm@9 yarn

COPY --chown=${CONTAINER_USER}:root ./frontend/package.json ./frontend/yarn.lock ./
COPY --chown=${CONTAINER_USER}:root ./config.json /
# Copy vesion.json to docker root, because app scripts read it from ".."
COPY --chown=${CONTAINER_USER}:root ./version.json /

RUN . ~/.nvm/nvm.sh && yarn install

Expand Down
7 changes: 4 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"start": "react-scripts start",
"build": "react-scripts build",
"copy-config": "mkdir -p ./src/generated; cp ../config.json ./src/generated/",
"postinstall": "yarn copy-config",
"prestart": "yarn copy-config",
"prebuild": "yarn copy-config",
"copy-version": "mkdir -p ./src/generated; cp ../version.json ./src/generated/",
"postinstall": "yarn copy-config; yarn copy-version",
"prestart": "yarn copy-config; yarn copy-version",
"prebuild": "yarn copy-config; yarn copy-version",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint --ext js src",
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/design/components/Logo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, CardMedia, Grid, Typography } from '@mui/material';
import { Box, CardMedia, Grid, Tooltip, Typography } from '@mui/material';
import version from '../../generated/version.json';

export const Logo = () => (
<>
Expand All @@ -16,9 +17,11 @@ export const Logo = () => (
</Box>
</Grid>
<Grid item>
<Typography variant="h5" color="#fff">
&nbsp;data.all
</Typography>
<Tooltip title={'version ' + version.version} placement="top-start">
<Typography variant="h5" color="#fff">
&nbsp;data.all
</Typography>
</Tooltip>
</Grid>
</Grid>
</>
Expand Down
4 changes: 4 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "2.2.0",
"release-date": "14.12.2023"
}
Loading