Skip to content

docs: add description about our code structure #26394

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ Pull requests that change the vendor/ directory directly will not be accepted.
Instead, changes should be submitted to the original package (defined by the path in `vendor/`; for example, `vendor/github.com/containers/storage` is the [containers/storage library](https://github.com/containers/storage/).
Once the changes have been merged into the original package, Podman's vendor directory can be updated by using `go get` on the appropriate version of the package, then running `make vendor` or `make vendor-in-container`.

## Codebase structure

Description about important directories in our repository is found [here](./docs/CODE_STRUCTURE.md).

## Testing

Podman provides an extensive suite of regression tests in the `test/` directory.
Expand Down
92 changes: 92 additions & 0 deletions docs/CODE_STRUCTURE.md
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree the content serves the purpose of the PR of a "getting started guide for new folks"

Before merging a few small grammatical issues should be resolved:

  • Capitalise proper nouns like Podman, Sphinx, SQLite, BoltDB.
  • Capitalise the first letter in each of the dot points.
  • Add periods to the end of each dot point.

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Podman Codebase structure

Description about important directories in our repository.

### cmd/
Copy link
Member

Choose a reason for hiding this comment

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

### contrib ?


- each directory here builds its own binary

#### cmd/podman/

- podman cli code, cli commands and flags are defined here, we are using github.com/spf13/cobra as library for command line parsing
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- podman cli code, cli commands and flags are defined here, we are using github.com/spf13/cobra as library for command line parsing
- Podman CLI code, CLI commands and flags are defined here, we are using the [Cobra CLI library](https://github.com/spf13/cobra) for command line parsing.


#### cmd/quadlet/

- quadlet cli

### contrib/

- CI scripts, packaging files some container image build files

### docs/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe also link to docs/REAME.md in this section? It goes into more depth on the directory structure for docs/


- sphinx based documentation for podman that is build on readthedocs (docs.podman.io)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- sphinx based documentation for podman that is build on readthedocs (docs.podman.io)
- Sphinx based documentation for Podman that is build on [Read the Docs](https://readthedocs.com/) and hosted at [docs.podman.io](https://docs.podman.io/en/latest/)


#### docs/source/markdown/

- man pages for each podman command

### libpod/ (only works on linux and freebsd)
- underlying core for most podman operations, defines container, pod, volume management opartions
- contains the database to store these information on disk, either sqlite or botldb (our old db format)
- integrates with our other libraries such as:
- containers/storage create and mount container storage
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Do we want to use 4 indents here? If so please ignore.

- containers/buildah for building images
- containers/common/libnetwork for network management

### pkg/

- various packages to do all sorts of different things

#### pkg/api/
Copy link
Member

Choose a reason for hiding this comment

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

Maybe ##### pkg/api/handlers/compat and ##### pkg/api/handlers/libpod.


- the HTTP REST API server code

#### pkg/bindings/

- the HTTP REST API client code
- this package must have a stable API as it is for use by external consumers as well

#### pkg/domain/

- "glue" code between cli and the actual operations performed

##### pkg/domain/entities/

- the package defines two interfaces (ContainerEngine, ImageEngine) that more or less have a function for each cli command defined
- it also defines a lot of types (structs) for the various options the functions accept

##### pkg/domain/infra/tunnel/

- implements the two interfaces for the remote mode (podman-remote) which just maps each operations to the bindings code from pkg/bindings which then talks to the remote server

##### pkg/domain/infra/abi/

- implements the two interfaces for the local mode (podman) that calls then directly into the core parts of libpod/ or our other libraries containers/{common,image,storage}...

#### pkg/libartifact/

- core code for the new podman artifact commands

#### pkg/machine/

- core code for podman machine commands
Copy link
Member

Choose a reason for hiding this comment

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

maybe #####pkg/machine/tests ?


##### pkg/machine/e2e/

- e2e tests for podman machine commands
- runs on windows, macos, linux.

### test/

Copy link
Member

Choose a reason for hiding this comment

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

i think @ninja-quokka had some initial trouble understanding these subdirectories. I would be fine with merging this PR without them but maybe that's something we can do soon thereafter? @ninja-quokka im kind of thinking you would be a good candidate for that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I can post a follow up PR with a small addition about the test directory structure. I should really add more content to podman/test/apiv2/README.md before my ideas get oom_reaper'd

- various tests suites, see the test [README.md](../test/README.md) for more details
- these run on linux only

#### vendor/

- directory created with "go mod vendor"
- this includes all go deps in our repo, DO NOT edit this directory directly, changes in dependencies must be made in their respective upstream repositories and then updated in go.mod

#### bin/
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Should this be added to the top to keep the order?


- build binaries are put here (bin/podman, bin/podman-remote, etc...)