{"id":13795921,"url":"https://github.com/k-kinzal/aliases","last_synced_at":"2025-05-01T07:32:54.703Z","repository":{"id":57613076,"uuid":"155034297","full_name":"k-kinzal/aliases","owner":"k-kinzal","description":" Resolve dependency on all commands by container","archived":false,"fork":false,"pushed_at":"2020-03-05T01:08:37.000Z","size":342,"stargazers_count":12,"open_issues_count":6,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-04T23:10:05.762Z","etag":null,"topics":["container","docker","operations"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k-kinzal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-28T04:12:34.000Z","updated_at":"2022-07-01T01:09:01.000Z","dependencies_parsed_at":"2022-09-26T20:11:09.890Z","dependency_job_id":null,"html_url":"https://github.com/k-kinzal/aliases","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Faliases","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Faliases/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Faliases/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-kinzal%2Faliases/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k-kinzal","download_url":"https://codeload.github.com/k-kinzal/aliases/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224245848,"owners_count":17279649,"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":["container","docker","operations"],"created_at":"2024-08-03T23:01:04.111Z","updated_at":"2024-11-12T09:14:57.227Z","avatar_url":"https://github.com/k-kinzal.png","language":"Go","funding_links":[],"categories":["Command Line and Tooling"],"sub_categories":["Observability"],"readme":"# aliases\n\n[![CircleCI](https://circleci.com/gh/k-kinzal/aliases.svg?style=svg)](https://circleci.com/gh/k-kinzal/aliases)\n[![GolangCI](https://golangci.com/badges/github.com/k-kinzal/aliases.svg)](https://golangci.com/r/github.com/k-kinzal/aliases)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fk-kinzal%2Faliases.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fk-kinzal%2Faliases?ref=badge_shield)\n\n\n`aliases` is a tool for resolving command dependencies with containers.\n\n* YAML-based command definition\n* Version of command with the environment variable\n* Call another dependent command from the command\n\n## Install\n\n```\n$ go get github.com/k-kinzal/aliases\n```\n\n## Get Started\n\n**~/.aliases/aliases.yaml**\n\n```\n/usr/local/bin/kubectl:\n  image: chatwork/kubectl\n  tag: 1.11.2\n  volume:\n  - $HOME/.kube:/root/.kube\n  - $PWD:/kube\n  workdir: /kube\n\n/usr/local/bin/alpine:\n  image: alpine\n  tag: 3.8\n  volume:\n  - $PWD:/work\n  workdir: /work\n  dependencies:\n  - /usr/local/bin/kubectl\n```\n\n```\n$ eval \"$(aliases gen)\"\n```\n\nor \n\n```\n$ eval \"$(aliases gen --export)\"\n```\n\n\nUsing the option of `--export` can be used as a command instead of an alias.\n\n## CLI\n\n```\n$ aliases --help\nNAME:\n   aliases - Generate alias for command on the container\n\nUSAGE:\n   aliases [global options] command [command options] [arguments...]\n\nVERSION:\n   v0.5.1\n\nCOMMANDS:\n     gen      Generate aliases\n     run      Run aliases command\n     home     Get aliases home path\n     help, h  Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n   --config value, -c value  Load configuration file\n   --home value              Home directory for aliases [$ALIASES_HOME]\n   --verbose, -v             enable verbose output\n   --help                    show help\n   --version                 print the version\n```\n\n## Version Environment variable\n\nIf `/usr/local/bin/kubectl` is defined, you can specify the version in the environment variable with `_VERSION` in the suffix with `kubectl` in the file name capitalized.\n\n```\n$ KUBECTL_VERSION=1.11.3 kubectl get all\n```\n\nWhen version environment variable is specified, a command is executed by overwriting `tag` defined by YAML.\n\n\n## Expand Environment Variables\n\n```yaml\nenv:\n  $ENV1: $ENV2\n```\n\n```yaml\nvolume:\n- $ENV1:$ENV2:rw\n```\n\n```yaml\nuser: $ENV1:$ENV2\n```\n\nEnvironmental variables expand with parameters expressed like this.\n`Env1` expands at the timing when `aliases` generates a command.\n`Env2` expands at the timing when you executed a command generated by `aliases`\n\n## Expand commands\n\n```yaml\ntty: $(if tty \u003e/dev/null; then echo \"true\"; else echo \"false\"; fi)\n```\n\n```yaml\nvolume:\n- $(helm home):/root/.helm\n```\n\nWhen you enclose the command with `$(...)`, the `STDOUT` of the command is set as the parameter.\nCommand expanded at the timing when you executed a command generated by `aliases`.\n\nNote: Always execute the generated command on the machine (host or docker) that executed the alias.\n\n## Special Environment Variable\n\n`$PWD` is a special environment variable.\nThe `$PWD` specified on the left always points to `$PWD` of the host.\n\n## Extend entrypoint\n\n```yaml\n/usr/local/bin/helm:\n  image: chatwork/helm\n  tag: 2.12.3\n  volume:\n  - $HOME/.helm:/root/.helm\n  - $PWD:/helm\n  workdir: /helm\n  dependencies:\n  - /bin/bash:\n      image: bash\n      tag: 5.0.2\n  - /bin/curl:\n      image: byrnedo/alpine-curl\n      tag: 0.1.7\n  entrypoint: |\n    #!/bin/sh\n    if [ -f $(helm home)/plugins/helm-import ]; then\n      helm plugin install https://github.com/k-kinzal/helm-import --version v0.2.1\n    if\n    helm \"$@\"\n```\n\nIf you want to extend `entrypoint`, please define a string with shebang in `entrypoint`.\n\nNOTE: Please understand that extend entrypoint is less reproducible. It should be included in the docker image if possible.\n\n## Dependencies commands.\n\n`aliases` can define commands that depend on commands.\n\n```yaml\n/usr/local/bin/sops:\n  image: mozilla/sops\n  tag: a2d0328e35e6e37b51f3ad468dc6f213c7b44014 \n  env:\n    AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}\n    AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}\n    AWS_PROFILE: ${AWS_PROFILE}\n    AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}\n  volume:\n  - $PWD:/sops\n  workdir: /sops\n\n/usr/local/bin/helm:\n  image: chatwork/helm\n  tag: 2.12.3\n  volume:\n  - $HOME/.helm:/root/.helm\n  - $PWD:/helm\n  workdir: /helm\n  dependencies:\n  - /usr/local/bin/sops\n  - /bin/bash:\n      image: bash\n      tag: 5.0.2\n  - /bin/curl:\n      image: byrnedo/alpine-curl\n      tag: 0.1.7\n```\n\nFor dependency, reference to another command defined or define command.\nIf you want to define a command that can only be called from a command, please recursively define the dependency.\n\nAlso, parent commands inherit dependent parameters.\n\n```bash\n$ AWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=xxx helm secrets enc ...\n```\n\nIf the same parameter exists, the parent parameter takes precedence.\n\n## How to debug aliases\n\nIf you do not get what you expected, please use the `aliases run` command.\n\n```bash\n$ aliases run -it --entrypoint '' [command] sh\n```\n\n`aliases run` command overwrites the option of your defined command and executes it.\n\n```bash\n$ aliases --verbose run -it --entrypoint '' [command] sh\ndocker run --entrypoint \"\" --interactive --network \"host\" --rm --tty [your image] sh\n```\n\nIf you want to show the docker run command, please specify the option of `--verbose`.\n\n## for CircleCI\n\n`aliases` supports [CircleCI Orb](https://circleci.com/orbs/registry/orb/k-kinzal/aliases).\nYou can quickly execute precisely the same commands on local and CI.\n\n```yaml\nversion: \"2.1\"\n\norbs:\n  aliases: k-kinzal/aliases@0.2.1\n\njobs:\n  aliases:\n    machine: true\n    steps:\n    - checkout\n    - aliases/install\n    - aliases/gen\n    - run: [your command]\n\nworkflows:\n  version: 2\n\n  aliases:\n    jobs:\n    - aliases\n```\n\nHowever, since A uses privileged and volume, please use [Machine Executor](https://circleci.com/docs/2.0/executor-types/#using-machine).\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fk-kinzal%2Faliases.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fk-kinzal%2Faliases?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-kinzal%2Faliases","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-kinzal%2Faliases","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-kinzal%2Faliases/lists"}