feat(ecs): add basic ECS service implementation#206
Merged
Conversation
Implement basic ECS service with the following APIs: - CreateCluster, DeleteCluster, DescribeClusters, ListClusters - RegisterTaskDefinition, DeregisterTaskDefinition - RunTask, StopTask, DescribeTasks - CreateService, DeleteService, UpdateService Add in-memory storage implementation with cluster, task definition, task, and service management. Implement JSON protocol dispatcher for AWS JSON 1.1 protocol. Add integration tests for all implemented APIs. Closes #14
- Add package comment to handlers.go - Rename ECSService to ServiceResource to avoid stuttering - Add status constants and use them throughout - Refactor RunTask function to reduce length (funlen) - Fix rangeValCopy by using index instead of value - Fix prealloc by preallocating slice capacity - Use range over int syntax for loop modernization
Add the ECS service import to cmd/awsim/main.go so that the ECS service is registered via init() when the server starts. This fixes the integration test failure where the JSON protocol dispatcher could not find the AmazonEC2ContainerServiceV20141113 service.
- Add JSON tags to all data model structs (Cluster, TaskDefinition, Task, Container, ServiceResource, Deployment, Tag, etc.) to ensure proper serialization for AWS SDK compatibility - Fix DeleteService to return "DRAINING" status instead of "INACTIVE" to match AWS ECS behavior
- Add custom Timestamp type that marshals to Unix epoch seconds - AWS SDK expects timestamps as floating-point numbers, not RFC3339 strings - Update Task and Deployment structs to use Timestamp type - Add newTimestamp() helper function in storage - Fix bindIP JSON tag to bindIp for tagliatelle linter
b49d7d2 to
885378d
Compare
Contributor
📊 Integration Test Coverage ReportTotal Coverage: 65.0% |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements basic ECS (Elastic Container Service) service support for awsim.
Implemented APIs
Cluster Operations
CreateCluster- Create a new ECS clusterDeleteCluster- Delete an existing clusterDescribeClusters- Describe one or more clustersListClusters- List all clustersTask Definition Operations
RegisterTaskDefinition- Register a new task definitionDeregisterTaskDefinition- Deregister a task definitionTask Operations
RunTask- Run tasks on a clusterStopTask- Stop a running taskDescribeTasks- Describe one or more tasksService Operations
CreateService- Create a new ECS serviceDeleteService- Delete an existing serviceUpdateService- Update service configurationImplementation Details
AmazonEC2ContainerServiceV20141113Changes
internal/service/ecs/service.go- Service registration and JSONProtocolService implementationinternal/service/ecs/handlers.go- DispatchAction and 12 handler implementationsinternal/service/ecs/storage.go- Storage interface and MemoryStorage implementationinternal/service/ecs/types.go- Complete type definitions for requests/responsestest/integration/ecs_test.go- Integration tests for all APIsTesting
Checklist
Closes #14