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

Support config from files and env vars in addition to flags #49

Closed
drevell opened this issue Jun 22, 2023 · 10 comments
Closed

Support config from files and env vars in addition to flags #49

drevell opened this issue Jun 22, 2023 · 10 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@drevell
Copy link
Contributor

drevell commented Jun 22, 2023

TL;DR

In the original design doc, we decided to allow all options to be provided by flag, config file, or environment variables. Currently we only support flags, so we need to add support for the other methods.

Config file support is needed for #46.

Detailed design

No response

Alternatives considered

No response

Additional information

No response

@drevell drevell added enhancement New feature or request good first issue Good for newcomers labels Jun 22, 2023
@drevell drevell self-assigned this Jul 8, 2023
@drevell
Copy link
Contributor Author

drevell commented Jul 8, 2023

cc @verbanicm , I'm starting work on this

@drevell
Copy link
Contributor Author

drevell commented Jul 19, 2023

After discussing with @sethvargo, we decided to wait to wait to build support for file-based and env-var-based inputs until we have a customer need for this, not counting our own team.

@stytchiz stytchiz self-assigned this Oct 13, 2023
@stytchiz stytchiz pinned this issue Oct 13, 2023
@stytchiz
Copy link
Contributor

stytchiz commented Oct 13, 2023

Discussed with Dave on chat.

Decision: We'll support a config file for exclusively the input variables i.e. -input="foo=bar". abc command will read them on execution.

e.g.

# abc-inputs.yaml
foo: bar
service_account: 'my-service-account-123'

Running the following command

# with abc-inputs.yaml
$ abc templates render -input="world=jupiter" $TEMPLATE_LOC

is effectively the same as

# without abc-inputs.yaml
abc templates render -input="foo=bar, service_account=my-service-account-123, world=jupiter" $TEMPLATE_LOC

Update: see #49 (comment)

For precedence order , I'm considering following ssh.config's example.
From www.jamesridgway.co.uk/simplify-ssh-with-ssh-config-files

SSH takes the first value it finds for each parameter. Command line arguments take precedent over a user's config file which takes precedence over the system config file and within a configuration file earlier entries take precedent over later entries

@drevell
Copy link
Contributor Author

drevell commented Oct 13, 2023

cc @sethvargo @verbanicm @dcreey this effort is starting up again, led by @stytchiz. The rationale is that our two main customers, Mike and Dylan, both want it, and much of the work will be reusable for #191.

@drevell drevell removed their assignment Oct 17, 2023
@dcreey
Copy link
Contributor

dcreey commented Oct 23, 2023

My use case is that we generate a root project location in our repo using a template. This process creates a lot of resources that we need to expose downstream for other templates. Each downstream template creates new resources in sub folders (we are creating deployments, experimental projects, and deployment-resources at the x-project level). As long as we can specify which input configs to use in a command via cli flag the proposed design should be sufficient. If you aren't planning on adding a flag to specify input config path please do.

@stytchiz
Copy link
Contributor

@dcreey Yes, we will be supporting a new flag for the file. @drevell and I talked about doing so, but I forgot to update it here.

abc templates render -input_file=$PATH/abc-input.yaml $TEMPLATE_LOC

@stytchiz
Copy link
Contributor

#245 is merged.

@drevell can we close this issue?

@drevell
Copy link
Contributor Author

drevell commented Oct 25, 2023

#245 is merged.

@drevell can we close this issue?

Sure, let's take it for a quick test drive on the command line first just to make sure everything works as well in reality as it does in tests.

@stytchiz
Copy link
Contributor

➜  hello_jupiter git:(stanchen/issue49) ✗ cat input.yaml 
planet: Jupiter
➜  hello_jupiter git:(stanchen/issue49) ✗ cat spec.yaml 
apiVersion: 'cli.abcxyz.dev/v1alpha1'
kind: 'Template'

desc:
  'Template for printing planet'
inputs:
  - name: 'planet'
    desc: 'foo bar baz'
steps:
  - desc: 'Print "planet"'
    action: 'print'
    params:
      message: 'Hello {{.planet}}'
➜  hello_jupiter git:(stanchen/issue49) ✗ ./abc templates render --input-file=input.yaml .
Hello Jupiter
➜  hello_jupiter git:(stanchen/issue49) ✗ ./abc templates render --input=planet=Mars --input-file=input.yaml .
Hello Mars

@drevell
Copy link
Contributor Author

drevell commented Oct 25, 2023

Nice, thanks Stanley. This was released in v0.2.1 and is ready to be used (cc @dcreey who wanted to use it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Development

No branches or pull requests

3 participants