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

Add EP-10498: Deflate repository into idiomatic Go layout #10566

Merged

Conversation

timflannagan
Copy link
Member

Description

Add an enhancement for deflating the current repository structure (notable the projects/ directory) into a flatter organization. Implementation will follow if accepted.

Related to #10496.
Related to #10498.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

- Separate the project's Go applications by extracting existing CLI entry points (currently nested in `projects/*/cmd` subdirectories) into a top-level `cmd/` directory, in order to follow standard Go patterns.
- Standardize tooling placement by ensuring all project-specific tooling, miscellaneous scripts, and other automation-related files reside in a `hack/` directory.

## Non-Goals
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Add non-goal for separate kgateway/api repository to make it easier for consumers to import that module without the rest of the kgateway module dependencies. This can be done over time if strictly necessary.

$ tree -L 1
├── api/ # Migrated from `projects/gateway2/api/...` initially. Any future API types will be added here.
├── cmd/ # Top-level directory containing main entry points (e.g., cmd/sds, cmd/controller, cmd/envoy-init, etc.).
├── internal/ # Private application and library code that is not meant to be imported by external consumers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, i think it makes sense that most code would live here. that way we know we can change it without breaking downstream clients


```bash
$ tree -L 1
├── api/ # Migrated from `projects/gateway2/api/...` initially. Any future API types will be added here.
Copy link
Contributor

@yuval-k yuval-k Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've seen projects use the plural form apis because often you have more than one (i.e. v1alpha1, v1beta1, etc..)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I've seen a combination of api, apis, and pkg/api(s) throughout the ecosystem. I tend to prefer the first two unless the project adopted the pkg/apis organization as k8s tooling matured.

@timflannagan
Copy link
Member Author

TODO: what to do about projects/distroless going forward.

├── internal/ # Private application and library code that is not meant to be imported by external consumers.
├── pkg/ # Reusable library code that external consumers could import in the future.
├── test/ # Test helpers, e2e tests, integration test assets, etc.
├── hack/ # Houses project-specific tooling, miscellaneous scripts, etc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're going to keep hack? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other potential names: tools, scripts?

├── ci/ # Open question: Should CI-specific scripts remain here or be moved to hack/?
└── ...
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's missing from the current tree layout. I was trying to refactor/rip out/cleanup/etc. the other non-code directories outside of this proposal before enumerating on the final directory structure here. IMO, install/ is fine unless we have better options.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Added the install directory to the tree output in the latest round of commits.)

timflannagan added a commit to timflannagan/kgateway that referenced this pull request Feb 5, 2025
This commit temporarily removes the CODEOWNERS file
now that the docs/ directory has largely been migrated
to the kateway.dev repository. Previously, this file
contained minimal code owner paths and tagged the docs
team whenever any non-osa_*.md file(s) were changed in
the docs/ directory.

Related to kgateway-dev#10566
which overhauls the repository structure. We can re-evaluate
the right CODEOWNERS approach once that EP has been approved
and implemented.

Related to kgateway-dev#10431
which tracks better CODEOWNER adoption throughout the repository.

Signed-off-by: timflannagan <[email protected]>
├── api/ # Migrated from `projects/gateway2/api/...` initially. Any future API types will be added here.
├── cmd/ # Top-level directory containing main entry points (e.g., cmd/sds, cmd/controller, cmd/envoy-init, etc.).
├── design/ # Enhancements, templates, etc.
├── examples/ # Example usage, etc. Open question on whether we want to keep this. The README.md would reference this directory.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaning towards removing this directory. See #10579 (review) for more context.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From ^ PR ref:

does it make sense to just remove the examples directory and rely on the unit / e2e tests as examples? in theory the tests should cover (most of) the use cases we support

Consider using examples for quickstart guide assets (xref).

### Proposed Directory Layout

```bash
$ tree -L 1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs/ directory is missing from this proposed directory layout. See #10576 which overhauled the docs/ directory and replaced the contents with a docs/README.md file that references the dedicated kgateway.dev documentation repository. I think we're leaning towards removing that directory as a follow-up after this EP is implemented.


- `internal/` usage: Which packages are truly internal-only vs. possibly importable by external consumers?
- Versioning: Should there be a dedicated `internal/version` package, or is placing version info in `cmd/` acceptable?
- CI directory: Should CI-specific scripts remain in `ci/` or be moved into `hack/`?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like most scripts under ci can also be used for local debugging so i wouldn't be opposed to moving it into hack. what is the convention for this in other projects? we can also leave them separate for now and iterate on it later

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think hack is pretty widely adopted throughout the k8s ecosystem, so I'm leaning towards consolidating the ci/* contents into the hack directory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 You're spot on @timflannagan with using hack and we can create add'l sub dirs from there as needed.

- Versioning: Should there be a dedicated `internal/version` package, or is placing version info in `cmd/` acceptable?
- CI directory: Should CI-specific scripts remain in `ci/` or be moved into `hack/`?
- projects/distroless: Should we keep this directory? If so, where should it live?
- projects/gateway2: Do we need to keep the non-code files, e.g. istio.sh, Makefile, etc.?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik istio.sh is for local testing, can probably be moved into the hack directory

we should probably combine this Makefile into the top-level Makefile

@danehans danehans added this pull request to the merge queue Feb 6, 2025
Merged via the queue into kgateway-dev:main with commit d3308f7 Feb 6, 2025
8 checks passed
@timflannagan timflannagan deleted the design/add-deflation-proposal branch February 6, 2025 21:05
stevenctl pushed a commit to stevenctl/gloo that referenced this pull request Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants