Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pkg/config/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ func (p *PostSync) Validate() error {

// DeploymentChain provides all configurations used to trigger a chain of deployments.
type DeploymentChain struct {
// Nodes provides list of DeploymentChainNodes which contain filters to be used
// ApplicationMatchers provides list of ChainApplicationMatcher which contain filters to be used
// to find applications to deploy as chain node. It's required to not empty.
Nodes []*DeploymentChainNode `json:"applications"`
ApplicationMatchers []*ChainApplicationMatcher `json:"applications"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to use pointer.

// Conditions provides configuration used to determine should the piped in charge in
// the first applications in the chain trigger a whole new deployment chain or not.
// If this field is not set, always trigger a whole new deployment chain when the current
Expand All @@ -564,12 +564,12 @@ type DeploymentChain struct {
}

func (dc *DeploymentChain) Validate() error {
if len(dc.Nodes) == 0 {
if len(dc.ApplicationMatchers) == 0 {
return fmt.Errorf("missing specified applications that will be triggered on this chain of deployment")
}

for _, n := range dc.Nodes {
if err := n.Validate(); err != nil {
for _, m := range dc.ApplicationMatchers {
if err := m.Validate(); err != nil {
return err
}
}
Expand All @@ -583,16 +583,16 @@ func (dc *DeploymentChain) Validate() error {
return nil
}

// DeploymentChainNode provides filters used to find the right applications to trigger
// ChainApplicationMatcher provides filters used to find the right applications to trigger
// as a part of the deployment chain.
type DeploymentChainNode struct {
type ChainApplicationMatcher struct {
AppName string `json:"name"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Name" is enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice point 👍 addressed by 91d35ee

AppKind string `json:"kind"`
AppLabels map[string]string `json:"labels"`
}

func (n *DeploymentChainNode) Validate() error {
hasFilterCond := n.AppName != "" || n.AppKind != "" || len(n.AppLabels) != 0
func (m *ChainApplicationMatcher) Validate() error {
hasFilterCond := m.AppName != "" || m.AppKind != "" || len(m.AppLabels) != 0

if !hasFilterCond {
return fmt.Errorf("at least one of \"name\", \"kind\" or \"labels\" must be set to find applications to deploy")
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func TestGenericPostSyncConfiguration(t *testing.T) {
},
PostSync: &PostSync{
DeploymentChain: &DeploymentChain{
Nodes: []*DeploymentChainNode{
ApplicationMatchers: []*ChainApplicationMatcher{
{
AppName: "app-1",
},
Expand Down