feat(script): add kubeconfig utilities and enhance branch-specific env handling
- Added new scripts for loading and saving kubeconfig from Keepass and Pass - Introduced log-error and log-success utilities for consistent logging - Enhanced init-venv to create branch-specific virtual environments - Added pattern for loading branch-specific .env files based on current git branch - Improved error messages with proper quoting and formatting - Updated patterns.md to document branch-specific environment handling
This commit is contained in:
2 files changed
+63
-41
No files matched your search
@@ -5,44 +5,51 @@ repository=https://taskfile.build
|
||||
|
||||
# ls -1 bin | sed '/install/d'
|
||||
scripts=(
|
||||
activate-venv
|
||||
backup-env-files
|
||||
build-image
|
||||
clean-git-folder
|
||||
commit-git-folder
|
||||
commit-with-llm
|
||||
copy-env
|
||||
create-env
|
||||
create-symlink
|
||||
create-symlink-files
|
||||
edit-env
|
||||
ensure-directory
|
||||
get-pass-from-keepass
|
||||
init-dotenv-dir
|
||||
list-env
|
||||
load-dotenv-from-keepass
|
||||
load-dotenv-from-pass
|
||||
load-env
|
||||
login-docker
|
||||
log-warning
|
||||
ls-git-folder
|
||||
open-url-with-delay
|
||||
open-with-os
|
||||
push-git-folder
|
||||
remove-env
|
||||
remove-venv
|
||||
rename-env
|
||||
reset-git-folder
|
||||
restore-env-files
|
||||
save-dotenv-to-keepass
|
||||
save-dotenv-to-pass
|
||||
save-pass-to-keepass
|
||||
show-env
|
||||
stage-git-folder
|
||||
status-git-folder
|
||||
template-dotenv
|
||||
update-submodule
|
||||
update-with-llm
|
||||
activate-venv
|
||||
backup-env-files
|
||||
build-image
|
||||
clean-git-folder
|
||||
commit-git-folder
|
||||
commit-with-llm
|
||||
copy-env
|
||||
create-env
|
||||
create-symlink
|
||||
create-symlink-files
|
||||
edit-env
|
||||
ensure-directory
|
||||
get-pass-from-keepass
|
||||
init-dotenv-dir
|
||||
list-env
|
||||
load-dotenv-from-keepass
|
||||
load-dotenv-from-pass
|
||||
load-env
|
||||
load-kubeconfig-from-keepass
|
||||
load-kubeconfig-from-pass
|
||||
log-error
|
||||
login-docker
|
||||
log-success
|
||||
log-warning
|
||||
ls-git-folder
|
||||
open-url-with-delay
|
||||
open-with-os
|
||||
push-git-folder
|
||||
remove-env
|
||||
remove-venv
|
||||
rename-env
|
||||
reset-git-folder
|
||||
restore-env-files
|
||||
save-dotenv-to-keepass
|
||||
save-dotenv-to-pass
|
||||
save-kubeconfig-to-keepass
|
||||
save-kubeconfig-to-pass
|
||||
save-pass-to-keepass
|
||||
show-dotenv
|
||||
show-env
|
||||
stage-git-folder
|
||||
status-git-folder
|
||||
template-dotenv
|
||||
update-submodule
|
||||
update-with-llm
|
||||
)
|
||||
|
||||
install_dir='/usr/local/bin'
|
||||
|
||||
+18
-3
@@ -84,12 +84,14 @@ template-with-env() {
|
||||
}
|
||||
```
|
||||
|
||||
## Create Python virtual env
|
||||
## Create Python virtual env for git branch
|
||||
|
||||
Initialize Python virtual env with uv.
|
||||
|
||||
```bash
|
||||
init-venv() {
|
||||
GIT_BRANCH=$(git symbolic-ref --short -q HEAD)
|
||||
|
||||
if [[ ! -d ".venv$GIT_BRANCH" ]]; then
|
||||
echo "Init .venv$GIT_BRANCH with $(uv --version)."
|
||||
uv venv ".venv$GIT_BRANCH"
|
||||
@@ -287,14 +289,27 @@ process-data() {
|
||||
|
||||
Add the following statements to check if the required commands is available:
|
||||
|
||||
```python
|
||||
```bash
|
||||
if ! (command -v grep &> /dev/null && grep --version | grep -q GNU) && [[ "$OS_RELEASE" =~ ^(Darwin)$ ]]; then
|
||||
echo 'Error: On Darwin systems, GNU grep must be installed.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v envsubst &> /dev/null; then
|
||||
echo 'Error: '\''envsubst'\'' is not available. Install '\''gettext'\'' package.'
|
||||
echo "Error: 'envsubst' is not available. Install 'gettext' package."
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
## Load dotenv by git branch
|
||||
|
||||
If you want to have a `.env.<branch>` file for each git branch use this pattern:
|
||||
|
||||
```bash
|
||||
if [[ -d ".git" ]]; then
|
||||
GIT_BRANCH=$(git symbolic-ref --short -q HEAD)
|
||||
if [[ -a ".env.$GIT_BRANCH" ]]; then
|
||||
export $(cat ".env.$GIT_BRANCH" | sed 's/^#.*//g' | xargs)
|
||||
fi
|
||||
fi
|
||||
```
|
||||
Reference in new issue
Block a user