Skip to content

Commit

Permalink
Versao funcional salvando os recursos
Browse files Browse the repository at this point in the history
  • Loading branch information
CNCF-Bot committed Dec 10, 2021
1 parent 3bffffd commit 3e947be
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 16 deletions.
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/jfonseca85/controlplaneagent

//replace github.com/jfonseca85/controlplaneagent => ../control-plane-agent

go 1.17

require (
github.com/aws/aws-sdk-go-v2/config v1.11.0
github.com/aws/aws-sdk-go-v2/service/cloudcontrol v1.3.2
github.com/gin-contrib/sse v0.1.0
github.com/gin-gonic/gin v1.7.7
github.com/mattn/go-isatty v0.0.12
)

require (
Expand All @@ -21,13 +21,15 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.6.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.11.1 // indirect
github.com/aws/smithy-go v1.9.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/golang/protobuf v1.3.3 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
github.com/stretchr/testify v1.5.1 // indirect
Expand Down
13 changes: 5 additions & 8 deletions internal/core/domain/cloudcontrolmdl/cloudcontrolmdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ type Model struct {

func ToResourceInput(model Model) *cloudcontrol.CreateResourceInput {
result := cloudcontrol.CreateResourceInput{
TypeName: &(model.TypeName),
DesiredState: &(model.DesiredState),
ClientToken: &(model.ClientToken),
RoleArn: &(model.RoleArn),
TypeVersionId: &(model.TypeVersionId),
TypeName: &(model.TypeName),
DesiredState: &(model.DesiredState),
//ClientToken: &(model.ClientToken),
//RoleArn: &(model.RoleArn),
//TypeVersionId: &(model.TypeVersionId),
}
return &result
}
Expand Down Expand Up @@ -159,9 +159,6 @@ type ProgressEvent struct {
TypeName *string
}

/**
Domain que envia informações para retornar os recursos existentes na conta e região AWS
**/
type RequestList struct {

// The maximum number of results to be returned with a single call. If the number
Expand Down
10 changes: 5 additions & 5 deletions internal/handlers/cloudcontrolhdl/create_dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func BuildResponseCreate(progressEvent *cloudcontrolmdl.ProgressEvent) ResponseC

func BuildRequestCreate(dto BodyCreate) cloudcontrolmdl.Model {
model := cloudcontrolmdl.Model{
ClientToken: dto.ClientToken,
DesiredState: dto.DesiredState,
RoleArn: dto.RoleArn,
TypeName: dto.TypeName,
TypeVersionId: dto.TypeVersionId,
//ClientToken: dto.ClientToken,
DesiredState: dto.DesiredState,
//RoleArn: dto.RoleArn,
TypeName: dto.TypeName,
//TypeVersionId: dto.TypeVersionId,
}
return model
}
7 changes: 6 additions & 1 deletion internal/handlers/cloudcontrolhdl/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cloudcontrolhdl
import (
"github.com/gin-gonic/gin"
"github.com/jfonseca85/controlplaneagent/internal/core/service/cloudcontrolsrv"
"github.com/jfonseca85/controlplaneagent/internal/partners/builder"
)

type HTTPHandler struct {
Expand All @@ -19,7 +20,11 @@ func (hdl *HTTPHandler) Create(c *gin.Context) {
body := BodyCreate{}
c.BindJSON(&body)

model := BuildRequestCreate(body)
model := builder.
UmCloudControlModel().
ComDesiredState(body.DesiredState).
ComTypeName(body.TypeName).
Agora()

resource, err := hdl.cloudcontrolService.Create(model)

Expand Down
40 changes: 40 additions & 0 deletions internal/partners/builder/cloudcontrolModel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package builder

import "github.com/jfonseca85/controlplaneagent/internal/core/domain/cloudcontrolmdl"

type newCloudControlModel struct {
model cloudcontrolmdl.Model
}

func UmCloudControlModel() *newCloudControlModel {
return &newCloudControlModel{}
}

func (c *newCloudControlModel) ComDesiredState(desiredState string) *newCloudControlModel {
c.model.DesiredState = desiredState
return c
}

func (c *newCloudControlModel) ComTypeName(typeName string) *newCloudControlModel {
c.model.TypeName = typeName
return c
}

func (c *newCloudControlModel) ComClientToken(clientToken string) *newCloudControlModel {
c.model.ClientToken = clientToken
return c
}

func (c *newCloudControlModel) ComRoleArn(roleArn string) *newCloudControlModel {
c.model.RoleArn = roleArn
return c
}

func (c *newCloudControlModel) ComTypeVersionId(typeVersionId string) *newCloudControlModel {
c.model.TypeVersionId = typeVersionId
return c
}

func (c *newCloudControlModel) Agora() cloudcontrolmdl.Model {
return c.model
}

0 comments on commit 3e947be

Please sign in to comment.