-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pipecd builtin tags to ECS resources #4140
Changes from 23 commits
c006e82
13fc5bc
a973d11
ca0a60d
b2ce287
c2a85d1
9a9ee5b
74c29dc
9643e01
b072278
09a423a
33831eb
1297a75
c4ae0f5
5882609
14954a7
9b8a215
17697c3
defc1ba
d517e33
c7970b4
6669ad1
9833e37
94c3ba1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,13 +19,22 @@ import ( | |
"path/filepath" | ||
"sync" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/service/ecs/types" | ||
"go.uber.org/zap" | ||
"golang.org/x/sync/singleflight" | ||
|
||
"github.com/pipe-cd/pipecd/pkg/config" | ||
) | ||
|
||
const ( | ||
LabelManagedBy string = "pipecd-dev-managed-by" // Always be piped. | ||
LabelPiped string = "pipecd-dev-piped" // The id of piped handling this application. | ||
LabelApplication string = "pipecd-dev-application" // The application this resource belongs to. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add more builtin tags for ECS resources. For instant, in case of CloudRun, we have as below I think we should also have: TagManagedBy (value will be piped in all cases), LabelPiped, LabelCommitHash as the PipeCD builtin tags for ECS resources. |
||
LabelCommitHash string = "pipecd-dev-commit-hash" // Hash value of the deployed commit. | ||
ManagedByPiped string = "piped" | ||
) | ||
|
||
// Client is wrapper of ECS client. | ||
type Client interface { | ||
ECS | ||
|
@@ -37,11 +46,12 @@ type ECS interface { | |
CreateService(ctx context.Context, service types.Service) (*types.Service, error) | ||
UpdateService(ctx context.Context, service types.Service) (*types.Service, error) | ||
RegisterTaskDefinition(ctx context.Context, taskDefinition types.TaskDefinition) (*types.TaskDefinition, error) | ||
RunTask(ctx context.Context, taskDefinition types.TaskDefinition, clusterArn string, launchType string, awsVpcConfiguration *config.ECSVpcConfiguration) error | ||
RunTask(ctx context.Context, taskDefinition types.TaskDefinition, clusterArn string, launchType string, awsVpcConfiguration *config.ECSVpcConfiguration, tags []types.Tag) error | ||
GetPrimaryTaskSet(ctx context.Context, service types.Service) (*types.TaskSet, error) | ||
CreateTaskSet(ctx context.Context, service types.Service, taskDefinition types.TaskDefinition, targetGroup *types.LoadBalancer, scale int) (*types.TaskSet, error) | ||
DeleteTaskSet(ctx context.Context, service types.Service, taskSetArn string) error | ||
UpdateServicePrimaryTaskSet(ctx context.Context, service types.Service, taskSet types.TaskSet) (*types.TaskSet, error) | ||
TagResource(ctx context.Context, resourceArn string, tags []types.Tag) error | ||
} | ||
|
||
type ELB interface { | ||
|
@@ -109,3 +119,11 @@ var defaultRegistry = ®istry{ | |
func DefaultRegistry() Registry { | ||
return defaultRegistry | ||
} | ||
|
||
func MakeTags(tags map[string]string) []types.Tag { | ||
resourceTags := make([]types.Tag, 0, len(tags)) | ||
for key, value := range tags { | ||
resourceTags = append(resourceTags, types.Tag{Key: aws.String(key), Value: aws.String(value)}) | ||
} | ||
return resourceTags | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed this part. I think we should always propagate the tags from the service to its tasks due to tags contains out builtin tags as well. So it's better to set the value to CreateServiceInput.PropagateTags directly in CreateService method. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
I think we should always propagate tags from the service to its tasks.
So, set the value directly to CreateServiceInput.PropagateTags in the CreateService method.