Skip to content

Commit

Permalink
Feature: Live updates (#28)
Browse files Browse the repository at this point in the history
* chore: Deletes a couple of messages

* fix: Better way to manage aliases with homebrew

* feat: Adds support for the QCExperimental account

* fix: The terraform plan function allowing to pass more parameters

* chore: Updates pre-commit

---------

Co-authored-by: JJ <[email protected]>
  • Loading branch information
jjuarez and JJ authored Oct 9, 2024
1 parent 1458089 commit 27974d4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
32 changes: 23 additions & 9 deletions roles/dotfiles/files/shell/rc/.aliasesrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@ HOMEBREW_PREFIX=${HOMEBREW_PREFIX:-"$(brew --prefix 2>/dev/null)"}
OS="$(uname)"


utils::check_homebrew() {
command -v brew 2>&1 >/dev/null &&
test -n "${HOMEBREW_PREFIX} &&
test -d "${HOMEBREW_PREFIX}
}


# Tools
alias tree='tree -a -I .git'
[[ $(command -v bat 2>/dev/null) ]] && alias cat='bat'

# path traversal
alias ..='cd ..'
alias ...='cd ../..'

# Check if we have home brew installed
if [[ -z "${HOMEBREW_PREFIX}" ]]; then
if utils::check_homebrew; then
case "${OS}" in
Darwin*)
alias netstat='netstat -an -p tcp -f inet'

# GNU tools
[[ -x "${HOMEBREW_PREFIX}/bin/gtar" ]] && alias tar="${HOMEBREW_PREFIX}/bin/gtar"
[[ -x "${HOMEBREW_PREFIX}/bin/gfind" ]] && alias find="${HOMEBREW_PREFIX}/bin/gfind"
[[ -x "${HOMEBREW_PREFIX}/bin/gsed" ]] && alias sed="${HOMEBREW_PREFIX}/bin/gsed"
[[ -x "${HOMEBREW_PREFIX}/bin/kubecolor" ]] && alias k='kubecolor'
;;
esac

Expand All @@ -23,12 +38,11 @@ if [[ -z "${HOMEBREW_PREFIX}" ]]; then
elif [[ "${HOMEBREW_PREFIX}/bin/vim" ]]; then
alias vi="${HOMEBREW_PREFIX}/bin/vim"
fi
fi

# Commons
[[ $(command -v bat 2>/dev/null) ]] && alias cat='bat'
alias tree='tree -a -I .git'
# kubecolor
alias k='kubectl'

# path traversal
alias ..='cd ..'
alias ...='cd ../..'
if [[ -x "${HOMEBREW_PREFIX}/bin/kubecolor" ]]; then
alias k='kubecolor'
fi
fi
3 changes: 3 additions & 0 deletions roles/dotfiles/files/shell/rc/.featuresrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ features::ibmcloud() {

utils::check_file "${HOME}/.env.IBM.Cloud.QSProduction.apikey" || return 1
source "${HOME}/.env.IBM.Cloud.QSProduction.apikey"

utils::check_file "${HOME}/.env.IBM.Cloud.QCExperimental.apikey" || return 1
source "${HOME}/.env.IBM.Cloud.QCExperimental.apikey"
}

features::krew() {
Expand Down
12 changes: 6 additions & 6 deletions roles/dotfiles/files/shell/rc/.terraform-pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.92.0
hooks:
- id: terraform_fmt
- id: terraform_validate
# - id: terraform_tflint
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.96.1
hooks:
- id: terraform_fmt
- id: terraform_validate
# - id: terraform_tflint
4 changes: 2 additions & 2 deletions roles/dotfiles/files/shell/zsh.d/ibm.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ utils::panic() {
# Configurations
#
[[ -s "${HOME}/.env.IBM.Cloud.account.ids" ]] || utils::panic "Warning: I couldn't load the IBMCloud accound ids from: ${HOME}/.env.IBM.Cloud.account.ids" 1
echo "Loading accounts..." && source "${HOME}/.env.IBM.Cloud.account.ids"
source "${HOME}/.env.IBM.Cloud.account.ids"

[[ -s "${HOME}/.env.IBM.Cloud.clusters" ]] || utils::panic "Warning: I couldn't load the IBMCloud cluster list from: ${HOME}/.env.IBM.Cloud.clusters" 2
echo "Loading clusters..." && source "${HOME}/.env.IBM.Cloud.clusters"
source "${HOME}/.env.IBM.Cloud.clusters"

#
# Tools
Expand Down
4 changes: 3 additions & 1 deletion roles/dotfiles/files/shell/zsh.d/terraform.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ terraform::state::upgrade() {
}

terraform::plan() {
terraform plan --lock=false --out="${PLAN_FILENAME}"
# We need to pass all the command line, for example to allow the alias to work with targets
terraform plan --lock=false --out="${PLAN_FILENAME}" "${@}"
}

terraform::apply() {
Expand All @@ -63,5 +64,6 @@ alias tf='terraform'
alias tfi='terraform::state::init'
alias tfc='terraform::state::cleanup'
alias tfu='terraform::state::upgrade'
alias tfv='terraform validate'
alias tfp='terraform::plan'
alias tfa='terraform::apply'

0 comments on commit 27974d4

Please sign in to comment.