Skip to content

Commit de81c7d

Browse files
committed
Modified install script to use venv setup
1 parent 842336c commit de81c7d

File tree

7 files changed

+34
-95
lines changed

7 files changed

+34
-95
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
max-line-length = 100
2+
max-line-length = 120
33
exclude =
44
.tox,
55
.git,

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ repos:
1414
hooks:
1515
- id: black
1616
language_version: python3
17+
args: ["--line-length", "120"]
1718

1819
- repo: https://github.com/pycqa/isort
1920
rev: 5.13.2

helm_values_manager/cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
app = typer.Typer(
66
name="values-manager",
77
help="A Helm plugin to manage values and secrets across environments.",
8-
add_completion=False,
8+
add_completion=True,
99
)
1010

1111

@@ -24,15 +24,16 @@ def main(ctx: typer.Context):
2424

2525
@app.command()
2626
def init(
27+
release_name: str = typer.Option(..., "--release", "-r", help="Name of the Helm release"),
2728
config_file: str = typer.Option(
2829
"values-manager.yaml",
2930
"--config",
3031
"-c",
3132
help="Path to the values manager configuration file",
32-
)
33+
),
3334
):
3435
"""Initialize a new values manager configuration."""
35-
typer.echo(f"Initializing values manager with config file: {config_file}")
36+
typer.echo(f"Initializing values manager with config file: {config_file}, for the release: {release_name}.")
3637
# TODO: Implement initialization logic
3738

3839

plugin.yaml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
name: "values-manager"
2-
version: "0.1-rc1"
2+
version: "0.1.0rc1"
33
usage: "Manage Helm values and secrets across environments"
44
description: |-
55
This plugin helps you manage Helm values and secrets across different environments
66
while supporting multiple secret backends like AWS Secrets Manager, Azure Key Vault,
77
and HashiCorp Vault.
8-
platformCommand:
9-
- os: linux
10-
arch: amd64
11-
command: "$HELM_PLUGIN_DIR/bin/wrapper.sh"
12-
- os: darwin
13-
arch: amd64
14-
command: "$HELM_PLUGIN_DIR/bin/wrapper.sh"
15-
- os: darwin
16-
arch: arm64
17-
command: "$HELM_PLUGIN_DIR/bin/wrapper.sh"
18-
- os: windows
19-
arch: amd64
20-
command: "$HELM_PLUGIN_DIR/bin/wrapper.bat"
8+
command: "$HELM_PLUGIN_DIR/venv/bin/python3 $HELM_PLUGIN_DIR/helm_values_manager/cli.py"
219
hooks:
2210
install: "$HELM_PLUGIN_DIR/scripts/install.sh"
2311
update: "$HELM_PLUGIN_DIR/scripts/update.sh"

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "helm-values-manager"
7-
version = "0.1-rc1"
7+
version = "0.1.0rc1"
88
description = "A Helm plugin to manage values and secrets across environments"
99
readme = "README.md"
1010
requires-python = ">=3.8"
@@ -39,22 +39,22 @@ dev = [
3939
]
4040

4141
[tool.black]
42-
line-length = 100
42+
line-length = 120
4343
target-version = ['py38']
4444
include = '\.pyi?$'
4545

4646
[tool.isort]
4747
profile = "black"
4848
multi_line_output = 3
49-
line_length = 100
49+
line_length = 120
5050

5151
[tool.pytest.ini_options]
5252
testpaths = ["tests"]
5353
python_files = ["test_*.py"]
5454
addopts = "--cov=helm_values_manager --cov-report=xml --cov-report=term-missing"
5555

5656
[tool.flake8]
57-
max-line-length = 100
57+
max-line-length = 120
5858
exclude = [
5959
".tox",
6060
".git",

scripts/install.sh

Lines changed: 19 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,30 @@
11
#!/bin/bash
2+
set -e
23

3-
# Check if Python 3.8 or higher is available
4-
python_version=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
5-
required_version="3.8"
6-
7-
if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" = "$required_version" ]; then
8-
# Python version is >= 3.8, proceed with installation
9-
python3 -m pip install -e .
10-
else
11-
echo "Error: Python 3.8 or higher is required (found $python_version)"
12-
exit 1
13-
fi
14-
15-
mkdir -p $HELM_PLUGIN_DIR/bin
16-
17-
# Create Python script with error handling
18-
cat > $HELM_PLUGIN_DIR/bin/helm_values_manager.py << 'EOF'
19-
#!/usr/bin/env python3
20-
import sys
21-
import os
22-
23-
try:
24-
sys.path.insert(0, os.path.join(os.environ["HELM_PLUGIN_DIR"], "lib"))
25-
from helm_values_manager import helm_values_manager
26-
except ImportError as e:
27-
print(f"Error: Failed to import helm_values_manager: {e}", file=sys.stderr)
28-
print("This might be due to missing dependencies or incorrect installation.", file=sys.stderr)
29-
sys.exit(1)
30-
except Exception as e:
31-
print(f"Error: {e}", file=sys.stderr)
32-
sys.exit(1)
33-
34-
if __name__ == '__main__':
35-
sys.exit(helm_values_manager())
36-
EOF
37-
38-
# Create wrapper script with error handling
39-
cat > $HELM_PLUGIN_DIR/bin/wrapper.sh << 'EOF'
40-
#!/bin/sh
41-
42-
# Ensure HELM_PLUGIN_DIR is set
43-
if [ -z "$HELM_PLUGIN_DIR" ]; then
44-
echo "Error: HELM_PLUGIN_DIR environment variable is not set"
4+
# Check if Python 3.7+ is available
5+
if ! command -v python3 &> /dev/null; then
6+
echo "Error: Python 3 is required but not found"
457
exit 1
468
fi
479

48-
# Ensure the Python script exists
49-
if [ ! -f "$HELM_PLUGIN_DIR/bin/helm_values_manager.py" ]; then
50-
echo "Error: helm_values_manager.py not found"
10+
PYTHON_VERSION=$(python3 -c 'import sys; print(sys.version_info[0] * 10 + sys.version_info[1])')
11+
if [ "$PYTHON_VERSION" -lt 37 ]; then
12+
echo "Error: Python 3.7 or higher is required (found $PYTHON_VERSION)"
5113
exit 1
5214
fi
5315

54-
# Run the Python script with proper error handling
55-
python3 "$HELM_PLUGIN_DIR/bin/helm_values_manager.py" "$@"
56-
EOF
57-
58-
# Create Windows wrapper script
59-
cat > $HELM_PLUGIN_DIR/bin/wrapper.bat << 'EOF'
60-
@echo off
61-
setlocal
62-
63-
if "%HELM_PLUGIN_DIR%"=="" (
64-
echo Error: HELM_PLUGIN_DIR environment variable is not set
65-
exit /b 1
66-
)
67-
68-
if not exist "%HELM_PLUGIN_DIR%\bin\helm_values_manager.py" (
69-
echo Error: helm_values_manager.py not found
70-
exit /b 1
71-
)
72-
73-
python "%HELM_PLUGIN_DIR%\bin\helm_values_manager.py" %*
74-
EOF
16+
# Create virtual environment if it doesn't exist
17+
if [ ! -d "$HELM_PLUGIN_DIR/venv" ]; then
18+
echo "Creating virtual environment..."
19+
python3 -m venv "$HELM_PLUGIN_DIR/venv"
20+
fi
7521

76-
chmod +x $HELM_PLUGIN_DIR/bin/helm_values_manager.py
77-
chmod +x $HELM_PLUGIN_DIR/bin/wrapper.sh
22+
# Upgrade pip and install package
23+
echo "Installing dependencies..."
24+
"$HELM_PLUGIN_DIR/venv/bin/pip" install --upgrade pip
25+
"$HELM_PLUGIN_DIR/venv/bin/pip" install -e . || {
26+
echo "Error: Failed to install package dependencies"
27+
exit 1
28+
}
7829

7930
echo "helm-values-manager plugin installed successfully"

scripts/update.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
2+
set -e
23

3-
# Update the plugin using pip
4-
pip install --target $HELM_PLUGIN_DIR/lib --upgrade .
5-
6-
# Re-run the install script to ensure all files are properly set up
7-
$HELM_PLUGIN_DIR/scripts/install.sh
4+
# Run the install script to update the binary
5+
"$HELM_PLUGIN_DIR/scripts/install.sh"

0 commit comments

Comments
 (0)