Skip to content

Commit

Permalink
feature: Add library
Browse files Browse the repository at this point in the history
  • Loading branch information
doosuu committed Aug 31, 2023
1 parent 60ad170 commit 49e0bfa
Show file tree
Hide file tree
Showing 44 changed files with 2,710 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2023 Robert Bosch GmbH
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

FROM ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.1

COPY scripts/*.sh /tmp/scripts/
RUN find /tmp/scripts/ -type f -iname "*.sh" -exec chmod +x {} \;
RUN /bin/bash /tmp/scripts/container-set.sh
RUN /bin/bash /tmp/scripts/configure-proxies.sh
47 changes: 47 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "Velocitas lib",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--init",
"--privileged"
],
"containerEnv": {
"GITHUB_API_TOKEN": "${localEnv:GITHUB_API_TOKEN}"
},
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"python.pythonPath": "/usr/bin/python3",
"python.defaultInterpreterPath": "/usr/bin/python3",
// Only Flake8 is used as linter and static code analyzer, as faster tool
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
// Style Formatter
"python.formatting.provider": "black",
// Security Linter
"python.linting.banditEnabled": true,
"python.disableInstallationCheck": true,
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
}
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"cschleiden.vscode-github-actions",
"dotjoshjohnson.xml",
"matangover.mypy",
"ms-python.isort",
"ms-python.flake8"
]
}
},
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
99 changes: 99 additions & 0 deletions .devcontainer/scripts/configure-proxies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash
# Copyright (c) 2023 Robert Bosch GmbH and Microsoft Corporation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

echo "#######################################################"
echo "### Configure-proxies ###"
echo "#######################################################"

if [ "$HTTP_PROXY" != "" ]; then
USE_PROXIES="true"
CONFIGURE_GIT="true"
FTP_PROXY=$HTTP_PROXY
ALL_PROXY=$HTTP_PROXY
NO_PROXY="localhost,127.0.0.1,0.0.0.0,10.0.0.0/8,192.168.122.0/24,172.0.0.0/8,cattle-system.svc,.svc,.cluster.local"
fi

echo "Use proxies: $USE_PROXIES"
echo "Http-proxy: $HTTP_PROXY"
echo "Https-proxy: $HTTPS_PROXY"
echo "Ftp-proxy: $FTP_PROXY"
echo "All proxy: $ALL_PROXY"
echo "No proxy: $NO_PROXY"
echo "Configure git: $CONFIGURE_GIT"

set -e

if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi

# Determine the appropriate non-root user
# This recognizes the same possible user names found in Microsoft base Docker images
# as the scripts in the ../library-scripts directory
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
USERNAME=""
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
if id -u ${CURRENT_USER} > /dev/null 2>&1; then
USERNAME=${CURRENT_USER}
break
fi
done
elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
USERNAME=root
fi

if [ "${USERNAME}" = "" ]; then
USERNAME=vscode
fi
echo "Selected user name is ${USERNAME}"

if [ "${USE_PROXIES}" = "true" ]; then
echo "Configuring proxies"

mkdir -p /home/${USERNAME}
echo "export HTTP_PROXY=\"${HTTP_PROXY}\"" >> /home/${USERNAME}/.profile
echo "export http_proxy=\"${HTTP_PROXY}\"" >> /home/${USERNAME}/.profile
echo "export HTTPS_PROXY=\"${HTTPS_PROXY}\"" >> /home/${USERNAME}/.profile
echo "export https_proxy=\"${HTTPS_PROXY}\"" >> /home/${USERNAME}/.profile
echo "export FTP_PROXY=\"${FTP_PROXY}\"" >> /home/${USERNAME}/.profile
echo "export ftp_proxy=\"${FTP_PROXY}\"" >> /home/${USERNAME}/.profile
echo "export ALL_PROXY=\"${ALL_PROXY}\"" >> /home/${USERNAME}/.profile
echo "export all_proxy=\"${ALL_PROXY}\"" >> /home/${USERNAME}/.profile
echo "export NO_PROXY=\"${NO_PROXY}\"" >> /home/${USERNAME}/.profile
echo "export no_proxy=\"${NO_PROXY}\"" >> /home/${USERNAME}/.profile

# # Apply common tools proxy settings for installed tools
if [ "${CONFIGURE_GIT}" = "true" ]; then
su -c "git config --global http.proxy ${HTTP_PROXY}" ${USERNAME}
su -c "git config --global https.proxy ${HTTPS_PROXY}" ${USERNAME}
git config --global http.proxy ${HTTP_PROXY}
git config --global https.proxy ${HTTPS_PROXY}
fi

echo "# Proxy settings" >> /etc/wgetrc
echo "http_proxy=${HTTP_PROXY}" >> /etc/wgetrc
echo "https_proxy=${HTTPS_PROXY}" >> /etc/wgetrc
echo "ftp_proxy=${FTP_PROXY}" >> /etc/wgetrc
echo "no_proxy=${NO_PROXY}" >> /etc/wgetrc
echo "use_proxy=on" >> /etc/wgetrc

# enable root user to "apt-get" via proxy
echo "Acquire::http::proxy \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf
echo "Acquire::https::proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf
fi

exit 0
20 changes: 20 additions & 0 deletions .devcontainer/scripts/container-set.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# Copyright (c) 2023 Robert Bosch GmbH and Microsoft Corporation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

echo "#######################################################"
echo "### Checking container creation ###"
echo "#######################################################"
useradd vscode --password vscode -m
usermod -aG sudo vscode
47 changes: 47 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Automatically normalize line endings for all text-based files
# http://git-scm.com/docs/gitattributes#_end_of_line_conversion
* text=auto

# For the following file types, normalize line endings to LF on
# checkin and prevent conversion to CRLF when they are checked out
# (this is required in order to prevent newline related issues like,
# for example, after the build script is run)
.* text eol=lf
*.css text eol=lf
*.html text eol=lf
*.js text eol=lf
*.json text eol=lf
*.md text eol=lf
*.sh text eol=lf
*.txt text eol=lf
*.xml text eol=lf
*.yml text eol=lf
*.yaml text eol=lf

# Source files
# ============
*.pxd text diff=python
*.py text diff=python
*.py3 text diff=python
*.pyw text diff=python
*.pyx text diff=python
*.pyz text diff=python
*.pyi text diff=python

# Binary files
# ============
*.db binary
*.p binary
*.pkl binary
*.pickle binary
*.pyc binary export-ignore
*.pyo binary export-ignore
*.pyd binary

# Jupyter notebook
*.ipynb text

# Note: .db, .p, and .pkl files are associated
# with the python modules ``pickle``, ``dbm.*``,
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
# (among others).
83 changes: 83 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: 🐞 Bug Report
description: Provide a general summary of the bug in the title below.
title: "[Bug]: "
labels:
- bug
body:
- type: markdown
attributes:
value: |
**Thank you :heart: for taking the time to fill out this bug report!**
- type: dropdown
id: severity
validations:
required: true
attributes:
label: Severity
description: How severe is the bug in your opinion?
multiple: false
options:
- "Trivial"
- "Medium"
- "High"
- "Critical"
- "Blocker"
- type: input
id: version
validations:
required: true
attributes:
label: What release version, tag or commit-hash did you use?
description: Please include a link if possible.
placeholder: v0.1.0 or 06f432a00e4c66804202c91bdfb9c9b12823928b
- type: textarea
id: current-behavior
validations:
required: true
attributes:
label: Current Behavior
description: Tell us what happened instead of the expected behavior.
placeholder: Error message appeared when I cloned a repository...
- type: textarea
id: steps-to-reproduce
validations:
required: true
attributes:
label: Steps to Reproduce
description: Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant
placeholder: |
1. ...
2. ...
3. ...
- type: textarea
id: expected-behavior
validations:
required: true
attributes:
label: Expected Behavior
description: Tell us what should happen
placeholder: Clone of repository shall be prune of errors.
- type: textarea
id: possible-solution
validations:
required: false
attributes:
label: Possible Solution
description: Fix/reason of the bug suggestion
placeholder: A possible solution or fix is...
- type: textarea
id: additional-information
validations:
required: false
attributes:
label: Additional Information
description: Provide an additional detailed description / screenshots / evidences of the bug
placeholder: I would like to add...
- type: checkboxes
id: code-of-conduct
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our "Code of Conduct".
options:
- label: I agree to follow this project's "Code of Conduct".
required: true
45 changes: 45 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 🛠️ Feature Request
description: Suggest an idea to help us improve our product.
title: "[Feature]: "
labels:
- "enhancement"
body:
- type: markdown
attributes:
value: |
**Thank you :heart: for taking the time to fill out this feature request report!**
We kindly ask you to search if an issue already exists for your requested feature.
We are happy about contributions from all users.
- type: textarea
attributes:
label: Description
description: |
A clear and concise description of the feature you're interested in.
validations:
required: true

- type: textarea
attributes:
label: Suggested Solution
description: |
Describe the solution you'd like to be implemented. Provide a clear and concise description of what you want to happen.
validations:
required: false

- type: textarea
attributes:
label: Alternatives
description: |
Describe alternatives you've considered.
A clear and concise description of alternative solutions or features you've considered.
validations:
required: false

- type: textarea
attributes:
label: Additional Context
description: |
Add any other context about the problem here.
validations:
required: false
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ❓ Question or general issue
description: Approach us with a question
title: "[Q]: "
labels:
- question
body:
- type: markdown
attributes:
value: |
**We are happy that you have a question to ask!**
- type: textarea
validations:
required: true
attributes:
label: Question
description: Feel free to ask us if you need assistance
placeholder: How can I create a repository based on your template?
Loading

0 comments on commit 49e0bfa

Please sign in to comment.