-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Day 100/100 commits -🎖️⭐️ THE LAST DAY OF CHALLENGE🎖️⭐️ store informa…
…tion about apply
- Loading branch information
1 parent
7ec8646
commit ae9e443
Showing
30 changed files
with
545 additions
and
118 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
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
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
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
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,96 @@ | ||
package aggregates | ||
|
||
import ( | ||
"github.com/google/uuid" | ||
"labraboard/internal/entities" | ||
"labraboard/internal/valueobjects/iac" | ||
"time" | ||
) | ||
|
||
// todo design -> it should be combined somehow with IacPlan | ||
|
||
type IacDeployment struct { | ||
id uuid.UUID | ||
planId uuid.UUID | ||
projectId uuid.UUID | ||
deploymentType IaCDeploymentType | ||
startedTime time.Time | ||
deployedTime time.Time | ||
changes []iac.ChangesIac | ||
changeSummary iac.ChangeSummaryIac | ||
outputs []iac.Output | ||
} | ||
|
||
func NewIacDeployment(id uuid.UUID, planId uuid.UUID, projectId uuid.UUID, deploymentType IaCDeploymentType) *IacDeployment { | ||
return &IacDeployment{ | ||
id: id, | ||
planId: planId, | ||
projectId: projectId, | ||
deploymentType: deploymentType, | ||
startedTime: time.Now().UTC(), | ||
changes: make([]iac.ChangesIac, 0), | ||
outputs: make([]iac.Output, 0), | ||
} | ||
} | ||
|
||
func NewIacDeploymentExplicit(deploymentId uuid.UUID, planId uuid.UUID, projectId uuid.UUID, startedTime time.Time, deployedTime time.Time, deployedType string, changes []iac.ChangesIac, summary iac.ChangeSummaryIac, outputs []iac.Output) *IacDeployment { | ||
return &IacDeployment{ | ||
id: deploymentId, | ||
planId: planId, | ||
projectId: projectId, | ||
deploymentType: IaCDeploymentType(deployedType), | ||
startedTime: startedTime, | ||
deployedTime: deployedTime, | ||
changes: changes, | ||
changeSummary: summary, | ||
outputs: outputs, | ||
} | ||
} | ||
|
||
// GetID returns the Iac root entity ID | ||
func (deployment *IacDeployment) GetID() uuid.UUID { | ||
return deployment.id | ||
} | ||
|
||
func (deployment *IacDeployment) FinishDeployment(plans ...entities.IacTerraformOutputJson) { | ||
var changes []iac.ChangesIac | ||
deployment.deployedTime = time.Now().UTC() | ||
for _, p := range plans { | ||
if p.Type == entities.Version { | ||
continue | ||
} | ||
|
||
if p.Change == emptyPlanChange { | ||
|
||
if p.SummaryChanges == emptySummaryChange { | ||
continue | ||
} | ||
deployment.changeSummary = iac.ChangeSummaryIac{ | ||
Add: p.SummaryChanges.Add, | ||
Change: p.SummaryChanges.Change, | ||
Remove: p.SummaryChanges.Remove, | ||
} | ||
|
||
} else if p.Outputs != nil && len(p.Outputs) != 0 { | ||
for key, value := range p.Outputs { | ||
deployment.outputs = append(deployment.outputs, iac.Output{ | ||
Name: key, | ||
Sensitive: value.Sensitive, | ||
Type: value.Type, | ||
Value: value.Value, | ||
}) | ||
} | ||
} else { | ||
planner := newChangeIacPlanner(p.Change.Resource.ResourceType, p.Change.Resource.ResourceName, p.Change.Resource.Provider, iac.PlanTypeAction(p.Change.Action)) | ||
deployment.changes = append(changes, *planner) | ||
} | ||
} | ||
} | ||
|
||
func (deployment *IacDeployment) Composite() ([]iac.ChangesIac, iac.ChangeSummaryIac, []iac.Output) { | ||
return deployment.changes, deployment.changeSummary, deployment.outputs | ||
} | ||
|
||
func (deployment *IacDeployment) GetMetadata() (deploymentId uuid.UUID, planId uuid.UUID, projectId uuid.UUID, startedTime time.Time, deployedTime time.Time, deployedType string) { | ||
return deployment.id, deployment.planId, deployment.projectId, deployment.startedTime, deployment.deployedTime, string(deployment.deploymentType) | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,51 @@ | ||
package entities | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
type IacPlatformType string | ||
|
||
var ( | ||
Version IacPlatformType | ||
PlannedChange IacPlatformType | ||
ChangeSummary IacPlatformType | ||
) | ||
|
||
type IacTerraformOutputJson struct { | ||
Message string `json:"@message"` | ||
Module string `json:"@module"` | ||
Timestamp time.Time `json:"@timestamp"` | ||
Type IacPlatformType `json:"type"` | ||
Change IacTerraformChangeJson `json:"change"` | ||
SummaryChanges IacTerraformSummaryChangesJson `json:"changes"` | ||
Outputs map[string]IacTerraformOutputValue `json:"outputs"` | ||
} | ||
|
||
type IacTerraformChangeJson struct { | ||
Resource IacTerraformChangeResourceJson `json:"resource"` | ||
Action string `json:"action"` | ||
} | ||
|
||
type IacTerraformChangeResourceJson struct { | ||
Addr string `json:"addr"` | ||
Module string `json:"module"` | ||
Resource string `json:"resource"` | ||
Provider string `json:"implied_provider"` | ||
ResourceType string `json:"resource_type"` | ||
ResourceName string `json:"resource_name"` | ||
ResourceKey string `json:"resource_key"` | ||
} | ||
|
||
type IacTerraformSummaryChangesJson struct { | ||
Add int `json:"add"` | ||
Change int `json:"change"` | ||
Remove int `json:"remove"` | ||
Operation string `json:"operation"` | ||
} | ||
|
||
type IacTerraformOutputValue struct { | ||
Sensitive bool `json:"sensitive"` | ||
Type string `json:"type"` | ||
Value string `json:"value"` | ||
} |
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
Oops, something went wrong.