- .github
- actions
- api
- blueprints
-
cmd
-
timoni
- testdata
- apply.go
- apply_test.go
- artifact.go
- artifact_list.go
- artifact_pull.go
- artifact_pull_test.go
- artifact_push.go
- artifact_push_test.go
- artifact_tag.go
- artifact_tag_test.go
- build.go
- build_test.go
- bundle.go
- bundle_apply.go
- bundle_apply_test.go
- bundle_build.go
- bundle_build_test.go
- bundle_delete.go
- bundle_delete_test.go
- bundle_status.go
- bundle_status_test.go
- bundle_vet.go
- bundle_vet_test.go
- completion.go
- completion_bash.go
- completion_fish.go
- completion_funcs.go
- completion_powershell.go
- completion_zsh.go
- delete.go
- delete_test.go
- docgen.go
- dyff.go
- dyff_test.go
- errors.go
- inspect.go
- inspect_module.go
- inspect_resources.go
- inspect_test.go
- inspect_values.go
- list.go
- log.go
- main.go
- main_test.go
- mod.go
- mod_init.go
- mod_list.go
- mod_list_test.go
- mod_pull.go
- mod_pull_test.go
- mod_push.go
- mod_push_test.go
- mod_show.go
- mod_show_config.go
- mod_show_config_test.go
- mod_vendor.go
- mod_vendor_crd.go
- mod_vendor_crd_test.go
- mod_vendor_k8s.go
- mod_vet.go
- mod_vet_test.go
- registry.go
- runtime.go
- runtime_build.go
- runtime_build_test.go
- status.go
- status_test.go
- version.go
- version_test.go
-
timoni
- docs
-
examples
- bundles
-
minimal
- cue.mod
- templates
- README.md
- debug_tool.cue
- debug_values.cue
- timoni.cue
- values.cue
- redis
- hack
-
internal
-
engine
- fetcher
- testdata
- bundle_builder.go
- bundle_builder_test.go
- doc.go
- importer.go
- importer_test.go
- module_builder.go
- module_builder_test.go
- resourceset.go
- resourceset_test.go
- runtime_builder.go
- runtime_builder_test.go
- runtime_injector.go
- runtime_injector_test.go
- utils.go
- utils_test.go
- values_builder.go
- values_builder_test.go
- flags
- oci
- runtime
- testutils
-
engine
- logo
- schemas
- .gitattributes
- .gitignore
- .goreleaser.yml
- CODE_OF_CONDUCT.md
- CONTRIBUTING.md
- DCO
- LICENSE
- Makefile
- README.md
- SECURITY.md
- go.mod
- go.sum
- mkdocs.yml
- proto-plugin.toml
Explanation
This code sets up an in-memory Docker registry server for testing purposes. Here’s a breakdown:
1. TestMain:
- Purpose: Runs before any test functions within the test file.
- Details:
- Creates a context and sets up a Docker registry server using
setupRegistryServer
. - Stores the registry address in
dockerRegistry
for later use in tests. - Runs all tests within the file using
m.Run()
. - Exits with the return code of the tests.
2. setupRegistryServer:
- Purpose: Creates and starts an in-memory Docker registry server.
- Details:
- Configuration:
- Disables access logging and sets log level to “error”.
- Finds a free port using
freeport.GetFreePort
. - Sets
dockerRegistry
to “localhost:”. - Configures the server to listen on
127.0.0.1:<port>
. - Uses the “inmemory” storage driver.
- Registry Creation:
- Creates a new
registry.Registry
using the configured parameters. - Server Start:
- Starts the registry server in a separate goroutine.
- Returns: An error if any step fails.
3. rnd:
- Purpose: Generates a random string with a given prefix and length.
- Details:
- Generates a random sequence of letters and numbers.
- Appends the prefix to the generated string.
Summary:
This code provides a simple, in-memory Docker registry server that can be used for testing purposes. It allows test cases to interact with a registry server without the need for a real Docker registry instance. The code ensures the registry is started before tests run and stops it afterwards, providing a clean testing environment.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph