switch-context

command module
v0.0.0-...-53112be Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 7 Imported by: 0

README

Switch-context

Switch-context is a simple CLI tool to switch various environments quickly I made it for myself and plan to add to it as I need to.

I could have probably done this in bash but I didn't feel like it.

Installation

Install Go from the official website

clone this repository and build the executable. Then move it to your bin folder

git clone https://github.com/DaraDadachanji/scontext.git
cd switch-context
go mod tidy
go build
mv ./switch-context /usr/local/bin/switch-context

add the following snippet to your bash profile

function sc() {
    switch-context $1 > /tmp/switchcontext
    source /tmp/switchcontext
}

This allows the environment variable changes to persist in the shell session.

Configuration

create a folder in your home directory named .switchcontext and a file inside named profiles.yaml

for example:

profiles:
  usprod:
    env:
      AWS_PROFILE: default
      AWS_REGION: us-east-1
    kube: us-prod
  ukprod:
    env:
      AWS_PROFILE: ukprod
      AWS_REGION: eu-west-2
    kube: uk-prod

Usage

Call sc and then the name of your profile

sc usprod

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL