Skip to content

Commit 7a66bb9

Browse files
committed
Merge branch 'feat/hurl' into feat/all-new-features
# Conflicts: # .github/workflows/test.yaml # README.md # test/_global/all-tools.sh # test/_global/scenarios.json
2 parents 9849da5 + 2f2eeda commit 7a66bb9

8 files changed

Lines changed: 159 additions & 9 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
- hyperfine
4242
- glow
4343
- fx
44+
- hurl
4445
baseImage:
4546
- debian:latest
4647
- ubuntu:latest

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ This repository contains a _collection_ of Features.
4040
| hyperfine | https://github.com/sharkdp/hyperfine | A command-line benchmarking tool. |
4141
| Glow | https://github.com/charmbracelet/glow | Render markdown on the CLI, with pizzazz! 💅🏻 |
4242
| fx | https://github.com/antonmedv/fx | Terminal JSON viewer & processor. |
43+
| hurl | https://github.com/Orange-OpenSource/hurl | Run and test HTTP requests with plain text. |
4344

4445

4546

@@ -428,6 +429,9 @@ Running `glow --version` inside the built container will print the version of gl
428429
### `fx`
429430

430431
Running `fx --version` inside the built container will print the version of fx.
432+
### `hurl`
433+
434+
Running `hurl --version` inside the built container will print the version of hurl.
431435

432436
```jsonc
433437
{
@@ -442,6 +446,7 @@ Running `fx --version` inside the built container will print the version of fx.
442446
"ghcr.io/jsburckhardt/devcontainer-features/hyperfine:1": {}
443447
"ghcr.io/jsburckhardt/devcontainer-features/glow:1": {}
444448
"ghcr.io/jsburckhardt/devcontainer-features/fx:1": {}
449+
"ghcr.io/jsburckhardt/devcontainer-features/hurl:1": {}
445450
}
446451
}
447452
```
@@ -456,4 +461,5 @@ zoxide --version
456461
hyperfine --version
457462
glow --version
458463
fx --version
464+
hurl --version
459465
```

src/hurl/devcontainer-feature.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "hurl",
3+
"id": "hurl",
4+
"version": "1.0.0",
5+
"description": "Run and test HTTP requests with plain text.",
6+
"options": {
7+
"version": {
8+
"type": "string",
9+
"default": "latest",
10+
"description": "Version of hurl to install from GitHub releases e.g. 8.0.1"
11+
}
12+
}
13+
}

src/hurl/install.sh

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env bash
2+
3+
# Variables
4+
REPO_OWNER="Orange-OpenSource"
5+
REPO_NAME="hurl"
6+
BINARY_NAME="hurl"
7+
HURL_VERSION="${VERSION:-"latest"}"
8+
GITHUB_API_REPO_URL="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases"
9+
10+
set -e
11+
12+
if [ "$(id -u)" -ne 0 ]; then
13+
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
14+
exit 1
15+
fi
16+
17+
# Clean up
18+
rm -rf /var/lib/apt/lists/*
19+
20+
# Checks if packages are installed and installs them if not
21+
check_packages() {
22+
if ! dpkg -s "$@" >/dev/null 2>&1; then
23+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
24+
echo "Running apt-get update..."
25+
apt-get update -y
26+
fi
27+
apt-get -y install --no-install-recommends "$@"
28+
fi
29+
}
30+
31+
# Make sure we have curl and jq
32+
check_packages curl jq ca-certificates
33+
34+
# Function to get the latest version from GitHub API
35+
get_latest_version() {
36+
curl -s "${GITHUB_API_REPO_URL}/latest" | jq -r ".tag_name"
37+
}
38+
39+
# Check if a version is passed as an argument
40+
if [ -z "$HURL_VERSION" ] || [ "$HURL_VERSION" == "latest" ]; then
41+
# No version provided, get the latest version
42+
HURL_VERSION=$(get_latest_version)
43+
echo "No version provided or 'latest' specified, installing the latest version: $HURL_VERSION"
44+
else
45+
echo "Installing version from environment variable: $HURL_VERSION"
46+
fi
47+
48+
# Determine the OS and architecture
49+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
50+
ARCH=$(uname -m)
51+
52+
case "$ARCH" in
53+
x86_64)
54+
ARCH="x86_64"
55+
;;
56+
aarch64)
57+
ARCH="aarch64"
58+
;;
59+
*)
60+
echo "Unsupported architecture: $ARCH"
61+
exit 1
62+
;;
63+
esac
64+
65+
case "$OS" in
66+
linux)
67+
OS="unknown-linux-gnu"
68+
;;
69+
darwin)
70+
OS="apple-darwin"
71+
;;
72+
*)
73+
echo "Unsupported OS: $OS"
74+
exit 1
75+
;;
76+
esac
77+
78+
# Construct the download URL
79+
DOWNLOAD_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${HURL_VERSION}/hurl-${HURL_VERSION}-${ARCH}-${OS}.tar.gz"
80+
81+
# Create a temporary directory for the download
82+
TMP_DIR=$(mktemp -d)
83+
cd "$TMP_DIR" || exit
84+
85+
echo "Downloading hurl from $DOWNLOAD_URL"
86+
curl -sSL "$DOWNLOAD_URL" -o "hurl.tar.gz"
87+
88+
# Extract the tarball
89+
echo "Extracting hurl..."
90+
tar -xzf "hurl.tar.gz"
91+
92+
# Find the extracted directory
93+
EXTRACTED_DIR=$(find . -name "hurl-${HURL_VERSION}-*" -type d | head -1)
94+
if [ -z "$EXTRACTED_DIR" ]; then
95+
echo "ERROR: Could not find extracted hurl directory"
96+
exit 1
97+
fi
98+
99+
# Move the binaries to /usr/local/bin (hurl ships hurl and hurlfmt)
100+
echo "Installing hurl..."
101+
mv "${EXTRACTED_DIR}/bin/hurl" /usr/local/bin/
102+
mv "${EXTRACTED_DIR}/bin/hurlfmt" /usr/local/bin/
103+
104+
# Cleanup
105+
cd - || exit
106+
rm -rf "$TMP_DIR"
107+
108+
# Clean up
109+
rm -rf /var/lib/apt/lists/*
110+
111+
# Verify installation
112+
echo "Verifying installation..."
113+
hurl --version
114+
115+
echo "Done!"

test/_global/all-tools.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ check "zoxide" zoxide --version
3030
check "hyperfine" hyperfine --version
3131
check "glow" glow --version
3232
check "fx" fx --version
33+
check "hurl" hurl --version
3334

3435
reportResults
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
source dev-container-features-test-lib
5+
check "hurl with specific version" /bin/bash -c "hurl --version | grep '6.0.0'"
6+
7+
reportResults

test/_global/scenarios.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,7 @@
2323
"ccc": {},
2424
"yazi": {},
2525
"tmux": {},
26-
"fx": {}
27-
}
28-
},
29-
"fx-specific-version": {
30-
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
31-
"features": {
32-
"fx": {
33-
"version": "35.0.0"
34-
}
26+
"hurl": {}
3527
}
3628
},
3729
"flux-specific-version": {
@@ -181,5 +173,13 @@
181173
"features": {
182174
"tmux": {}
183175
}
176+
},
177+
"hurl-specific-version": {
178+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
179+
"features": {
180+
"hurl": {
181+
"version": "6.0.0"
182+
}
183+
}
184184
}
185185
}

test/hurl/test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source dev-container-features-test-lib
6+
check "hurl" hurl --version
7+
reportResults

0 commit comments

Comments
 (0)