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

Convert File Type for Files or Remote Hyperlinks in Continuous Deployment #1010

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
4 changes: 3 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM ubuntu:20.04 as base-environment

ADD ./ci-cd/python/requirements.txt .

ENV TZ=US/Eastern
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

Expand All @@ -15,7 +17,7 @@ RUN apt-get install -y apt-utils build-essential git jq libxml2-utils maven node
RUN npm install -g npm n
RUN n latest
RUN npm install --loglevel verbose -g ajv-cli@"^4.0.x" ajv-formats@"^1.5.x" json-diff markdown-link-check yaml-convert@"^1.0.x" yargs
RUN pip3 install lxml
RUN pip3 install -r requirements.txt

#RUN useradd --create-home --home-dir /home/user user
#USER user
Expand Down
14 changes: 2 additions & 12 deletions build/ci-cd/copy-and-convert-content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,7 @@ post_process_content() {
if [ "$VERBOSE" = "true" ]; then
echo -e "${P_INFO}Translating relative XML paths to JSON paths in '${P_END}${target_file_relative}${P_INFO}'.${P_END}"
fi
# Remove extra slashes
perl -pi -e 's,\\/,/,g' "${target_file}"
# translate OSCAL mime types
perl -pi -e 's,(application/(oscal\.)?[a-z]+\+)xml\",\1json\",g' "${target_file}"
# relative content paths
# translate path names for local references
perl -pi -e 's,((?:\.\./)+(?:(?!xml/)[^\s/"'']+/)+)xml/((?:(?!.xml)[^\s"'']+)+).xml,\1json/\2.json,g' "${target_file}"
python "$OSCALDIR/build/ci-cd/python/convert-filetypes.py" --old-extension xml --new-extension json "${target_file}"
fi

# produce pretty JSON
Expand Down Expand Up @@ -205,11 +199,7 @@ post_process_content() {
if [ "$VERBOSE" = "true" ]; then
echo -e "${P_INFO}Translating relative paths in '${P_END}${yaml_file_relative}${P_INFO}'.${P_END}"
fi
# translate OSCAL mime types
perl -pi -e 's,(application/oscal\.[a-z]+\+)json\",\1yaml\",g' "${yaml_file}"
# translate path names for local references
perl -pi -e 's,((?:\.\./)+(?:(?!json/)[^\s/"'']+/)+)json/((?:(?!.json)[^\s"'']+)+).json,\1yaml/\2.yaml,g' "${yaml_file}"

python "$OSCALDIR/build/ci-cd/python/convert-filetypes.py" --old-extension json --new-extension yaml "${yaml_file}"
echo -e "${P_OK}Created YAML '${P_END}${yaml_file_relative}${P_OK}'.${P_END}"
;;
xml)
Expand Down
Loading