diff --git a/go.mod b/go.mod index dd7c3f3..c5f7949 100644 --- a/go.mod +++ b/go.mod @@ -39,6 +39,7 @@ require ( github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/mrusme/go-render v0.0.0-20220522181051-6679dc7559c7 // indirect github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 // indirect diff --git a/go.sum b/go.sum index c7cd40e..26de70c 100644 --- a/go.sum +++ b/go.sum @@ -178,6 +178,8 @@ github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRC github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mrusme/go-render v0.0.0-20220522181051-6679dc7559c7 h1:W2icuSr/hPk7POKZTNqxEFVaz6nbFKcr/PjMJgqSGdI= +github.com/mrusme/go-render v0.0.0-20220522181051-6679dc7559c7/go.mod h1:v8zUoMwWVC0pLhjsb17G8SlHVl/ZsJvP6kG1trj6DE0= github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34= github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho= github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ= diff --git a/nori/nor.go b/nori/nor.go index b4e075a..ecdc96b 100644 --- a/nori/nor.go +++ b/nori/nor.go @@ -8,6 +8,7 @@ import ( "github.com/mrusme/planor/nori/amazon" "github.com/mrusme/planor/nori/vultr" "github.com/mrusme/planor/nori/heroku" + "github.com/mrusme/planor/nori/render" ) type Nor interface { @@ -35,6 +36,10 @@ func New(cloudType *string, profile *string) (Nor, error) { cloud = new(vultr.Vultr) case "heroku": cloud = new(heroku.Heroku) + case "render": + cloud = new(render.Render) + default: + return nil, errors.New("No such cloud") } err := cloud.LoadProfile(profile) @@ -48,7 +53,5 @@ func New(cloudType *string, profile *string) (Nor, error) { } return cloud, nil - - return nil, errors.New("No such cloud") } diff --git a/nori/render/ci.go b/nori/render/ci.go new file mode 100644 index 0000000..2cc185d --- /dev/null +++ b/nori/render/ci.go @@ -0,0 +1,11 @@ +package render + +import ( + "errors" + + "github.com/mrusme/planor/nori/models" +) + +func (cloud *Render) ListPipelines() ([]models.Pipeline, error) { + return nil, errors.New("Unsupported") +} diff --git a/nori/render/instances.go b/nori/render/instances.go new file mode 100644 index 0000000..9b7597b --- /dev/null +++ b/nori/render/instances.go @@ -0,0 +1,31 @@ +package render + +import ( + "github.com/mrusme/planor/nori/models" + + // gorender "github.com/mrusme/go-render" +) + +func (cloud *Render) ListInstances() ([]models.Instance, error) { + var instances []models.Instance + ret, err := cloud.render.ListServices() + if err != nil { + return nil, err + } + + for _, instance := range ret { + newInstance := models.Instance{ + ID: instance.ID, + Name: instance.Name, + + Type: instance.Type, + + Status: instance.Deploys[0].Status, + } + + instances = append(instances, newInstance) + } + + return instances, nil +} + diff --git a/nori/render/logs.go b/nori/render/logs.go new file mode 100644 index 0000000..587ea8d --- /dev/null +++ b/nori/render/logs.go @@ -0,0 +1,21 @@ +package render + +import ( + "errors" + + "github.com/mrusme/planor/nori/models" +) + + +func (cloud *Render) ListLogGroups(updateStreams bool, updateEvents bool) ([]models.LogGroup, error) { + return nil, errors.New("Unsupported") +} + +func (cloud *Render) UpdateLogStreams(logGroup *models.LogGroup, updateEvents bool) (error) { + return errors.New("Unsupported") +} + +func (cloud *Render) UpdateLogEvents(logStream *models.LogStream) (error) { + return errors.New("Unsupported") +} + diff --git a/nori/render/render.go b/nori/render/render.go new file mode 100644 index 0000000..27090df --- /dev/null +++ b/nori/render/render.go @@ -0,0 +1,41 @@ +package render + +import ( + // "context" + "os" + + "github.com/mrusme/planor/nori/adapter" + + gorender "github.com/mrusme/go-render" +) + +type Render struct { + apiKey string + render *gorender.RenderClient +} + +func (cloud *Render) LoadProfile(profile *string) (error) { + cloud.apiKey = os.Getenv(*profile) + + return nil +} + +func (cloud *Render) LoadClients() (error) { + var err error + cloud.render, err = gorender.New(cloud.apiKey) + + return err +} + +func (cloud *Render) GetCapabilities() ([]adapter.Capability) { + var caps []adapter.Capability + + caps = append(caps, adapter.Capability{ + ID: "instances", + Name: "Services", + }) + + return caps +} + +