Skip to content
This repository was archived by the owner on Jan 12, 2025. It is now read-only.

Commit 79fbfc5

Browse files
style: standard formating (#560)
1 parent 7c6b27a commit 79fbfc5

File tree

8 files changed

+58
-54
lines changed

8 files changed

+58
-54
lines changed

src/composer/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Composer (via Github Releases)
1+
2+
# Composer (via Github Releases) (composer)
23

34
Composer is an open source dependency management tool for PHP.
45

@@ -15,3 +16,5 @@ Composer is an open source dependency management tool for PHP.
1516
| Options Id | Description | Type | Default Value |
1617
|-----|-----|-----|-----|
1718
| version | Select the version to install. | string | latest |
19+
20+

src/composer/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
"installsAfter": [
1818
"ghcr.io/devcontainers-contrib/features/gh-release"
1919
]
20-
}
20+
}

src/composer/install.sh

100644100755
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
#!/bin/bash -i
21

32
set -e
43

54
. ./library_scripts.sh
65

76
# nanolayer is a cli utility which keeps container layers as small as possible
87
# source code: https://github.com/devcontainers-contrib/nanolayer
9-
# `ensure_nanolayer` is a bash function that will find any existing nanolayer installations,
10-
# and if missing - will download a temporary copy that automatically get deleted at the end
8+
# `ensure_nanolayer` is a bash function that will find any existing nanolayer installations,
9+
# and if missing - will download a temporary copy that automatically get deleted at the end
1110
# of the script
12-
ensure_nanolayer nanolayer_location "v0.5.4"
11+
ensure_nanolayer nanolayer_location "v0.5.5"
12+
1313

1414
$nanolayer_location \
1515
install \
1616
devcontainer-feature \
1717
"ghcr.io/devcontainers-contrib/features/gh-release:1.0.24" \
1818
--option repo='composer/composer' --option binaryNames='composer' --option version="$VERSION"
19+
20+
1921

2022
echo 'Done!'
23+

src/composer/library_scripts.sh

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#!/bin/bash -i
1+
22

33
clean_download() {
44
# The purpose of this function is to download a file with minimal impact on container layer size
5-
# this means if no valid downloader is found (curl or wget) then we install a downloader (currently wget) in a
6-
# temporary manner, and making sure to
5+
# this means if no valid downloader is found (curl or wget) then we install a downloader (currently wget) in a
6+
# temporary manner, and making sure to
77
# 1. uninstall the downloader at the return of the function
88
# 2. revert back any changes to the package installer database/cache (for example apt-get lists)
9-
# The above steps will minimize the leftovers being created while installing the downloader
9+
# The above steps will minimize the leftovers being created while installing the downloader
1010
# Supported distros:
1111
# debian/ubuntu/alpine
1212

@@ -15,16 +15,16 @@ clean_download() {
1515
tempdir=$(mktemp -d)
1616
downloader_installed=""
1717

18-
function _apt_get_install() {
18+
_apt_get_install() {
1919
tempdir=$1
2020

21-
# copy current state of apt list - in order to revert back later (minimize contianer layer size)
22-
cp -p -R /var/lib/apt/lists $tempdir
21+
# copy current state of apt list - in order to revert back later (minimize contianer layer size)
22+
cp -p -R /var/lib/apt/lists $tempdir
2323
apt-get update -y
2424
apt-get -y install --no-install-recommends wget ca-certificates
2525
}
2626

27-
function _apt_get_cleanup() {
27+
_apt_get_cleanup() {
2828
tempdir=$1
2929

3030
echo "removing wget"
@@ -35,21 +35,20 @@ clean_download() {
3535
rm -r /var/lib/apt/lists && mv $tempdir/lists /var/lib/apt/lists
3636
}
3737

38-
function _apk_install() {
38+
_apk_install() {
3939
tempdir=$1
40-
# copy current state of apk cache - in order to revert back later (minimize contianer layer size)
41-
cp -p -R /var/cache/apk $tempdir
40+
# copy current state of apk cache - in order to revert back later (minimize contianer layer size)
41+
cp -p -R /var/cache/apk $tempdir
4242

4343
apk add --no-cache wget
4444
}
4545

46-
function _apk_cleanup() {
46+
_apk_cleanup() {
4747
tempdir=$1
4848

4949
echo "removing wget"
50-
apk del wget
50+
apk del wget
5151
}
52-
5352
# try to use either wget or curl if one of them already installer
5453
if type curl >/dev/null 2>&1; then
5554
downloader=curl
@@ -76,7 +75,7 @@ clean_download() {
7675
if [ $downloader = "wget" ] ; then
7776
wget -q $url -O $output_location
7877
else
79-
curl -sfL $url -o $output_location
78+
curl -sfL $url -o $output_location
8079
fi
8180

8281
# NOTE: the cleanup procedure was not implemented using `trap X RETURN` only because
@@ -90,54 +89,49 @@ clean_download() {
9089
echo "distro not supported"
9190
exit 1
9291
fi
93-
fi
92+
fi
9493

9594
}
9695

96+
9797
ensure_nanolayer() {
9898
# Ensure existance of the nanolayer cli program
9999
local variable_name=$1
100100

101101
local required_version=$2
102-
# normalize version
103-
if ! [[ $required_version == v* ]]; then
104-
required_version=v$required_version
105-
fi
106102

107-
local nanolayer_location=""
103+
local __nanolayer_location=""
108104

109105
# If possible - try to use an already installed nanolayer
110-
if [[ -z "${NANOLAYER_FORCE_CLI_INSTALLATION}" ]]; then
111-
if [[ -z "${NANOLAYER_CLI_LOCATION}" ]]; then
106+
if [ -z "${NANOLAYER_FORCE_CLI_INSTALLATION}" ]; then
107+
if [ -z "${NANOLAYER_CLI_LOCATION}" ]; then
112108
if type nanolayer >/dev/null 2>&1; then
113109
echo "Found a pre-existing nanolayer in PATH"
114-
nanolayer_location=nanolayer
110+
__nanolayer_location=nanolayer
115111
fi
116112
elif [ -f "${NANOLAYER_CLI_LOCATION}" ] && [ -x "${NANOLAYER_CLI_LOCATION}" ] ; then
117-
nanolayer_location=${NANOLAYER_CLI_LOCATION}
118-
echo "Found a pre-existing nanolayer which were given in env variable: $nanolayer_location"
113+
__nanolayer_location=${NANOLAYER_CLI_LOCATION}
114+
echo "Found a pre-existing nanolayer which were given in env variable: $__nanolayer_location"
119115
fi
120116

121117
# make sure its of the required version
122-
if ! [[ -z "${nanolayer_location}" ]]; then
118+
if ! [ -z "${__nanolayer_location}" ]; then
123119
local current_version
124-
current_version=$($nanolayer_location --version)
125-
if ! [[ $current_version == v* ]]; then
126-
current_version=v$current_version
127-
fi
120+
current_version=$($__nanolayer_location --version)
121+
128122

129123
if ! [ $current_version == $required_version ]; then
130124
echo "skipping usage of pre-existing nanolayer. (required version $required_version does not match existing version $current_version)"
131-
nanolayer_location=""
125+
__nanolayer_location=""
132126
fi
133127
fi
134128

135129
fi
136130

137-
# If not previuse installation found, download it temporarly and delete at the end of the script
138-
if [[ -z "${nanolayer_location}" ]]; then
131+
# If not previuse installation found, download it temporarly and delete at the end of the script
132+
if [ -z "${__nanolayer_location}" ]; then
139133

140-
if [ "$(uname -sm)" == "Linux x86_64" ] || [ "$(uname -sm)" == "Linux aarch64" ]; then
134+
if [ "$(uname -sm)" = 'Linux x86_64' ] || [ "$(uname -sm)" = "Linux aarch64" ]; then
141135
tmp_dir=$(mktemp -d -t nanolayer-XXXXXXXXXX)
142136

143137
clean_up () {
@@ -147,7 +141,7 @@ ensure_nanolayer() {
147141
}
148142
trap clean_up EXIT
149143

150-
144+
151145
if [ -x "/sbin/apk" ] ; then
152146
clib_type=musl
153147
else
@@ -158,11 +152,11 @@ ensure_nanolayer() {
158152

159153
# clean download will minimize leftover in case a downloaderlike wget or curl need to be installed
160154
clean_download https://github.com/devcontainers-contrib/cli/releases/download/$required_version/$tar_filename $tmp_dir/$tar_filename
161-
155+
162156
tar xfzv $tmp_dir/$tar_filename -C "$tmp_dir"
163157
chmod a+x $tmp_dir/nanolayer
164-
nanolayer_location=$tmp_dir/nanolayer
165-
158+
__nanolayer_location=$tmp_dir/nanolayer
159+
166160

167161
else
168162
echo "No binaries compiled for non-x86-linux architectures yet: $(uname -m)"
@@ -171,5 +165,8 @@ ensure_nanolayer() {
171165
fi
172166

173167
# Expose outside the resolved location
174-
declare -g ${variable_name}=$nanolayer_location
168+
export ${variable_name}=$__nanolayer_location
169+
175170
}
171+
172+

src/sqlfluff/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ Fluff is an extensible and modular linter designed to help you write good SQL an
1818
| version | Select the version to install. | string | latest |
1919
| plugins | A space delimitered list of sqlfluff plugins (will be injected into the sqlfluff pipx env). See proposals for examples. | string | - |
2020

21+

src/sqlfluff/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "sqlfluff",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"name": "SqlFluff (via pipx)",
55
"documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/sqlfluff",
66
"description": "Fluff is an extensible and modular linter designed to help you write good SQL and catch errors and bad SQL before it hits your database.",
@@ -27,4 +27,4 @@
2727
"ghcr.io/devcontainers-contrib/features/pipx-package",
2828
"ghcr.io/devcontainers/features/python"
2929
]
30-
}
30+
}

src/sqlfluff/install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ set -e
55

66
# nanolayer is a cli utility which keeps container layers as small as possible
77
# source code: https://github.com/devcontainers-contrib/nanolayer
8-
# `ensure_nanolayer` is a bash function that will find any existing nanolayer installations,
9-
# and if missing - will download a temporary copy that automatically get deleted at the end
8+
# `ensure_nanolayer` is a bash function that will find any existing nanolayer installations,
9+
# and if missing - will download a temporary copy that automatically get deleted at the end
1010
# of the script
11-
ensure_nanolayer nanolayer_location "v0.5.0"
11+
ensure_nanolayer nanolayer_location "v0.5.5"
1212

1313

1414
$nanolayer_location \
1515
install \
1616
devcontainer-feature \
1717
"ghcr.io/devcontainers-contrib/features/pipx-package:1.1.7" \
18-
--option package='sqlfluff' --option version="$VERSION" --option injections="$PLUGINS"
19-
18+
--option package='sqlfluff' --option injections="$PLUGINS" --option version="$VERSION"
19+
2020

2121

2222
echo 'Done!'

test/composer/scenarios.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"composer": {}
66
}
77
}
8-
}
8+
}

0 commit comments

Comments
 (0)