Skip to content

Commit

Permalink
Implemented Render API
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed May 22, 2022
1 parent d080e31 commit 677d36e
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
7 changes: 5 additions & 2 deletions nori/nor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -48,7 +53,5 @@ func New(cloudType *string, profile *string) (Nor, error) {
}

return cloud, nil

return nil, errors.New("No such cloud")
}

11 changes: 11 additions & 0 deletions nori/render/ci.go
Original file line number Diff line number Diff line change
@@ -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")
}
31 changes: 31 additions & 0 deletions nori/render/instances.go
Original file line number Diff line number Diff line change
@@ -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
}

21 changes: 21 additions & 0 deletions nori/render/logs.go
Original file line number Diff line number Diff line change
@@ -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")
}

41 changes: 41 additions & 0 deletions nori/render/render.go
Original file line number Diff line number Diff line change
@@ -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
}


0 comments on commit 677d36e

Please sign in to comment.