Skip to content

Commit

Permalink
feat(#209); try scrapping acorns
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanHCB committed Oct 6, 2023
1 parent 3b25b41 commit 6bc3b2e
Show file tree
Hide file tree
Showing 80 changed files with 759 additions and 1,180 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,6 @@ correct version. If not, wait a bit and try again, you landed on an instance tha

![software architecture](docs/architecture-export.png)

### Those aren't Beans, they're Acorns

Our singleton components implement the
[Acorn interface](https://github.com/StephanHCB/go-autumn-acorn-registry/blob/main/api/interface.go).
All singletons refer to each other by references to their interface. This allows for easy mocking during tests.

## development

### initial setup
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ exclude (
)

require (
github.com/StephanHCB/go-autumn-acorn-registry v0.3.1
github.com/StephanHCB/go-autumn-config-api v0.2.1
github.com/StephanHCB/go-autumn-config-env v0.2.2
github.com/StephanHCB/go-autumn-logging v0.3.0
Expand All @@ -62,7 +61,7 @@ require (
github.com/StephanHCB/go-autumn-restclient-circuitbreaker v0.4.1
github.com/StephanHCB/go-autumn-restclient-circuitbreaker-prometheus v0.1.0
github.com/StephanHCB/go-autumn-restclient-prometheus v0.1.2
github.com/StephanHCB/go-backend-service-common v0.5.1
github.com/StephanHCB/go-backend-service-common v0.5.2-0.20231006142552-74b094f17b4f
github.com/go-chi/chi/v5 v5.0.10
github.com/go-git/go-billy/v5 v5.5.0
github.com/go-git/go-git/v5 v5.9.0
Expand All @@ -81,6 +80,7 @@ require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/StephanHCB/go-autumn-acorn-registry v0.3.1 // indirect
github.com/StephanHCB/go-autumn-web-swagger-ui v0.2.3 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/armon/go-radix v1.0.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ github.com/StephanHCB/go-autumn-web-swagger-ui v0.2.3 h1:aC/rTlw9pBPCWYH46KGzSB9
github.com/StephanHCB/go-autumn-web-swagger-ui v0.2.3/go.mod h1:EBtCQXF8JhoADnadezundz2xWEdFPmx2NUTgZYtUE0M=
github.com/StephanHCB/go-backend-service-common v0.5.1 h1:Ailpaq3PjCKsir79YTubz0lMvLOI2kE38hZPj6snx5Y=
github.com/StephanHCB/go-backend-service-common v0.5.1/go.mod h1:UBCrmMypKkucU8Upqlej4sUCI4Bn0Xakgv3yT9kSbno=
github.com/StephanHCB/go-backend-service-common v0.5.2-0.20231006124829-e54605b6bbee h1:xLIAMjoe6yzsVZ7BFx+1BTP3pA/GrhZq4fDh6nyyJ6k=
github.com/StephanHCB/go-backend-service-common v0.5.2-0.20231006124829-e54605b6bbee/go.mod h1:UBCrmMypKkucU8Upqlej4sUCI4Bn0Xakgv3yT9kSbno=
github.com/StephanHCB/go-backend-service-common v0.5.2-0.20231006142552-74b094f17b4f h1:ejWnj2aVE2Lg2OcecKfCh8W3xuit3nrAbHdBElY24UU=
github.com/StephanHCB/go-backend-service-common v0.5.2-0.20231006142552-74b094f17b4f/go.mod h1:UBCrmMypKkucU8Upqlej4sUCI4Bn0Xakgv3yT9kSbno=
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
Expand Down
21 changes: 0 additions & 21 deletions internal/acorn/application/appint.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,6 @@ const ApplicationName = "metadata"
type Application interface {
IsApplication() bool

// Register registers all Acorns that make up the application.
//
// after a call to Register you can override the Acorn constructors in the registry, e.g. for mocking.
//
// if not already called, Run will call this for you.
Register()

// Create instantiates all Acorns, but does not connect them.
//
// after a call to Create you can replace Acorns by name in the registry, e.g. for testing/mocking.
//
// if not already called, Run will call this for you.
Create()

// Assemble wires up all Acorns.
//
// to avoid a circular dependency with logging, this also parses the configuration, but does not validate it.
//
// if not already called, Run will call this for you.
Assemble() error

// Run runs the application, including setup and teardown phase
//
// returns the exit code - we do not call os.Exit inside
Expand Down
4 changes: 2 additions & 2 deletions internal/acorn/application/serverint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package application

import "context"

const ServerAcornName = "server"

type Server interface {
IsServer() bool

Setup() error

WireUp(ctx context.Context)

Run() error
Expand Down
2 changes: 0 additions & 2 deletions internal/acorn/controller/ownerctlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"github.com/go-chi/chi/v5"
)

const OwnerControllerAcornName = "ownerctl"

// OwnerController provides endpoints for managing owner information
type OwnerController interface {
IsOwnerController() bool
Expand Down
2 changes: 0 additions & 2 deletions internal/acorn/controller/repositoryctlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"github.com/go-chi/chi/v5"
)

const RepositoryControllerAcornName = "repositoryctl"

// RepositoryController provides endpoints for managing repository information
type RepositoryController interface {
IsRepositoryController() bool
Expand Down
2 changes: 0 additions & 2 deletions internal/acorn/controller/servicectlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"github.com/go-chi/chi/v5"
)

const ServiceControllerAcornName = "servicectl"

// ServiceController provides endpoints for managing service information
type ServiceController interface {
IsServiceController() bool
Expand Down
2 changes: 0 additions & 2 deletions internal/acorn/controller/webhookctlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"github.com/go-chi/chi/v5"
)

const WebhookControllerAcornName = "webhookctl"

// WebhookController provides a simple git webhook endpoint
type WebhookController interface {
IsWebhookController() bool
Expand Down
6 changes: 3 additions & 3 deletions internal/acorn/repository/bitbucketint.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"context"
)

const BitbucketAcornName = "bitbucket"

type Bitbucket interface {
IsBitbucket() bool

Setup(ctx context.Context) error
Setup() error

SetupClient(ctx context.Context) error

GetBitbucketUser(ctx context.Context, username string) (BitbucketUser, error)
GetBitbucketUsers(ctx context.Context, usernames []string) ([]BitbucketUser, error)
Expand Down
4 changes: 2 additions & 2 deletions internal/acorn/repository/hostipint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package repository

import "net"

const HostIPAcornName = "hostip"

// HostIP interacts with the local network interfaces.
type HostIP interface {
IsHostIP() bool

Setup() error

// ObtainLocalIp gets the first non-localhost ipv4 address from your interfaces.
//
// In a k8s deployment, that'll be the pod ip.
Expand Down
8 changes: 4 additions & 4 deletions internal/acorn/repository/idpint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package repository

import "context"

const IdentityProviderAcornName = "idp"

// IdentityProvider is the central singleton representing an Open ID Connect Identity Provider.
//
// We use this to obtain a JWT keyset and to check its id endpoint to synchronously validate JWT tokens.
type IdentityProvider interface {
IsIdentityProvider() bool

// Setup uses the configuration to set up
Setup(ctx context.Context) error
Setup() error

// SetupConnector uses the configuration to set up the connector
SetupConnector(ctx context.Context) error

// ObtainKeySet calls the key set endpoint and converts the keys to PEM for use with the jwt package
ObtainKeySet(ctx context.Context) error
Expand Down
5 changes: 3 additions & 2 deletions internal/acorn/repository/kafkaint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package repository

import "context"

const KafkaAcornName = "kafka"

// Kafka is the central singleton representing the kafka messaging bus.
type Kafka interface {
IsKafka() bool

Setup() error
Teardown()

// SubscribeIncoming allows you to register a callback that is called whenever a message is received from the Kafka bus.
//
// Note, we currently only allow a single callback, so calling this multiple times will overwrite the callback.
Expand Down
5 changes: 3 additions & 2 deletions internal/acorn/repository/metadataint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"time"
)

const MetadataAcornName = "metadata"

// CommitInfo holds information about a commit.
type CommitInfo struct {
CommitHash string
Expand All @@ -24,6 +22,9 @@ type CommitInfo struct {
type Metadata interface {
IsMetadata() bool

Setup() error
Teardown()

// Clone performs an initial in-memory clone of the metadata repository on the mainline
Clone(ctx context.Context) error

Expand Down
6 changes: 3 additions & 3 deletions internal/acorn/repository/notifierint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"github.com/Interhyp/metadata-service/internal/types"
)

const NotifierAcornName = "notifier"

type Notifier interface {
IsNotifier() bool

Setup(ctx context.Context) error
Setup() error

SetupNotifier(ctx context.Context) error

PublishCreation(ctx context.Context, payloadName string, payload openapi.NotificationPayload) error

Expand Down
6 changes: 3 additions & 3 deletions internal/acorn/repository/sshAuthProviderInt.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
)

const SshAuthProviderAcornName = "SshAuthProvider"

// SshAuthProvider is an SshAuthProvider business logic component.
type SshAuthProvider interface {
IsSshAuthProvider() bool

Setup(ctx context.Context) error
Setup() error

SetupProvider(ctx context.Context) error

ProvideSshAuth(ctx context.Context) (*ssh.PublicKeys, error)
}
4 changes: 2 additions & 2 deletions internal/acorn/service/cacheint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"github.com/Interhyp/metadata-service/api"
)

const CacheAcornName = "cache"

// Cache is the central in-memory metadata cache, present to speed up read access to the current metadata.
type Cache interface {
IsCache() bool

Setup() error

// --- owner cache ---

// SetOwnerListTimestamp lets you set or update the timestamp for the last full scan of the list of aliases.
Expand Down
4 changes: 2 additions & 2 deletions internal/acorn/service/mapperint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"github.com/Interhyp/metadata-service/internal/acorn/repository"
)

const MapperAcornName = "mapper"

// Mapper translates between the git repo representation (yaml) and the business entities.
//
// It also performs commit workflows for the metadata repository.
Expand All @@ -22,6 +20,8 @@ const MapperAcornName = "mapper"
type Mapper interface {
IsMapper() bool

Setup() error

RefreshMetadata(ctx context.Context) ([]repository.UpdateEvent, error)
ContainsNewInformation(ctx context.Context, event repository.UpdateEvent) bool

Expand Down
4 changes: 2 additions & 2 deletions internal/acorn/service/ownersint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"github.com/Interhyp/metadata-service/api"
)

const OwnersAcornName = "owners"

// Owners provides the business logic for owner metadata.
type Owners interface {
IsOwners() bool

Setup() error

GetOwners(ctx context.Context) (openapi.OwnerListDto, error)
GetOwner(ctx context.Context, ownerAlias string) (openapi.OwnerDto, error)

Expand Down
3 changes: 1 addition & 2 deletions internal/acorn/service/repositoriesint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"github.com/StephanHCB/go-backend-service-common/api/apierrors"
)

const RepositoriesAcornName = "repositories"

// Repositories provides the business logic for repository metadata.
type Repositories interface {
IsRepositories() bool
Setup() error

// ValidRepositoryKey checks validity of a repository key and returns an error describing the problem if invalid
ValidRepositoryKey(ctx context.Context, repoKey string) apierrors.AnnotatedError
Expand Down
4 changes: 2 additions & 2 deletions internal/acorn/service/servicesint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"github.com/Interhyp/metadata-service/api"
)

const ServicesAcornName = "services"

// Services provides the business logic for service metadata.
type Services interface {
IsServices() bool

Setup() error

GetServices(ctx context.Context, ownerAliasFilter string) (openapi.ServiceListDto, error)
GetService(ctx context.Context, serviceName string) (openapi.ServiceDto, error)

Expand Down
4 changes: 2 additions & 2 deletions internal/acorn/service/triggerint.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package service

const TriggerAcornName = "trigger"

// Trigger triggers update runs in Updater.
//
// Trigger events occur on initial app startup (before it becomes healthy), and periodically
type Trigger interface {
IsTrigger() bool
Setup() error
Teardown()
}
4 changes: 2 additions & 2 deletions internal/acorn/service/updaterint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"github.com/Interhyp/metadata-service/api"
)

const UpdaterAcornName = "updater"

// Updater is the central orchestrator component that manages information flow.
type Updater interface {
IsUpdater() bool

Setup() error

// -- Eventing --

// StartReceivingEvents starts receiving events. Called by Trigger after it has initially populated the cache.
Expand Down
Loading

0 comments on commit 6bc3b2e

Please sign in to comment.