Skip to content

Commit

Permalink
Merge pull request #210 from Interhyp/testing_poc_noacorn
Browse files Browse the repository at this point in the history
feat(#209); scrap acorns
  • Loading branch information
StephanHCB authored Oct 10, 2023
2 parents 3b25b41 + 529cdc4 commit 46059b2
Show file tree
Hide file tree
Showing 85 changed files with 1,125 additions and 1,691 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: go vet ./...

- name: Run coverage
run: go test -race -coverpkg='./internal/...' -coverprofile=coverage.out -covermode=atomic ./...
run: go test -coverpkg='./internal/...' -coverprofile=coverage.out -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

Expand Down
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
10 changes: 5 additions & 5 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.6.0
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 Expand Up @@ -125,9 +125,9 @@ require (
github.com/tidwall/tinylru v1.2.1 // indirect
github.com/twmb/franz-go/pkg/kmsg v1.6.1 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
go.elastic.co/apm/module/apmchiv5/v2 v2.4.3 // indirect
go.elastic.co/apm/module/apmhttp/v2 v2.4.3 // indirect
go.elastic.co/apm/v2 v2.4.3 // indirect
go.elastic.co/apm/module/apmchiv5/v2 v2.4.4 // indirect
go.elastic.co/apm/module/apmhttp/v2 v2.4.4 // indirect
go.elastic.co/apm/v2 v2.4.4 // indirect
go.elastic.co/fastjson v1.1.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/mod v0.12.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ github.com/StephanHCB/go-autumn-restclient-prometheus v0.1.2 h1:xsTZdR9WlSaoeUc3
github.com/StephanHCB/go-autumn-restclient-prometheus v0.1.2/go.mod h1:74X7ghxTOjj6Tl0lvVJXOQHz+3RbKvGirvF5l82XDwk=
github.com/StephanHCB/go-autumn-web-swagger-ui v0.2.3 h1:aC/rTlw9pBPCWYH46KGzSB942sTALIcIsZi0piVUuEo=
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.6.0 h1:PWqGdUq7TPqI+rPwgHB+pcXZUWQOCMBMS4wFWoWXvvc=
github.com/StephanHCB/go-backend-service-common v0.6.0/go.mod h1:/S3+UrSczKX6Ypk35G5xz1NRjnH6SifKLlfsFrveAmc=
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 Expand Up @@ -185,12 +185,12 @@ github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.elastic.co/apm/module/apmchiv5/v2 v2.4.3 h1:U1Ju0e8GhgqWQTsWiUKWMxx10qL0JgJwsjH8Xhe0bbw=
go.elastic.co/apm/module/apmchiv5/v2 v2.4.3/go.mod h1:KgKbigCbttUp5X5I5EWm+ch1m5QgEcRaOU+aNLu5Exw=
go.elastic.co/apm/module/apmhttp/v2 v2.4.3 h1:bBqbbtQSEL+uVpH5CS656E9x6pXha8kkZ468/G0T5Eo=
go.elastic.co/apm/module/apmhttp/v2 v2.4.3/go.mod h1:PsafA29/iwRva1ouV+70Lfu6RyAJHh6Zcc+jL6eZ83E=
go.elastic.co/apm/v2 v2.4.3 h1:k6mj63O7IIyqqn3S52C2vBXvaSK9M5FHp0aZHpPH/as=
go.elastic.co/apm/v2 v2.4.3/go.mod h1:+CiBUdrrAGnGCL9TNx7tQz3BrfYV23L8Ljvotoc87so=
go.elastic.co/apm/module/apmchiv5/v2 v2.4.4 h1:jcEDE5wRvR8e6Y1bIF1lTMgegp52A2P5K4m4AED8Hnk=
go.elastic.co/apm/module/apmchiv5/v2 v2.4.4/go.mod h1:VBBWtTlOF23Sj4M+Ad8Zxl+yq5RP4D6NPC8hhDz0xy0=
go.elastic.co/apm/module/apmhttp/v2 v2.4.4 h1:BcJDLFztZByHiJRXXvAHY7bue9+vhzMLn2OBK5N8HDw=
go.elastic.co/apm/module/apmhttp/v2 v2.4.4/go.mod h1:694qsHWRPVkfYqQ224ZSeRx9Dt2FS/xF1igNBGkHi6o=
go.elastic.co/apm/v2 v2.4.4 h1:KGbmUEtLNQ6sCFGpqTMhfRjqDOKP8IliO+efErKY5lU=
go.elastic.co/apm/v2 v2.4.4/go.mod h1:+CiBUdrrAGnGCL9TNx7tQz3BrfYV23L8Ljvotoc87so=
go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4=
go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
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 46059b2

Please sign in to comment.