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 regexp for bash userdata #8

Closed
wants to merge 1 commit into from

Conversation

angel-manuel
Copy link
Contributor

Some may use user-data scripts like the following one.
Don't capture the quotes with the regexp

echo "ECS_CLUSTER=core-dev" >> /etc/ecs/ecs.config

Some may use user-data scripts like the following one.
Don't capture the quotes with the regexp

```
echo "ECS_CLUSTER=core-dev" >> /etc/ecs/ecs.config
```
@taraspos
Copy link
Member

@angel-manuel thanks for your contribution.

I know there are no tests for the lambda yet, but this like a good place to start adding them.
Could you do that?

Basically, move following lines into a separate function:

ecs-drain-lambda/ecs.go

Lines 177 to 182 in c7c20f8

// Using RegExp to get actual ECS Cluster name from UserData string
m := ecsRegExp.FindAllStringSubmatch(string(decodedUserData), -1)
if len(m) == 0 || len(m[0]) < 2 {
fmt.Printf("UserData:\n%s", string(decodedUserData))
return "", ErrMissingECSClusterInUserData
}

And add tests with a couple of different UserData examples.

@taraspos
Copy link
Member

Merged in #9

@taraspos taraspos closed this Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants