{"id":16777383,"url":"https://github.com/otakup0pe/hcvswitch","last_synced_at":"2025-03-22T00:31:06.650Z","repository":{"id":141875712,"uuid":"61071015","full_name":"otakup0pe/hcvswitch","owner":"otakup0pe","description":"Vault environment manager","archived":false,"fork":false,"pushed_at":"2024-05-08T20:21:09.000Z","size":23,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"mainline","last_synced_at":"2024-10-14T07:24:36.786Z","etag":null,"topics":["shell","vault"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/otakup0pe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-13T21:29:40.000Z","updated_at":"2024-05-08T20:21:13.000Z","dependencies_parsed_at":"2024-02-02T00:50:22.566Z","dependency_job_id":null,"html_url":"https://github.com/otakup0pe/hcvswitch","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otakup0pe%2Fhcvswitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otakup0pe%2Fhcvswitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otakup0pe%2Fhcvswitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otakup0pe%2Fhcvswitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otakup0pe","download_url":"https://codeload.github.com/otakup0pe/hcvswitch/tar.gz/refs/heads/mainline","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221820672,"owners_count":16886222,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["shell","vault"],"created_at":"2024-10-13T07:24:33.515Z","updated_at":"2024-10-28T11:18:34.021Z","avatar_url":"https://github.com/otakup0pe.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Maintenance](https://img.shields.io/maintenance/yes/2024.svg)\n\nHCV Switcher\n============\n\nThese scripts provide a simple way of switching between different instances of Hashicorp Vault. Once integrated into someone's Bash dotfiles setup, it should keep some environment variables up to date. A key assumption made by this script is that the shell environment it is installed in has a function similar to `PS1_COMMAND` which runs each time the shell is generated. As the `VAULT_ADDR` is not stored in any files, this environment variable must be kept up to date.\n\nInstallation\n------------\n\nClone this repository somewhere comfortable on your workstation. There are two environment variables which configure the scripts. Define these as you wish and then source the `init.sh` script in your `.profile`.\n\n* `HCVSWITCH_PATH` points to the location you cloned this repository\n* `HCVSWITCH_CONFIG` points to a yaml file containing your [Vault configuration](https://github.com/otakup0pe/hcvswitch#vault-configuration). This is optional and defaults to `~/.hcv.yml`.\n\n#### `.profile Example`\n```\nexport HCVSWITCH_PATH=\"${HOME}/src/hcvswitch\"\nexport HCVSWITCH_CONFIG=\"${HOME}/.hcv.yml\"\n. \"${HCVSWITCH_PATH}/init.sh\"\n```\n\nThere is an additional component that must be eval'd in the `PS1_COMMAND` context. This ensures that the Vault configuration is transparently known across terminals. Along with the various Vault environment variables, the `HCV_ENV` environment variable will be set to the name of the current Vault account. You can then use this to include the Vault environment in your `PS1` variable.\n\n#### eval Example\n\n```\neval $(\"${HCVSWITCH_PATH}/hcvswitch.sh\" eval)\n```\n\nVault Configuration\n-------------------\n\nThe Vault configuration is stored in a simple yaml file. It is a list of config entries prefixed by a comment with the name of the Vault environment. The comment is the name referenced when switching Vault accounts. Note that only `id` and `url` are required. The values of `ignore_ssl` and `sni` have sensible defaults. You can also specify some authenticaiton hints with `auth_user` and `auth_method`.\n\n```\n#my-vault\n- id: my-vault\n  url: http://vault.example.com/\n  ignore_ssl: false\n  sni: vault.example.com\n  auth_user: nobody\n  auth_method: userpass\n```\n\nScript Actions\n--------------\n\nThe inclusion of the `init.sh` script will keep some Vault related environment variables updated.\n\n* `VAULT_ADDR` Will be set to the current `url` for the active Vault environment.\n* `VAULT_SKIP_ADDR` Will be set to `0` or `1` depending on the `true`/`false` setting of the `ignore_ssl` for the active Vault environment.\n* `VAULT_TLS_SERVER_NAME` will be set to either the value of the `sni` setting, or the hostname portion of the `VAULT_ADDR`.\n* `HCV_ENV` will be set to the name of the current hcvswitch profile.\n\nUsage\n-----\n\nOnce you have initialized the script in your `.profile` usage is straight forward. Simply make use of the `hcvswitch` function and reference one of the Vault instances in your YAML configuration. This will cause your current terminal context to be re-initialized. Note that other terminals will _not_ be re-initialized until the next time the `PS1_COMMAND` context is evaluated. You can also use the `hcvlist` function to display the different Vault instances.\n\n```\n$ hcvlist\ntest1\ntest2\n$ hcvswitch test1\n$ echo $VAULT_ADDR\nhttp://localhost:8200\n$ hcvswitch test2\n$ echo $VAULT_ADDR\nhttp://localhost:8201\n```\n\nThere is also a simple Vault authentication helper for the LDAP and userpass backends. This will associate a auth method and username with a profile. If you have set both `auth_user` and `auth_method` for a profile, the `hcvauth` command will initiate a `vault auth` request.\n\nLicense\n-----\n\n[MIT](https://github.com/otakup0pe/hcvswitch/blob/master/LICENSE)\n\nAuthor\n-----\nThe hcvswitch tool was created by [Jonathan Freedman](http://jonathanfreedman.bio/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotakup0pe%2Fhcvswitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotakup0pe%2Fhcvswitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotakup0pe%2Fhcvswitch/lists"}