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

Application configuration store #9

Merged
merged 1 commit into from
Nov 15, 2020
Merged

Conversation

svengreb
Copy link
Owner

Resolves #8

Like described in the `/apps` directory documentation [1] of the
"tmpl-go" template repository, "wand" also aims to support the
monorepo [2] layout.
In order to manage multiple applications, their information and metadata
are recorded in a configuration store where each entry is identified by
a unique ID, usually the name of the application. The `pkg/app` package
provides two interfaces and an unexported struct that implements it that
can be used through the exported `NewStore() Store` function.

- <T> `pkg/app.Config` — A `struct` type that holds information and
  metadata of an application.
- <I> `pkg/app.Store` — A storage that provides methods to record
  application configurations:
  - `Add(*Config)` — Adds a application configuration.
  - `Get(string) (*Config, error)` — Returns the application
    configuration for the given name or nil along with an error when not
    stored.
- <T> `appStore` — A storage for application configurations.
- <F> `NewStore() Store` — Creates a new store for application configurations.

[1]: https://github.com/svengreb/tmpl-go/tree/main/apps
[2]: https://trunkbaseddevelopment.com/monorepos

GH-8
@svengreb svengreb added this to the 0.1.0 milestone Nov 15, 2020
@svengreb svengreb self-assigned this Nov 15, 2020
@svengreb svengreb merged commit a233575 into main Nov 15, 2020
@svengreb svengreb deleted the feature/gh-8-app-config-store branch November 15, 2020 09:59
@svengreb svengreb removed their assignment Nov 15, 2020
svengreb added a commit that referenced this pull request Nov 15, 2020
In GH-9 [1] the store and configuration for applications has been
implemented. In "wand" applications are not standalone but part of a
project which in turn is stored in a repository of a VCS like Git [2].
In case of "wand" this can also be a monorepo [3] to manage multiple
applications, but there is always only a single project which all these
applications are part of.
To store project and VCS repository information, some of the newly
implemented packages provide the following types:

- <T> "pkg/project.Metadata" - A "struct" type that stores information
  and metadata of a project.
- <T> "pkg/project.GoModuleID" - A "struct" type that stores partial
  information to identify a Go module [4].
- <T> "pkg/vcs.Kind" - A "struct" type that defines the kind of a
  "pkg/vcs.Repository".
- <I> "pkg/vcs.Repository" - A "interface" type to represents a VCS
  repository that provides methods to receive repository information:
  - "Kind() Kind" - returns the repository "pkg/vcs.Kind".
  - "DeriveVersion() error" - derives the repository version based on
    the "pkg/vcs.Kind".
  - "Version() interface{}" - returns the repository version.
- <T> "pkg/vcs/git.Git" - A "struct" type that implements
  "pkg/vcs.Repository" to represent a Git [5] repository.
- <T> "pkg/vcs/git.Version" - A "struct" type that stores version
  information and metadata derived from a Git [5] repository.
- <T> "pkg/vcs/none.None" - A "struct" type that implements
  "pkg/vcs.Repository" to represent a nonexistent repository.

[1]: #9
[2]: https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control
[3]: https://trunkbaseddevelopment.com/monorepos
[4]: https://golang.org/ref/mod
[5]: https://git-scm.com

GH-10
svengreb added a commit that referenced this pull request Nov 16, 2020
In GH-9 [1] the store and configuration for applications has been
implemented. In "wand" applications are not standalone but part of a
project which in turn is stored in a repository of a VCS like Git [2].
In case of "wand" this can also be a monorepo [3] to manage multiple
applications, but there is always only a single project which all these
applications are part of.
To store project and VCS repository information, some of the newly
implemented packages provide the following types:

- <T> "pkg/project.Metadata" - A "struct" type that stores information
  and metadata of a project.
- <T> "pkg/project.GoModuleID" - A "struct" type that stores partial
  information to identify a Go module [4].
- <T> "pkg/vcs.Kind" - A "struct" type that defines the kind of a
  "pkg/vcs.Repository".
- <I> "pkg/vcs.Repository" - A "interface" type to represents a VCS
  repository that provides methods to receive repository information:
  - "Kind() Kind" - returns the repository "pkg/vcs.Kind".
  - "DeriveVersion() error" - derives the repository version based on
    the "pkg/vcs.Kind".
  - "Version() interface{}" - returns the repository version.
- <T> "pkg/vcs/git.Git" - A "struct" type that implements
  "pkg/vcs.Repository" to represent a Git [5] repository.
- <T> "pkg/vcs/git.Version" - A "struct" type that stores version
  information and metadata derived from a Git [5] repository.
- <T> "pkg/vcs/none.None" - A "struct" type that implements
  "pkg/vcs.Repository" to represent a nonexistent repository.

[1]: #9
[2]: https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control
[3]: https://trunkbaseddevelopment.com/monorepos
[4]: https://golang.org/ref/mod
[5]: https://git-scm.com

Closes GH-10
@svengreb svengreb mentioned this pull request Nov 17, 2020
svengreb added a commit that referenced this pull request Nov 17, 2020
In GH-15 [1] some parts of the "wand" API have been implemented in form
of spell "incantations", "kinds" and "casters", inspired by the fantasy
novel "Harry Potter" [2] as an abstract view to define interfaces.
In GH-9 [3] and GH-11 [4] the API implementations for an application
configuration store as well as project and VCS repository metadata were
introduced.
These implementations are now usable in a combined form via the basic
"wand" API that consists of the following types:

- <I> `wand.Wand` - A `interface` type that manages a project and its
  applications and stores their metadata. Applications are registered
  using a unique name and the stored metadata can be received based on
  this name:
  - `GetAppConfig(appName string) (app.Config, error)` - returns an
    application configuration.
  - `GetProjectMetadata() project.Metadata` - returns the project
    metadata.
  - `RegisterApp(name, displayName, pathRel string) error` - registers a
    new application.
- <T> `wand.ctxKey` - A `struct` type that serves as context key used to
  wrap a `wand.Wand`.
- <F> `wand.GetCtxKey() interface{}` - A `func` type that returns the
  key used to wrap a `wand.Wand`.
- <F> `wand.WrapCtx(context.Context,Wand) context.Context` - A `func`
  type that wraps the given `wand.Wand` into the parent context.
  Use `wand.GetCtxKey() interface{}` to receive the key used to wrap
  the `wand.Wand`.

[1]: #15
[2]: https://en.wikipedia.org/wiki/Harry_Potter
[3]: #9
[4]: #11

GH-16
svengreb added a commit that referenced this pull request Nov 17, 2020
In GH-15 [1] some parts of the "wand" API have been implemented in form
of spell "incantations", "kinds" and "casters", inspired by the fantasy
novel "Harry Potter" [2] as an abstract view to define interfaces.
In GH-9 [3] and GH-11 [4] the API implementations for an application
configuration store as well as project and VCS repository metadata were
introduced.
These implementations are now usable in a combined form via the basic
"wand" API that consists of the following types:

- <I> `wand.Wand` - A `interface` type that manages a project and its
  applications and stores their metadata. Applications are registered
  using a unique name and the stored metadata can be received based on
  this name:
  - `GetAppConfig(appName string) (app.Config, error)` - returns an
    application configuration.
  - `GetProjectMetadata() project.Metadata` - returns the project
    metadata.
  - `RegisterApp(name, displayName, pathRel string) error` - registers a
    new application.
- <T> `wand.ctxKey` - A `struct` type that serves as context key used to
  wrap a `wand.Wand`.
- <F> `wand.GetCtxKey() interface{}` - A `func` type that returns the
  key used to wrap a `wand.Wand`.
- <F> `wand.WrapCtx(context.Context,Wand) context.Context` - A `func`
  type that wraps the given `wand.Wand` into the parent context.
  Use `wand.GetCtxKey() interface{}` to receive the key used to wrap
  the `wand.Wand`.

[1]: #15
[2]: https://en.wikipedia.org/wiki/Harry_Potter
[3]: #9
[4]: #11

GH-16
svengreb added a commit that referenced this pull request Nov 17, 2020
In GH-15 [1] some parts of the "wand" API have been implemented in form
of spell "incantations", "kinds" and "casters", inspired by the fantasy
novel "Harry Potter" [2] as an abstract view to define interfaces.
In GH-9 [3] and GH-11 [4] the API implementations for an application
configuration store as well as project and VCS repository metadata were
introduced.
These implementations are now usable in a combined form via the basic
"wand" API that consists of the following types:

- <I> `wand.Wand` - A `interface` type that manages a project and its
  applications and stores their metadata. Applications are registered
  using a unique name and the stored metadata can be received based on
  this name:
  - `GetAppConfig(appName string) (app.Config, error)` - returns an
    application configuration.
  - `GetProjectMetadata() project.Metadata` - returns the project
    metadata.
  - `RegisterApp(name, displayName, pathRel string) error` - registers a
    new application.
- <T> `wand.ctxKey` - A `struct` type that serves as context key used to
  wrap a `wand.Wand`.
- <F> `wand.GetCtxKey() interface{}` - A `func` type that returns the
  key used to wrap a `wand.Wand`.
- <F> `wand.WrapCtx(context.Context,Wand) context.Context` - A `func`
  type that wraps the given `wand.Wand` into the parent context.
  Use `wand.GetCtxKey() interface{}` to receive the key used to wrap
  the `wand.Wand`.

[1]: #15
[2]: https://en.wikipedia.org/wiki/Harry_Potter
[3]: #9
[4]: #11

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

Successfully merging this pull request may close these issues.

Application configuration store
1 participant