Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 20 additions & 0 deletions pkg/pullreq/diffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,26 @@ func GetCoveredClusters(
}
}

// In case where someone has used a wildcard, prune clusters that have no changes
// to avoid unexpected applies.
hasWildcards := false

for _, globStr := range selectedClusterGlobStrs {
if strings.Contains(globStr, "*") {
hasWildcards = true
break
}
}

if hasWildcards {
for cluster, paths := range changedClusterPaths {
if len(paths) == 0 {
log.Infof("Removing cluster %s because it has no changes", cluster)
delete(changedClusterPaths, cluster)
}
}
}

log.Infof("Changed cluster paths: %+v", changedClusterPaths)

changedClusters := []*config.ClusterConfig{}
Expand Down
39 changes: 39 additions & 0 deletions pkg/pullreq/diffs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,45 @@ func TestGetCoveredClusters(t *testing.T) {
".",
},
},
{
diffs: []*github.CommitFile{
{
Filename: aws.String("clusters/clustertype/expanded/cluster1/subdir1/file3.yaml"),
},
{
Filename: aws.String("clusters/clustertype/expanded/cluster3/file1.yaml"),
},
},
selectedClusterGlobStrs: []string{
"stage:*",
},
expectedClustersIDs: []string{
"stage:us-west-2:cluster1",
"stage:us-west-2:cluster3",
},
expectedSubpaths: []string{
"subdir1",
".",
},
},
{
diffs: []*github.CommitFile{
{
Filename: aws.String("clusters/clustertype/expanded/cluster1/subdir1/file3.yaml"),
},
},
selectedClusterGlobStrs: []string{
"stage:*",
},
// Cluster 3 is pruned from selection list because it doesn't have any files in the
// git diff.
expectedClustersIDs: []string{
"stage:us-west-2:cluster1",
},
expectedSubpaths: []string{
"subdir1",
},
},
{
diffs: []*github.CommitFile{
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package version

// Version stores the current kubeapply version.
const Version = "0.0.32"
const Version = "0.0.33"