Closed rifelpet closed 6 years ago
Hey @rifelpet, thanks for the report.
The problem lies with the Diffy gem. The diff
command it constructs includes an argument -U 5
(indicating we want to include 5
lines of context). The diff
that ships with the Alpine Docker image in question doesn't handle these arguments correctly:
diff: invalid number ' 5'
The solution to this is in an open PR on the project. I would encourage you to reach out to the maintainer of that project to fix!
I'm going to close this as it is an issue outside of our control, and seems like a nuanced enough situation to not warrant significant effort on our part to fix. Thanks!
@sds Thanks for looking into this! Installing a non-busybox diff
with apk add --no-cache diffutils
fixed the problem for me and is a sufficient workaround until that PR gets merged.
$ docker run -it --rm ruby:2.3-alpine sh
/ # gem install -q terraform_landscape -v 0.1.17
Successfully installed colorize-0.8.1
Successfully installed highline-1.7.10
Successfully installed commander-4.4.4
Successfully installed diffy-3.2.0
Successfully installed polyglot-0.3.5
Successfully installed treetop-1.6.10
Successfully installed terraform_landscape-0.1.17
7 gems installed
/ # cat << EOF | landscape
> ~ aws_iam_role.myrole
> assume_role_policy: "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::1234567890:root\"},\"Action\":\"sts:AssumeRole\"
}]}" => "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"sts:AssumeRole\",\n \"Principal\"
: {\n \"AWS\": [\n \"arn:aws:iam::1234567890:root\",\n \"arn:aws:iam::2345678901:root\"\n ],\n \"Service\": [\n \"lambda.amazonaws.com\",\
n \"ec2.amazonaws.com\"\n ]\n }\n }\n ]\n}"
> EOF
~ aws_iam_role.myrole
assume_role_policy:
/ # apk add --no-cache diffutils
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/1) Installing diffutils (3.3-r0)
Executing busybox-1.24.2-r14.trigger
OK: 22 MiB in 30 packages
/ # cat << EOF | landscape
> ~ aws_iam_role.myrole
> assume_role_policy: "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::1234567890:root\"},\"Action\":\"sts:AssumeRole\"
}]}" => "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"sts:AssumeRole\",\n \"Principal\"
: {\n \"AWS\": [\n \"arn:aws:iam::1234567890:root\",\n \"arn:aws:iam::2345678901:root\"\n ],\n \"Service\": [\n \"lambda.amazonaws.com\",\
n \"ec2.amazonaws.com\"\n ]\n }\n }\n ]\n}"
> EOF
~ aws_iam_role.myrole
assume_role_policy: {
"Version": "2012-10-17",
"Statement": [
{
+ "Sid": "",
"Effect": "Allow",
+ "Action": "sts:AssumeRole",
"Principal": {
- "AWS": "arn:aws:iam::1234567890:root"
- },
- "Action": "sts:AssumeRole"
+ "AWS": [
+ "arn:aws:iam::1234567890:root",
+ "arn:aws:iam::2345678901:root"
+ ],
+ "Service": [
+ "lambda.amazonaws.com",
+ "ec2.amazonaws.com"
+ ]
+ }
}
]
}
I'm seeing a bizarre issue with landscape on the official ruby alpine docker image but not the ruby debian docker image. The JSON diffs are blank. gem versions are otherwise identical so I'm not sure exactly why this is happening
Alpine:
Debian:
You can copy that
cat << EOF
heredoc yourself to try it out. Any idea what is causing this?