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

fix typo #72

Merged
merged 1 commit into from
Aug 20, 2023
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
22 changes: 11 additions & 11 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestLoadConfig(t *testing.T) {
pathes := []string{"testdata/sample.yaml", "testdata/sample.json", "testdata/sample.jsonnet"}
paths := []string{"testdata/sample.yaml", "testdata/sample.json", "testdata/sample.jsonnet"}
expect := &Config{
Role: "ecsEventsRole",
BaseConfig: &BaseConfig{
Expand All @@ -36,7 +36,7 @@ func TestLoadConfig(t *testing.T) {
AwsVpcConfiguration: &AwsVpcConfiguration{
Subnets: []string{"subnet-01234567", "subnet-12345678"},
SecurityGroups: []string{"sg-11111111", "sg-99999999"},
AssinPublicIP: "ENABLED",
AssignPublicIP: "ENABLED",
},
},
ContainerOverrides: []*ContainerOverride{
Expand Down Expand Up @@ -69,15 +69,15 @@ func TestLoadConfig(t *testing.T) {
dir: "testdata",
}

for _, path := range pathes {
for _, path := range paths {
f, err := os.Open(path)
if err != nil {
t.Fatal(err)
}
defer f.Close()
c, err := LoadConfig(context.Background(), f, "334", path)
if err != nil {
t.Errorf("error shoud be nil, but: %s", err)
t.Errorf("error should be nil, but: %s", err)
}

if !reflect.DeepEqual(c, expect) {
Expand All @@ -96,7 +96,7 @@ func TestLoadConfig_mustEnv(t *testing.T) {

c, err := LoadConfig(context.Background(), f, "335", path)
if err != nil {
t.Errorf("error shoud be nil, but: %s", err)
t.Errorf("error should be nil, but: %s", err)
}

ru := c.GetRuleByName("hoge-task-name")
Expand All @@ -105,7 +105,7 @@ func TestLoadConfig_mustEnv(t *testing.T) {
t.Errorf("error should be occurred but nil")
}
if g, e := err.Error(), "environment variable DUMMY_HOGE_ENV is not defined"; g != e {
t.Errorf("error shoud be %q, but: %q", e, g)
t.Errorf("error should be %q, but: %q", e, g)
}
}

Expand All @@ -119,7 +119,7 @@ func TestLoadConfig_tfstate(t *testing.T) {

c, err := LoadConfig(context.Background(), f, "336", path)
if err != nil {
t.Errorf("error shoud be nil, but: %s", err)
t.Errorf("error should be nil, but: %s", err)
}

if !reflect.DeepEqual(c.Plugins, []*Plugin{
Expand All @@ -131,13 +131,13 @@ func TestLoadConfig_tfstate(t *testing.T) {
as := c.Rules[0].NetworkConfiguration.AwsVpcConfiguration.Subnets
es := []string{"subnet-01234567", "subnet-12345678"}
if !reflect.DeepEqual(as, es) {
t.Errorf("error shoud be %v, but: %v", as, es)
t.Errorf("error should be %v, but: %v", as, es)
}

asg := c.Rules[0].NetworkConfiguration.AwsVpcConfiguration.SecurityGroups
esg := []string{"sg-11111111", "sg-99999999"}
if !reflect.DeepEqual(asg, esg) {
t.Errorf("error shoud be %v, but: %v", asg, esg)
t.Errorf("error should be %v, but: %v", asg, esg)
}
}

Expand All @@ -151,10 +151,10 @@ func TestLoadConfig_undefined(t *testing.T) {

c, err := LoadConfig(context.Background(), f, "337", path)
if err != nil {
t.Errorf("error shoud be nil, but: %s", err)
t.Errorf("error should be nil, but: %s", err)
}

if c.Rules[0].PropagateTags != nil {
t.Errorf("error shoud be nil, but: %v", c.Rules[0].PropagateTags)
t.Errorf("error should be nil, but: %v", c.Rules[0].PropagateTags)
}
}
14 changes: 7 additions & 7 deletions rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Target struct {
PropagateTags *string `yaml:"propagateTags,omitempty" json:"propagateTags,omitempty"`
}

// ContainerOverride overrids container
// ContainerOverride overrides container
type ContainerOverride struct {
Name string `yaml:"name" json:"name"`
Command []string `yaml:"command,flow" json:"command"` // ,flow
Expand Down Expand Up @@ -78,7 +78,7 @@ type NetworkConfiguration struct {
type AwsVpcConfiguration struct {
Subnets []string `yaml:"subnets" json:"subnets"`
SecurityGroups []string `yaml:"security_groups,omitempty" json:"security_groups,omitempty"`
AssinPublicIP string `yaml:"assign_public_ip,omitempty" json:"assign_public_ip,omitempty"`
AssignPublicIP string `yaml:"assign_public_ip,omitempty" json:"assign_public_ip,omitempty"`
}

func (nc *NetworkConfiguration) ecsParameters() *cloudwatchevents.NetworkConfiguration {
Expand All @@ -88,7 +88,7 @@ func (nc *NetworkConfiguration) ecsParameters() *cloudwatchevents.NetworkConfigu
if sgs := nc.AwsVpcConfiguration.SecurityGroups; len(sgs) > 0 {
awsVpcConf.SecurityGroups = aws.StringSlice(sgs)
}
if as := nc.AwsVpcConfiguration.AssinPublicIP; as != "" {
if as := nc.AwsVpcConfiguration.AssignPublicIP; as != "" {
awsVpcConf.AssignPublicIp = aws.String(as)
}
return &cloudwatchevents.NetworkConfiguration{
Expand All @@ -100,7 +100,7 @@ func (nc *NetworkConfiguration) inputParameters() *ecs.NetworkConfiguration {
awsVpcConfiguration := &ecs.AwsVpcConfiguration{
Subnets: aws.StringSlice(nc.AwsVpcConfiguration.Subnets),
}
if as := nc.AwsVpcConfiguration.AssinPublicIP; as != "" {
if as := nc.AwsVpcConfiguration.AssignPublicIP; as != "" {
awsVpcConfiguration.AssignPublicIp = aws.String(as)
}
if sgs := nc.AwsVpcConfiguration.SecurityGroups; len(sgs) > 0 {
Expand Down Expand Up @@ -388,7 +388,7 @@ func (r *Rule) Run(ctx context.Context, sess *session.Session, noWait bool) erro
return err
}
svc := ecs.New(sess, &aws.Config{Region: aws.String(r.Region)})
var contaierOverrides []*ecs.ContainerOverride
var containerOverrides []*ecs.ContainerOverride
for _, co := range r.ContainerOverrides {
var (
kvPairs []*ecs.KeyValuePair
Expand All @@ -403,7 +403,7 @@ func (r *Rule) Run(ctx context.Context, sess *session.Session, noWait bool) erro
for _, v := range co.Command {
command = append(command, aws.String(v))
}
contaierOverrides = append(contaierOverrides, &ecs.ContainerOverride{
containerOverrides = append(containerOverrides, &ecs.ContainerOverride{
Name: aws.String(co.Name),
Environment: kvPairs,
Command: command,
Expand All @@ -423,7 +423,7 @@ func (r *Rule) Run(ctx context.Context, sess *session.Session, noWait bool) erro
Cluster: aws.String(r.Cluster),
TaskDefinition: aws.String(r.taskDefinitionArn(r)),
Overrides: &ecs.TaskOverride{
ContainerOverrides: contaierOverrides,
ContainerOverrides: containerOverrides,
},
Count: aws.Int64(r.taskCount()),
LaunchType: aws.String(r.Target.LaunchType),
Expand Down
2 changes: 1 addition & 1 deletion rule_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (rg *ruleGetter) getRule(ctx context.Context, r *cloudwatchevents.Rule) (*R
AwsVpcConfiguration: &AwsVpcConfiguration{
Subnets: aws.StringValueSlice(nc.AwsvpcConfiguration.Subnets),
SecurityGroups: aws.StringValueSlice(nc.AwsvpcConfiguration.SecurityGroups),
AssinPublicIP: aws.StringValue(nc.AwsvpcConfiguration.AssignPublicIp),
AssignPublicIP: aws.StringValue(nc.AwsvpcConfiguration.AssignPublicIp),
},
}
}
Expand Down
Loading