-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ECS] Fix remove all previous active tasksets on QuickSync (#4600)
* Remove previous ACTIVE tasksets if present on quicksync Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com> * Remove GetPrimaryTaskSet interface Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com> --------- Signed-off-by: khanhtc1202 <khanhtc1202@gmail.com>
- Loading branch information
1 parent
2b2940f
commit 8ca8084
Showing
5 changed files
with
96 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 The PipeCD Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package ecs | ||
|
||
import "github.com/aws/aws-sdk-go-v2/service/ecs/types" | ||
|
||
func IsPipeCDManagedTaskSet(ts *types.TaskSet) bool { | ||
for _, tag := range ts.Tags { | ||
if *tag.Key == LabelManagedBy && *tag.Value == ManagedByPiped { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
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,61 @@ | ||
// Copyright 2023 The PipeCD Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package ecs | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/ecs/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIsPipeCDManagedTaskSet(t *testing.T) { | ||
t.Parallel() | ||
|
||
testcases := []struct { | ||
name string | ||
ts *types.TaskSet | ||
expected bool | ||
}{ | ||
{ | ||
name: "managed by piped", | ||
ts: &types.TaskSet{Tags: []types.Tag{ | ||
{Key: aws.String(LabelManagedBy), Value: aws.String(ManagedByPiped)}, | ||
}}, | ||
expected: true, | ||
}, | ||
{ | ||
name: "nil tags", | ||
ts: &types.TaskSet{}, | ||
expected: false, | ||
}, | ||
{ | ||
name: "not managed by piped", | ||
ts: &types.TaskSet{Tags: []types.Tag{ | ||
{Key: aws.String(LabelManagedBy), Value: aws.String("other")}, | ||
{Key: aws.String("hoge"), Value: aws.String("fuga")}, | ||
}}, | ||
expected: false, | ||
}, | ||
} | ||
|
||
for _, tc := range testcases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := IsPipeCDManagedTaskSet(tc.ts) | ||
assert.Equal(t, tc.expected, got) | ||
}) | ||
} | ||
} |