Skip to content
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

refactor: split packages #85

Merged
merged 48 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
43c18b4
wip
keroxp Jun 25, 2024
7da512e
Merge branch 'main' into feat-registry-test
keroxp Jun 27, 2024
cc3e627
w
keroxp Jun 27, 2024
903eff1
w
keroxp Jun 27, 2024
78cecbd
wip
keroxp Jun 27, 2024
c23f33b
Delete common.go
keroxp Jun 27, 2024
fba195a
wip
keroxp Jun 27, 2024
b14e30e
wip
keroxp Jun 27, 2024
010efae
wip
keroxp Jun 27, 2024
76ea966
wip
keroxp Jun 28, 2024
d7e82da
wip
keroxp Jun 28, 2024
5b29e1b
a
keroxp Jun 28, 2024
1e99755
wip
keroxp Jun 28, 2024
5e9296f
add tests
keroxp Jul 1, 2024
a8cdd70
add tests
keroxp Jul 1, 2024
fca8f4a
Update timeout_test.go
keroxp Jul 1, 2024
ad6eb7f
add test
keroxp Jul 1, 2024
9e99624
add tests
keroxp Jul 1, 2024
e9d44e4
di
keroxp Jul 1, 2024
d434547
add tests
keroxp Jul 1, 2024
262122e
drop timeout.Manager
keroxp Jul 2, 2024
b9c2c92
a
keroxp Jul 2, 2024
bf1f1b7
drop srv features
keroxp Jul 2, 2024
bfd3b71
a
keroxp Jul 2, 2024
810cffa
rename
keroxp Jul 2, 2024
3172b6e
add test
keroxp Jul 2, 2024
730399f
Update alb_task_test.go
keroxp Jul 3, 2024
ef4755e
add tests
keroxp Jul 3, 2024
5b7295c
add tests
keroxp Jul 3, 2024
8140df1
Update timeout_test.go
keroxp Jul 3, 2024
7a73ae0
Update simple_task_test.go
keroxp Jul 3, 2024
f51a5a3
test test test
keroxp Jul 3, 2024
4c3761e
test
keroxp Jul 3, 2024
305c2f2
a
keroxp Jul 3, 2024
14d22d7
test
keroxp Jul 3, 2024
be89a35
test
keroxp Jul 4, 2024
5a13995
a
keroxp Jul 4, 2024
aa7ad37
test
keroxp Jul 4, 2024
9f18e7b
test
keroxp Jul 4, 2024
382bfbb
add tests
keroxp Jul 4, 2024
7481c34
test
keroxp Jul 4, 2024
88b20b8
removed unused ecs api
keroxp Jul 4, 2024
53dd2b1
test
keroxp Jul 4, 2024
1afb781
test
keroxp Jul 4, 2024
f55317b
Update alb_task_test.go
keroxp Jul 8, 2024
436391b
tests
keroxp Jul 8, 2024
b6f9c45
PR
keroxp Jul 9, 2024
65afc07
PR
keroxp Jul 10, 2024
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: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@ push-test-container: test-container
docker push loilodev/http-server:latest
version:
go run cli/cage/main.go -v | cut -f 3 -d ' '
mocks: mocks/mock_awsiface/iface.go mocks/mock_cage/iface.go mocks/mock_upgrade/upgrade.go
mocks: mocks/mock_awsiface/iface.go \
mocks/mock_types/iface.go \
mocks/mock_upgrade/upgrade.go \
mocks/mock_task/task.go \
mocks/mock_taskset/taskset.go \
mocks/mock_task/factory.go \
mocks/mock_rollout/executor.go
mocks/mock_awsiface/iface.go: awsiface/iface.go
$(MOCKGEN) -source=./awsiface/iface.go > mocks/mock_awsiface/iface.go
mocks/mock_cage/iface.go: cage.go
$(MOCKGEN) -source=./cage.go > mocks/mock_cage/cage.go
mocks/mock_types/iface.go: types/iface.go
$(MOCKGEN) -source=./types/iface.go > mocks/mock_types/iface.go
mocks/mock_upgrade/upgrade.go: cli/cage/upgrade/upgrade.go
$(MOCKGEN) -source=./cli/cage/upgrade/upgrade.go > mocks/mock_upgrade/upgrade.go
mocks/mock_task/task.go: task/task.go
$(MOCKGEN) -source=./task/task.go > mocks/mock_task/task.go
mocks/mock_taskset/taskset.go: taskset/taskset.go
$(MOCKGEN) -source=./taskset/taskset.go > mocks/mock_taskset/taskset.go
mocks/mock_task/factory.go: task/factory.go
$(MOCKGEN) -source=./task/factory.go > mocks/mock_task/factory.go
mocks/mock_rollout/executor.go: rollout/executor.go
$(MOCKGEN) -source=./rollout/executor.go > mocks/mock_rollout/executor.go
.PHONY: mocks
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ By default, `cage rollout` will only update the task definition of the service.
"ecs:ListTasks",
"ecs:RunTask",
"ecs:StopTask",
"ecs:ListAttributes",
"ecs:PutAttributes",
"ecs:DescribeTaskDefinition"
],
"Resource": "*"
Expand Down
2 changes: 0 additions & 2 deletions awsiface/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ type (
ListTasks(ctx context.Context, params *ecs.ListTasksInput, optFns ...func(*ecs.Options)) (*ecs.ListTasksOutput, error)
RunTask(ctx context.Context, params *ecs.RunTaskInput, optFns ...func(*ecs.Options)) (*ecs.RunTaskOutput, error)
StopTask(ctx context.Context, params *ecs.StopTaskInput, optFns ...func(*ecs.Options)) (*ecs.StopTaskOutput, error)
ListAttributes(ctx context.Context, params *ecs.ListAttributesInput, optFns ...func(*ecs.Options)) (*ecs.ListAttributesOutput, error)
PutAttributes(ctx context.Context, params *ecs.PutAttributesInput, optFns ...func(*ecs.Options)) (*ecs.PutAttributesOutput, error)
DescribeTaskDefinition(ctx context.Context, params *ecs.DescribeTaskDefinitionInput, optFns ...func(*ecs.Options)) (*ecs.DescribeTaskDefinitionOutput, error)
}
AlbClient interface {
Expand Down
50 changes: 5 additions & 45 deletions cage.go
Original file line number Diff line number Diff line change
@@ -1,54 +1,14 @@
package cage

import (
"context"
"time"

"github.com/loilo-inc/canarycage/awsiface"
"github.com/loilo-inc/canarycage/timeout"
"github.com/loilo-inc/canarycage/types"
"github.com/loilo-inc/logos/di"
)

type Cage interface {
Up(ctx context.Context) (*UpResult, error)
Run(ctx context.Context, input *RunInput) (*RunResult, error)
RollOut(ctx context.Context, input *RollOutInput) (*RollOutResult, error)
}

type Time interface {
Now() time.Time
NewTimer(time.Duration) *time.Timer
}

type cage struct {
*Input
Timeout timeout.Manager
}

type Input struct {
Env *Envars
Ecs awsiface.EcsClient
Alb awsiface.AlbClient
Ec2 awsiface.Ec2Client
Time Time
di *di.D
}

func NewCage(input *Input) Cage {
if input.Time == nil {
input.Time = &timeImpl{}
}
taskRunningWait := (time.Duration)(input.Env.CanaryTaskRunningWait) * time.Second
taskHealthCheckWait := (time.Duration)(input.Env.CanaryTaskHealthCheckWait) * time.Second
taskStoppedWait := (time.Duration)(input.Env.CanaryTaskStoppedWait) * time.Second
serviceStableWait := (time.Duration)(input.Env.ServiceStableWait) * time.Second
return &cage{
Input: input,
Timeout: timeout.NewManager(
15*time.Minute,
&timeout.Input{
TaskRunningWait: taskRunningWait,
TaskHealthCheckWait: taskHealthCheckWait,
TaskStoppedWait: taskStoppedWait,
ServiceStableWait: serviceStableWait,
}),
}
func NewCage(di *di.D) types.Cage {
return &cage{di}
}
Loading