Giter VIP home page Giter VIP logo

aliases's People

Contributors

fossabot avatar k-kinzal avatar mumoshu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aliases's Issues

Error occurs when `tty` is enabled

Enabling tty occurs error in some cases.

Case1

alises.yaml

/usr/local/bin/alpine:
  image: alpine
  tag: 3.8
  tty: true
$ echo "foo" | alpine sh -c "cat -"
the input device is not a TTY

Case 2

aliases.yaml

/usr/local/bin/helm:
  image: chatwork/helm
  tag: 2.11.0
  volume:
  - /tmp:/tmp
  - $HOME/.kube:/root/.kube
  - $HOME/.helm:/root/.helm
  - $PWD:/helm
  - $PWD:/helmfile
  workdir: /helm

/usr/local/bin/helmfile:
  image: chatwork/helmfile
  tag: 0.40.1-2.10.0-1.11.3
  volume:
  - /tmp:/tmp
  - $HOME/.helm:/root/.helm
  - $PWD:/helmfile
  workdir: /helmfile
  dependencies:
  - /usr/local/bin/helm

We need a tty when using helm secret edit with helm.
However, to execute helm from helmfile we need to turn off tty.

feat: Automatic mounting of environment variables

Derived from #17.

Proposal

/usr/local/bin/kubectl:
  image: chatwork/kubectl
  tag: 1.11.2
  experimental: true
  env:
    KUBECONFIG: $KUBECONFIG
  volume:
  - $HOME/.kube:/root/.kube
  - $PWD:/kube
  workdir: /kube
$ KUBECONFIG=$HOME/.kube2/config:$HOME/.kube/config kubectl get all

We propose to mount the path automatically if the environment variable specified in env is in PATH format (colon delimited).

However, this is complicated.
Therefore we want to work only when experimental flag is enabled.
If it stabilizes, remove the flag of experimental to make it the default behavior.

feat: Supports extend of entrypoint

We may need helm plugins when using helm.
It is very troublesome to recreate containers.

So we need a way to install A with entrypoint.

proposal

aliases.yaml

/usr/local/bin/helm
  image: chatwork/helm
  tag: 2.11.0
  volumes:
  - $HOME/.kube:/root/.kube
  - $HOME/.helm:/root/.helm
  - $PWD:/helm
  workdir: /helm
  entrypoint: |
    #!/bin/sh
    if [ -f $(helm home)/plugins/helm-import ]; then
      helm plugin install https://github.com/k-kinzal/helm-import
    if
    helm "$@"
  dependencies:
  - /bin/bash
  - /bin/git

script

$ docker run ... -v $HOME/.aliases/entrypoints/xxx:/xxx --entrypoint /xxx chatwork/helm:${HELM_VERSION:-2.11.0}

We think that we should be able to extend entrypoint like this.

Detect problems when typo with YAML.

I typo.

/usr/local/bin/jq:
  image: chatwork/jq
  tag: 1.5-r5
  volumes:
  - $PWD:/jq
  workdir: /jq

volume rather than volumes is correct.
We do not want to use time for this, so I want to make an undefined key an error.

feat: Remove empty environment variable

awscli does not work if there is an empty environment variable.

  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY:
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_REGION

Therefore, empty environment variables should be removed.

However, we must consider cases where you want to use empty environment variables.
For example, when enclosed in double quotes, it is necessary to propose a workaround such as using an empty environment variable.

Execution of the command does not end.

aliases.yaml

/usr/local/bin/kubectl:
  image: chatwork/kubectl
  tag: 1.11.2
  volume:
  - $HOME/.kube:/root/.kube
  - $PWD:/kube
  workdir: /kube

/usr/local/bin/alpine:
  image: alpine
  tag: 3.8
  dependencies:
  - /usr/local/bin/kubectl
$ kubectl version -c
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

It works when kubectl is executed

$ alpine kubect version -c
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

But execute alpine through kubect does not end the command.
In order to solve this problem alpine needs to be tty: true.

How to solve symbolic links.

Installing helm plugin locally creates a symbolic link.

$ ls -la ~/.helm/plugins/helm-github.git 
lrwxrwxrwx  1 k-kinzal staff  71 Dec  5 12:49 /Users/k-kinzal/.helm/plugins/helm-github.git -> /root/.helm/cache/plugins/https-github.com-sagansystems-helm-github.git

If aliases mounts this ~/.helm directory it will not work.

feat: Automatically enable aliases

We want to enable aliases automatically when move to a directory with aliases.yaml like direnv.

We are using different versions of commands in multiple projects.
In this case it is impossible to manage all commands with $HOME/.aliases/aliases.yaml.
It is preferable to define different aliases.yaml for PROJ1/aliases.yaml and PROJ2/aliases.yaml respectively.

$ eval $(aliases hook zsh)

It is wonderful to make such a command.

feat: If there is a symbolic link in the mounted directory, a warning is displayed.

Derived from #17.

Proposal

/usr/local/bin/helm:
  image: chatwork/helm
  tag: 2.11.0
  volume:
  - $HOME/.kube:/root/.kube
  - $HOME/.helm:/root/.helm
  - $PWD:/helm
  workdir: /helm
$ aliases gen
WARNGING: /Users/k-kinzal/.helm/plugins/helm-secrets -> /root/.helm/cache/plugins/https-github.com-futuresimple-helm-secrets: not mounting this symbolic link destination

We propose to display warnings for symbolic links.
If a symbolic link exists and the link destination is not mounted, a warning is displayed.

feat: Command definition for dependency

When using the bash command with helm-secrets, defining the command will taint the host's bash.

/bin/sops:
  image: mozilla/sops
  tag: 8fcd61e8a3d1709ae37d7ae55d49cfe6b8aeda8b
  entrypoint: /bin/sops
  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
    SOPS_KMS_ARN: $SOPS_KMS_ARN
  volume:
  - $HOME/.aws:/root/.aws
  - $PWD:/sops
  - $PWD:/helm
  - $PWD:/helmfile
  workdir: /sops

/bin/bash:
  image: bash
  tag: 4.4.23
  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
    SOPS_KMS_ARN: $SOPS_KMS_ARN
  volume:
  - /tmp:/tmp
  - $HOME/.helm:/root/.helm
  - $PWD:/bash
  - $PWD:/helm
  - $PWD:/helmfile
  workdir: /bash
  dependencies:
  - /bin/sops
  - /usr/local/bin/helm

/usr/local/bin/helm:
  image: chatwork/helm
  tag: 2.11.0
  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
    SOPS_KMS_ARN: $SOPS_KMS_ARN
  volume:
  - /tmp:/tmp
  - $HOME/.kube:/root/.kube
  - $HOME/.helm:/root/.helm
  - $PWD:/helm
  - $PWD:/helmfile
  workdir: /helm
  dependencies:
  - /bin/bash

proposal

/bin/sops:
  image: mozilla/sops
  tag: 8fcd61e8a3d1709ae37d7ae55d49cfe6b8aeda8b
  entrypoint: /bin/sops
  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
    SOPS_KMS_ARN: $SOPS_KMS_ARN
  volume:
  - $HOME/.aws:/root/.aws
  - $PWD:/sops
  - $PWD:/helm
  - $PWD:/helmfile
  workdir: /sops

/usr/local/bin/helm:
  image: chatwork/helm
  tag: 2.11.0
  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
    SOPS_KMS_ARN: $SOPS_KMS_ARN
  volume:
  - /tmp:/tmp
  - $HOME/.kube:/root/.kube
  - $HOME/.helm:/root/.helm
  - $PWD:/helm
  - $PWD:/helmfile
  workdir: /helm
  dependencies:
  - /bin/bash:
    image: bash
    tag: 4.4.23
    env:
      AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
      AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
      AWS_PROFILE: $AWS_PROFILE
      AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
      SOPS_KMS_ARN: $SOPS_KMS_ARN
    volume:
    - /tmp:/tmp
    - $HOME/.helm:/root/.helm
    - $PWD:/bash
    - $PWD:/helm
    - $PWD:/helmfile
    workdir: /bash
    dependencies:
    - /bin/sops
    - /usr/local/bin/helm
$ eval $(aliases gen --export)
$ which bash
/bin/bash

So we want to be able to define commands for dependency.

feat: Conditional automount at execution

I had a problem.

/usr/local/bin/kubectl:
  image: chatwork/kubectl
  tag: 1.11.2
  env:
    KUBECONFIG: $KUBECONFIG
  volume:
  - $HOME/.kube:/root/.kube
  - $PWD:/kube
  workdir: /kube
$ KUBECONFIG=$HOME/Downloads/kube-config.cfg kubectl config view --flatten

it does not work because it is not mounted $HOME/Downloads/kube-config.cfg.

it possible to solve this problem if it can be automatically mounted under conditions at execution.

feat: `aliases lint` command.

If linting YAML with aliases lint, it will be easier to debug.

  1. format of YAML is valid
  2. Each value of YAML is valid
    • required value
    • pass to docker run

feat: Automatic argument mounting

Derived from #17.

Proposal

/bin/curl:
  image: tutum/curl
  tag: alpine
  experimental: true
  entrypoint: curl
$ curl ... -O $HOME/Downloads
$ cat $HOME/Downloads/[your download file]

We propose mounting the path specified by the argument.

  • host: Always mount if the argument contains a path
  • guest: If mounted on guest mount it. Otherwise, a warning is displayed.

However, this is complicated.
Therefore we want to work only when experimental flag is enabled.
If it stabilizes, remove the flag of experimental to make it the default behavior.

feat: Inherit dependent parameters

There is a problem that YAML becomes long when using helm secrets.

/bin/sops:
  image: mozilla/sops
  tag: 8fcd61e8a3d1709ae37d7ae55d49cfe6b8aeda8b
  entrypoint: /bin/sops
  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
    SOPS_KMS_ARN: $SOPS_KMS_ARN
  volume:
  - $HOME/.aws:/root/.aws
  - $PWD:/sops
  workdir: /sops

/bin/bash:
  image: bash
  tag: 4.4.23
  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
    SOPS_KMS_ARN: $SOPS_KMS_ARN
  workdir: /bash
  dependencies:
  - /bin/sops

/usr/local/bin/helm:
  image: chatwork/helm
  tag: 2.11.0
  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
    SOPS_KMS_ARN: $SOPS_KMS_ARN
  volume:
  - $HOME/.kube:/root/.kube
  - $HOME/.helm:/root/.helm
  - $PWD:/helm
  workdir: /helm
  dependencies:
  - /bin/bash

In this way we need to inherit the environment variable.
This not very readable.

proposal

/bin/sops:
  image: mozilla/sops
  tag: 8fcd61e8a3d1709ae37d7ae55d49cfe6b8aeda8b
  entrypoint: /bin/sops
  env:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_PROFILE: $AWS_PROFILE
    AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
    SOPS_KMS_ARN: $SOPS_KMS_ARN
  volume:
  - $HOME/.aws:/root/.aws
  - $PWD:/sops
  workdir: /sops

/bin/bash:
  image: bash
  tag: 4.4.23
  workdir: /bash
  dependencies:
  - /bin/sops

/usr/local/bin/helm:
  image: chatwork/helm
  tag: 2.11.0
  volume:
  - $HOME/.kube:/root/.kube
  - $HOME/.helm:/root/.helm
  - $PWD:/helm
  workdir: /helm
  dependencies:
  - /bin/bash
$ SOPS_KMS_ARN=xxx AWS_PROFILE=[your procile] helm secrets enc secrets.yaml

I would like to readability by inheriting the dependency parameters.

It does not work when `tcp://` is used with `DOCKER_HOST`

aliases works only on host.
However, if we use tcp: // for DOCKER_HOST, the host will be in a different environment.

This is a problem that aliases can not solve.
We should only support DOCKER_HOST with unix:// before releasing v0.1.0.

feat: Automatic download of docker binary

An error occurs when sharing docker container and docker binary on Ubuntu.

https://twitter.com/amaya382/status/1077874567119396864
https://amaya382.hatenablog.jp/entry/2016/10/05/030254

It is necessary to solve this problem in order to operate on CircleCI as a use case.

proposal

/bin/sh:
  docker:
    image: docker
    tag: 18.09.0
  image: alpine
  tag 3.8
  command: /bin/sh
  privileged: true
  volumes:
  - /var/run/docker.sock:/var/run/docker.sock
if [ ! -f $ALIASES_HOME/docker/docker-18.09.0 ]; then
  docker run -v $ALIASES_HOME/docker:/data --name docker-18-09-0 docker:18.09.0 /bin/sh -c 'cp $(which docker) /data/docker-18.09.0'
fi
docker run --interactive --privileged --rm --volume $ALIASES_HOME/docker/docker-18.09.0:/usr/local/bin/docker --volume /var/run/docker.sock:/var/run/docker.sock alpine:${SH_VERSION:-"3.8"} /bin/sh "$@"

We propose to download docker binary via docker image.

It is preferable that the downloading timing be executed when aliases is running.

feat: `aliases run` command.

aliases is hard to debug when it does not work.

  1. which [aliases generate cmd]
  2. cat [aliases binary]
  3. docker run --entrypoint '' -it ... /bin/sh
  4. debug!!!

Therefore, I want to be able to debug with aliases run.

$ aliases run --entrypointy '' -it [cmd name] /bin/sh

aliases run should be able to override all docker run options.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.