Skip to content

Commit 677d36e

Browse files
committed
Implemented Render API
1 parent d080e31 commit 677d36e

File tree

7 files changed

+112
-2
lines changed

7 files changed

+112
-2
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ require (
3939
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
4040
github.com/mattn/go-isatty v0.0.14 // indirect
4141
github.com/mattn/go-runewidth v0.0.13 // indirect
42+
github.com/mrusme/go-render v0.0.0-20220522181051-6679dc7559c7 // indirect
4243
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
4344
github.com/muesli/reflow v0.3.0 // indirect
4445
github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRC
178178
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
179179
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
180180
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
181+
github.com/mrusme/go-render v0.0.0-20220522181051-6679dc7559c7 h1:W2icuSr/hPk7POKZTNqxEFVaz6nbFKcr/PjMJgqSGdI=
182+
github.com/mrusme/go-render v0.0.0-20220522181051-6679dc7559c7/go.mod h1:v8zUoMwWVC0pLhjsb17G8SlHVl/ZsJvP6kG1trj6DE0=
181183
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
182184
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
183185
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ=

nori/nor.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/mrusme/planor/nori/amazon"
99
"github.com/mrusme/planor/nori/vultr"
1010
"github.com/mrusme/planor/nori/heroku"
11+
"github.com/mrusme/planor/nori/render"
1112
)
1213

1314
type Nor interface {
@@ -35,6 +36,10 @@ func New(cloudType *string, profile *string) (Nor, error) {
3536
cloud = new(vultr.Vultr)
3637
case "heroku":
3738
cloud = new(heroku.Heroku)
39+
case "render":
40+
cloud = new(render.Render)
41+
default:
42+
return nil, errors.New("No such cloud")
3843
}
3944

4045
err := cloud.LoadProfile(profile)
@@ -48,7 +53,5 @@ func New(cloudType *string, profile *string) (Nor, error) {
4853
}
4954

5055
return cloud, nil
51-
52-
return nil, errors.New("No such cloud")
5356
}
5457

nori/render/ci.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package render
2+
3+
import (
4+
"errors"
5+
6+
"github.com/mrusme/planor/nori/models"
7+
)
8+
9+
func (cloud *Render) ListPipelines() ([]models.Pipeline, error) {
10+
return nil, errors.New("Unsupported")
11+
}

nori/render/instances.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package render
2+
3+
import (
4+
"github.com/mrusme/planor/nori/models"
5+
6+
// gorender "github.com/mrusme/go-render"
7+
)
8+
9+
func (cloud *Render) ListInstances() ([]models.Instance, error) {
10+
var instances []models.Instance
11+
ret, err := cloud.render.ListServices()
12+
if err != nil {
13+
return nil, err
14+
}
15+
16+
for _, instance := range ret {
17+
newInstance := models.Instance{
18+
ID: instance.ID,
19+
Name: instance.Name,
20+
21+
Type: instance.Type,
22+
23+
Status: instance.Deploys[0].Status,
24+
}
25+
26+
instances = append(instances, newInstance)
27+
}
28+
29+
return instances, nil
30+
}
31+

nori/render/logs.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package render
2+
3+
import (
4+
"errors"
5+
6+
"github.com/mrusme/planor/nori/models"
7+
)
8+
9+
10+
func (cloud *Render) ListLogGroups(updateStreams bool, updateEvents bool) ([]models.LogGroup, error) {
11+
return nil, errors.New("Unsupported")
12+
}
13+
14+
func (cloud *Render) UpdateLogStreams(logGroup *models.LogGroup, updateEvents bool) (error) {
15+
return errors.New("Unsupported")
16+
}
17+
18+
func (cloud *Render) UpdateLogEvents(logStream *models.LogStream) (error) {
19+
return errors.New("Unsupported")
20+
}
21+

nori/render/render.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package render
2+
3+
import (
4+
// "context"
5+
"os"
6+
7+
"github.com/mrusme/planor/nori/adapter"
8+
9+
gorender "github.com/mrusme/go-render"
10+
)
11+
12+
type Render struct {
13+
apiKey string
14+
render *gorender.RenderClient
15+
}
16+
17+
func (cloud *Render) LoadProfile(profile *string) (error) {
18+
cloud.apiKey = os.Getenv(*profile)
19+
20+
return nil
21+
}
22+
23+
func (cloud *Render) LoadClients() (error) {
24+
var err error
25+
cloud.render, err = gorender.New(cloud.apiKey)
26+
27+
return err
28+
}
29+
30+
func (cloud *Render) GetCapabilities() ([]adapter.Capability) {
31+
var caps []adapter.Capability
32+
33+
caps = append(caps, adapter.Capability{
34+
ID: "instances",
35+
Name: "Services",
36+
})
37+
38+
return caps
39+
}
40+
41+

0 commit comments

Comments
 (0)