-
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.
Added method giving radix component deployments
- Loading branch information
Showing
12 changed files
with
235 additions
and
40 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,50 @@ | ||
package models | ||
|
||
import ( | ||
"fmt" | ||
radixutils "github.com/equinor/radix-common/utils" | ||
"github.com/equinor/radix-operator/pkg/apis/kube" | ||
v1 "github.com/equinor/radix-operator/pkg/apis/radix/v1" | ||
) | ||
|
||
// ComponentDeploymentSummaryBuilder Builds DTOs | ||
type ComponentDeploymentSummaryBuilder interface { | ||
WithRadixDeployment(*v1.RadixDeployment) ComponentDeploymentSummaryBuilder | ||
WithRadixDeployComponent(component v1.RadixCommonDeployComponent) ComponentDeploymentSummaryBuilder | ||
Build() (*ComponentDeploymentSummary, error) | ||
} | ||
|
||
type componentDeploymentSummaryBuilder struct { | ||
component v1.RadixCommonDeployComponent | ||
radixDeployment *v1.RadixDeployment | ||
} | ||
|
||
// NewComponentDeploymentSummaryBuilder Constructor for application ComponentDeploymentSummaryBuilder | ||
func NewComponentDeploymentSummaryBuilder() ComponentDeploymentSummaryBuilder { | ||
return &componentDeploymentSummaryBuilder{} | ||
} | ||
|
||
// WithRadixDeployComponent With RadixDeployComponent | ||
func (b *componentDeploymentSummaryBuilder) WithRadixDeployComponent(component v1.RadixCommonDeployComponent) ComponentDeploymentSummaryBuilder { | ||
b.component = component | ||
return b | ||
} | ||
|
||
func (b *componentDeploymentSummaryBuilder) WithRadixDeployment(rd *v1.RadixDeployment) ComponentDeploymentSummaryBuilder { | ||
b.radixDeployment = rd | ||
return b | ||
} | ||
|
||
func (b *componentDeploymentSummaryBuilder) Build() (*ComponentDeploymentSummary, error) { | ||
if b.component == nil || b.radixDeployment == nil { | ||
return nil, fmt.Errorf("component or RadixDeployment are empty") | ||
} | ||
return &ComponentDeploymentSummary{ | ||
Name: b.radixDeployment.GetName(), | ||
ComponentName: b.component.GetName(), | ||
ActiveFrom: radixutils.FormatTimestamp(b.radixDeployment.Status.ActiveFrom.Time), | ||
ActiveTo: radixutils.FormatTimestamp(b.radixDeployment.Status.ActiveTo.Time), | ||
Condition: string(b.radixDeployment.Status.Condition), | ||
GitCommitHash: b.radixDeployment.GetLabels()[kube.RadixCommitLabel], | ||
}, nil | ||
} |
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
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.