This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from weaveworks/platform-registry
Stub out platform and registry objects
- Loading branch information
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Package platform provides domain abstractions over orchestration platforms. | ||
package platform | ||
|
||
// Platform describes a runtime platform, like Swarm. | ||
type Platform interface { | ||
Services() []Service | ||
} | ||
|
||
// Service describes a single service as understood by a platform. This is an | ||
// interface rather than a struct, because we want to allow platforms to define | ||
// their own Service structs with all of their specific implementation details. | ||
type Service interface { | ||
Name() string | ||
Instances() []Instance | ||
} | ||
|
||
// Instance describes a single physical instance as understood by a platform. | ||
// The same caveats re: interface apply as to the service. | ||
type Instance interface { | ||
ID() string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Package swarm provides Swarm-flavored platform objects. | ||
package swarm | ||
|
||
import "github.com/weaveworks/fluxy/platform" | ||
|
||
// Platform represents a single Swarm cluster, as understood by a fluxd daemon | ||
// deployed within it. That means something like a connection to the API server, | ||
// so state may be queried. | ||
type Platform struct{} | ||
|
||
// Services implements platform.Platform. | ||
func (p *Platform) Services() []platform.Service { | ||
return []platform.Service{} | ||
} | ||
|
||
// Service represents a single Swarm service as yielded by a platform. | ||
type Service struct { | ||
name string | ||
instances []Instance | ||
} | ||
|
||
// Name implements platform.Service. | ||
func (s *Service) Name() string { | ||
return s.name | ||
} | ||
|
||
// Instances implements platform.Service. | ||
func (s *Service) Instances() []platform.Instance { | ||
res := make([]platform.Instance, len(s.instances)) | ||
for i := range s.instances { | ||
res[i] = &s.instances[i] | ||
} | ||
return res | ||
} | ||
|
||
// Instance represents a single container, or task, in a Swarm service. | ||
type Instance struct { | ||
id string | ||
} | ||
|
||
// ID implements platform.Instance. | ||
func (i *Instance) ID() string { | ||
return i.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Package quay provides Quay.io-flavored registry objects. | ||
package quay | ||
|
||
import ( | ||
"github.com/weaveworks/fluxy/registry" | ||
) | ||
|
||
// Registry represents a single Quay registry. | ||
type Registry struct { | ||
// Some Quay auth details stored here | ||
} | ||
|
||
// NewRegistry returns a new Quay-flavored Registry. | ||
func NewRegistry(username, password string) *Registry { | ||
return &Registry{} | ||
} | ||
|
||
// Repositories implements registry.Registry. | ||
func (r *Registry) Repositories() []registry.Repository { | ||
return []registry.Repository{} | ||
} | ||
|
||
// Repository represents a single Quay repository, yielded by a Quay Registry. | ||
type Repository struct { | ||
name string | ||
images []registry.Image | ||
} | ||
|
||
// Name implements registry.Repository. | ||
func (r *Repository) Name() string { | ||
return r.name | ||
} | ||
|
||
// Images implements registry.Repository. | ||
func (r *Repository) Images() []registry.Image { | ||
return r.images | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Package registry provides domain abstractions over container registries. | ||
package registry | ||
|
||
import "time" | ||
|
||
// Registry represents a container registry from the perspective of a specific, | ||
// logged-in user or organization. | ||
type Registry interface { | ||
Repositories() []Repository | ||
} | ||
|
||
// Repository is a collection of related (i.e. identical) images. | ||
type Repository interface { | ||
Name() string // "weaveworks/helloworld" | ||
Images() []Image | ||
} | ||
|
||
// Image represents a specific container image available in a repository. It's a | ||
// struct because I think we can safely assume the data here is pretty | ||
// universal across different registries and repositories. | ||
type Image struct { | ||
Name string // "weaveworks/helloworld" | ||
Tag string // "master-59f0001" | ||
CreatedAt time.Time // Always UTC | ||
} |