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

add kafkacat with apt #1

Merged
merged 1 commit into from
Jan 1, 2025
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
18 changes: 2 additions & 16 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ jobs:
strategy:
matrix:
features:
- color
- hello
- kcat-apt
baseImage:
- debian:latest
- ubuntu:latest
Expand All @@ -34,8 +33,7 @@ jobs:
strategy:
matrix:
features:
- color
- hello
- kcat-apt
steps:
- uses: actions/checkout@v4

Expand All @@ -44,15 +42,3 @@ jobs:

- name: "Generating tests for '${{ matrix.features }}' scenarios"
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated .

test-global:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4

- name: "Install latest devcontainer CLI"
run: npm install -g @devcontainers/cli

- name: "Testing global scenarios"
run: devcontainer features test --global-scenarios-only .
26 changes: 0 additions & 26 deletions src/color/README.md

This file was deleted.

21 changes: 0 additions & 21 deletions src/color/devcontainer-feature.json

This file was deleted.

26 changes: 0 additions & 26 deletions src/color/install.sh

This file was deleted.

26 changes: 0 additions & 26 deletions src/hello/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions src/hello/devcontainer-feature.json

This file was deleted.

29 changes: 0 additions & 29 deletions src/hello/install.sh

This file was deleted.

43 changes: 43 additions & 0 deletions src/kcat-apt/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# kcat (formerly kafkacat)

A command-line utility for Apache Kafka that provides functionality for producing and consuming messages, as well as various metadata operations. This feature installs kcat using the apt package manager on Debian/Ubuntu-based systems.

## Version Support

By default, this feature installs the latest version available in the distribution's repository. You can specify a particular version using the `version` option in your devcontainer.json:

```jsonc
{
"features": {
"ghcr.io/irfanputra/devcontainer-features/kcat-apt:1": {
"version": "1.7.0-1" // Use specific version
// or
"version": "latest" // Use latest version (default)
}
}
}
```

To check available versions in your base image:
```bash
apt-cache policy kafkacat
```

## Usage Examples

After installation, you can use either `kcat` or `kafkacat` command (they are symlinked):

```bash
# Consume messages
kcat -b localhost:9092 -t my-topic

# Produce messages
echo "Hello Kafka" | kcat -b localhost:9092 -t my-topic -P

# List topics
kcat -b localhost:9092 -L
```

## Note

This feature only supports Debian/Ubuntu-based containers as it uses the apt package manager.
16 changes: 16 additions & 0 deletions src/kcat-apt/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "kcat",
"id": "kcat-apt",
"version": "1.0.0",
"description": "A Kafka command line utility using kcat (formerly kafkacat). Only supports Debian/Ubuntu.",
"options": {
"version": {
"type": "string",
"default": "latest",
"description": "Select version of kcat (kafkacat) to install. Use distribution version format (e.g., '1.7.0-1'). Defaults to latest version."
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
}
33 changes: 33 additions & 0 deletions src/kcat-apt/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
set -e

# Check for apt-get
if ! type apt-get >/dev/null 2>&1; then
echo "ERROR: apt-get not found. This feature is only supported on Debian/Ubuntu-based systems."
exit 1
fi

# Function to check and install packages
check_package_and_install() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt-get update -y
apt-get -y install --no-install-recommends "$@"
fi
}

# Install kafkacat and create kcat symlink
if [ "${VERSION}" != "latest" ]; then
echo "Installing kafkacat version ${VERSION}..."
check_package_and_install kafkacat="${VERSION}"
else
echo "Installing latest version of kafkacat..."
check_package_and_install kafkacat
fi

# Create symlink from kafkacat to kcat for consistency
if [ ! -e "/usr/bin/kcat" ] && [ -e "/usr/bin/kafkacat" ]; then
ln -s /usr/bin/kafkacat /usr/bin/kcat
fi

# Clean up apt cache
rm -rf /var/lib/apt/lists/*
33 changes: 0 additions & 33 deletions test/_global/color_and_hello.sh

This file was deleted.

13 changes: 0 additions & 13 deletions test/_global/scenarios.json

This file was deleted.

17 changes: 0 additions & 17 deletions test/color/gold.sh

This file was deleted.

17 changes: 0 additions & 17 deletions test/color/green.sh

This file was deleted.

Loading
Loading