Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
drop metrics and contexts. CLI only offers command implemented on ECS
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Apr 18, 2023
1 parent 90eac95 commit 7d71118
Show file tree
Hide file tree
Showing 153 changed files with 171 additions and 16,664 deletions.
78 changes: 1 addition & 77 deletions api/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,11 @@
package backend

import (
"errors"
"fmt"

"github.com/docker/compose/v2/pkg/api"
"github.com/sirupsen/logrus"

"github.com/docker/compose-ecs/api/cloud"
"github.com/docker/compose-ecs/api/containers"
"github.com/docker/compose-ecs/api/resources"
"github.com/docker/compose-ecs/api/secrets"
"github.com/docker/compose-ecs/api/volumes"
"github.com/docker/compose/v2/pkg/api"
)

var (
errNoType = errors.New("backend: no type")
errNoName = errors.New("backend: no name")
errTypeRegistered = errors.New("backend: already registered")
)

type initFunc func() (Service, error)
type getCloudServiceFunc func() (cloud.Service, error)

type registeredBackend struct {
name string
backendType string
init initFunc
getCloudService getCloudServiceFunc
}

var backends = struct {
r []*registeredBackend
}{}

var instance Service

// Current return the active backend instance
Expand All @@ -64,55 +36,7 @@ func WithBackend(s Service) {

// Service aggregates the service interfaces
type Service interface {
ContainerService() containers.Service
ComposeService() api.Service
ResourceService() resources.Service
SecretsService() secrets.Service
VolumeService() volumes.Service
}

// Register adds a typed backend to the registry
func Register(name string, backendType string, init initFunc, getCoudService getCloudServiceFunc) {
if name == "" {
logrus.Fatal(errNoName)
}
if backendType == "" {
logrus.Fatal(errNoType)
}
for _, b := range backends.r {
if b.backendType == backendType {
logrus.Fatal(errTypeRegistered)
}
}

backends.r = append(backends.r, &registeredBackend{
name,
backendType,
init,
getCoudService,
})
}

// Get returns the backend registered for a particular type, it returns
// an error if there is no registered backends for the given type.
func Get(backendType string) (Service, error) {
for _, b := range backends.r {
if b.backendType == backendType {
return b.init()
}
}

return nil, api.ErrNotFound
}

// GetCloudService returns the backend registered for a particular type, it returns
// an error if there is no registered backends for the given type.
func GetCloudService(backendType string) (cloud.Service, error) {
for _, b := range backends.r {
if b.backendType == backendType {
return b.getCloudService()
}
}

return nil, fmt.Errorf("backend not found for backend type %s", backendType)
}
119 changes: 0 additions & 119 deletions api/client/client.go

This file was deleted.

123 changes: 0 additions & 123 deletions api/client/compose.go

This file was deleted.

Loading

0 comments on commit 7d71118

Please sign in to comment.