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 .ko.yaml while in subdir #172

Closed
mattmoor opened this issue Jun 12, 2020 · 6 comments
Closed

Support .ko.yaml while in subdir #172

mattmoor opened this issue Jun 12, 2020 · 6 comments

Comments

@mattmoor
Copy link
Collaborator

Today if I invoke ko apply -f foo/ while in a subdirectory bar/ then it is possible that a .ko.yaml file that's a sibling of bar/ won't be picked up because we (currently) only look at siblings of foo/.

Fortunately, AddConfigPath seems to support multiple invocations, so we can crawl the directory hierarchy from the current working directory to populate the path.

I think we want this here: https://github.com/google/ko/blob/d45c5277500220120e9196f431856c0cdd83e92b/pkg/commands/config.go#L104

@stanleynguyen
Copy link
Contributor

Hey @mattmoor I'd like to take this one up but before that I want to clarify with you. Let's say I have this structure:

- foo
- | - .ko.yaml
- | - k8s.yaml
- | - bar
- | - | - k8s_inside_bar.yaml
- | - | - .ko.yaml

Are we expecting to use foo/.ko.yaml for foo/k8s.yaml only and then use foo/bar/.ko.yaml for foo/bar/k8s_inside_bar.yaml?
Or are we using only either one of foo/.ko.yaml or foo/bar/.ko.yaml (if this is the case, which one has higher priority)?

@mattmoor
Copy link
Collaborator Author

I think this could spiral quickly, so I think as a first increment let's start with three simple pieces:

  1. Log if/where .ko.yaml is being read from,
  2. Support a flag to override that,
  3. Walk up the directory hierarchy and pick the first (vs. today, which only does current dir)

I think this balances clarity and simplicity. WDYT?

@stanleynguyen
Copy link
Contributor

I'm totally behind reading from only one .ko.yaml as I love to keep things simple. One question though, by "walking up", you mean we search parent directories? If that's the case, I'm seeing some complexity on how we determine when to stop searching?

@mattmoor
Copy link
Collaborator Author

I'd probably do the simple thing: keep going until you hit the root, or start getting permissions errors 🤷

@stanleynguyen
Copy link
Contributor

stanleynguyen commented Aug 29, 2020

I'd probably do the simple thing: keep going until you hit the root, or start getting permissions errors 🤷

One edge case that might end up confusing to end users (small problem since we're logging the location out but I'd still like to raise it): Say I have project2 as a subdir in project1, something like:

|- project1
|- .ko.yaml
|- project2
|- |- k8s.yaml

Now if I run ko apply -f k8s.yaml inside project1/project2 with the intention of using environment variables, I would be out of luck because the config (with the above-discussed behavior) would be read from project1/.ko.yaml.
I understand that the above scenario is an extreme one and most likely would not happen for majority of our users, but I'd still like to check if it's small enough for us to ignore. Also, we might need a flag value to indicate not reading from .ko.yaml for the mentioned scenario

@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

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

Successfully merging a pull request may close this issue.

2 participants