Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: No clobber of existing environment variables #402

Open
mjsqu opened this issue Jun 22, 2023 · 4 comments
Open

Feature request: No clobber of existing environment variables #402

mjsqu opened this issue Jun 22, 2023 · 4 comments

Comments

@mjsqu
Copy link

mjsqu commented Jun 22, 2023

When chamber is used to populate environment variables into a Elastic Container Services (ECS) task, you are able to add environment variables to the command using containerOverrides:

{
  "containerOverrides": [
    {
      "name": "string",
      "command": ["chamber","exec","<service>" ...],
      "environment": [
        {
          "name": "CLOBBERED_BY_CHAMBER",
          "value": "oops"
        }
        ...
      ]
    }
    ...
  ],
  "taskRoleArn": "string"
}

However, if you are running a chamber command these environment variables are overwritten if they exist in the service.

It would be good to be able to do:

chamber exec --noclobber <service>

And have chamber not overwrite and environment variables that are already set. An update to the way 'collisions' are handled in the code should achieve this.

To this end, --noclobber sits alongside the existing --pristine and --strict switches and should not be used with them as it works in the opposite way:

  • --strict and --noclobber - Should raise an error, these switches do pretty much the opposite of each other, --strict requiring the variables be set and --noclobber telling chamber not to overwrite them
  • --pristine and --noclobber - Should also error, --noclobber is allowing existing values to come through, --pristine explicitly prevents them from being inherited
@mjsqu
Copy link
Author

mjsqu commented Jun 22, 2023

Looks like this might have been already requested: #87

I have forked and am keen to work on this

@mjsqu
Copy link
Author

mjsqu commented Jun 22, 2023

Working prototype:

https://github.com/mjsqu/chamber/tree/feat/no_clobber

  • Adds --noclobber and helptext
  • Does not include validation against whether --strict and --pristine are set

Open to discussion here before raising a PR

@bhavanki
Copy link
Contributor

I haven't been involved in this project previously beyond keeping the lights on, but would like to respond. (I'm a Segment employee.)

The no-clobber idea makes sense to me, including how it conflicts with --strict and --pristine. If you're still interested in pursuing a PR, go for it. I took a look at the branch and my only big suggestion is refactoring the LoadNoClobber func into load.

@bpottier
Copy link

bpottier commented Aug 6, 2024

Any movement here? This would be really useful for local development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants