From f73f79af616b039a2fdde0f6802e72b764a91d49 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 20 Aug 2023 09:30:19 +0100 Subject: [PATCH 1/4] add support for dynamic blocks and modifying as attribute for autoscaling is tag not tags --- .github/workflows/codeql-analysis.yml | 6 +- src/data.go | 20 +++++- .../autoscaling/aws_autoscaling_group.json | 46 ++++++------- src/scan.go | 3 + src/scan_test.go | 64 ++++++++++++++++++- src/testdata/scan/examples/dynamic/dynamic.tf | 41 ++++++++++++ 6 files changed, 150 insertions(+), 30 deletions(-) create mode 100644 src/testdata/scan/examples/dynamic/dynamic.tf diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1558ec84..34c7ee0f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,7 +43,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@cdcdbb579706841c47f7063dda365e292e5cad7a # codeql-bundle-v2.13.4 + uses: github/codeql-action/init@7b6664fa89524ee6e3c3e9749402d5afd69b3cd8 # codeql-bundle-v2.14.1 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -57,7 +57,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@cdcdbb579706841c47f7063dda365e292e5cad7a # codeql-bundle-v2.13.4 + uses: github/codeql-action/autobuild@7b6664fa89524ee6e3c3e9749402d5afd69b3cd8 # codeql-bundle-v2.14.1 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -70,4 +70,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@cdcdbb579706841c47f7063dda365e292e5cad7a # codeql-bundle-v2.13.4 + uses: github/codeql-action/analyze@7b6664fa89524ee6e3c3e9749402d5afd69b3cd8 # codeql-bundle-v2.14.1 diff --git a/src/data.go b/src/data.go index 4710a317..f645a0c2 100644 --- a/src/data.go +++ b/src/data.go @@ -159,13 +159,26 @@ func GetBlockAttributes(attributes []string, block *hclsyntax.Block) []string { for _, attribute := range block.Body.Attributes { attributes = append(attributes, attribute.Name) } + for _, block := range block.Body.Blocks { // Also add in block names - if block.Type != "resource" { - attributes = append(attributes, block.Type) + + switch block.Type { + case "dynamic": + { + attributes = append(attributes, block.Labels...) + } + case "resource": + { + //do nothing + } + default: + { + attributes = append(attributes, block.Type) + attributes = GetBlockAttributes(attributes, block) + } } - attributes = GetBlockAttributes(attributes, block) } return attributes @@ -174,6 +187,7 @@ func GetBlockAttributes(attributes []string, block *hclsyntax.Block) []string { // GetPermission determines the IAM permissions required and returns a list of permission func GetPermission(result ResourceV2) (Sorted, error) { var err error + var myPermission Sorted switch result.Provider { diff --git a/src/mapping/aws/resource/autoscaling/aws_autoscaling_group.json b/src/mapping/aws/resource/autoscaling/aws_autoscaling_group.json index 9f4129ef..9c5d8420 100644 --- a/src/mapping/aws/resource/autoscaling/aws_autoscaling_group.json +++ b/src/mapping/aws/resource/autoscaling/aws_autoscaling_group.json @@ -1,23 +1,23 @@ -[ - { - "apply": [ - "autoscaling:CreateAutoScalingGroup", - "autoscaling:DescribeAutoScalingGroups", - "autoscaling:DescribeScalingActivities", - "autoscaling:UpdateAutoScalingGroup", - "autoscaling:DeleteAutoScalingGroup" - ], - "attributes": { - "tags": [ - "autoscaling:CreateOrUpdateTags", - "autoscaling:DeleteTags" - ] - }, - "destroy": [ - "autoscaling:UpdateAutoScalingGroup", - "autoscaling:DeleteAutoScalingGroup" - ], - "modify": [], - "plan": [] - } -] +[ + { + "apply": [ + "autoscaling:CreateAutoScalingGroup", + "autoscaling:DescribeAutoScalingGroups", + "autoscaling:DescribeScalingActivities", + "autoscaling:UpdateAutoScalingGroup", + "autoscaling:DeleteAutoScalingGroup" + ], + "attributes": { + "tag": [ + "autoscaling:CreateOrUpdateTags", + "autoscaling:DeleteTags" + ] + }, + "destroy": [ + "autoscaling:UpdateAutoScalingGroup", + "autoscaling:DeleteAutoScalingGroup" + ], + "modify": [], + "plan": [] + } +] diff --git a/src/scan.go b/src/scan.go index 1bbcdf82..b482603d 100644 --- a/src/scan.go +++ b/src/scan.go @@ -179,6 +179,7 @@ func MakePolicy(dirName string, file *string, init bool) (OutputPolicy, error) { } var resources []ResourceV2 + for _, tfFile := range files { resource, err := GetResources(tfFile, dirName) @@ -191,6 +192,7 @@ func MakePolicy(dirName string, file *string, init bool) (OutputPolicy, error) { resources = append(resources, resource...) } } + var PermissionBag Sorted var newPerms Sorted @@ -212,6 +214,7 @@ func MakePolicy(dirName string, file *string, init bool) (OutputPolicy, error) { if err2 != nil { return Output, err2 } + return Output, nil } diff --git a/src/scan_test.go b/src/scan_test.go index 6e11e8eb..d75a43d7 100644 --- a/src/scan_test.go +++ b/src/scan_test.go @@ -146,6 +146,7 @@ func TestInit(t *testing.T) { } func TestMakePolicy(t *testing.T) { + t.Parallel() type args struct { dirName string file *string @@ -154,6 +155,8 @@ func TestMakePolicy(t *testing.T) { bogus := "testdata/scan/examples/simple/bogus.tf" actual := "testdata/scan/examples/simple/aws_s3_bucket.pike.tf" + dynamic := "testdata/scan/examples/dynamic/dynamic.tf" + //goland:noinspection GoLinter tests := []struct { name string @@ -166,7 +169,50 @@ func TestMakePolicy(t *testing.T) { args{ "testdata/init/nicconf", nil, true, }, - "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"VisualEditor0\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"apigateway:DELETE\",\n \"apigateway:GET\",\n \"apigateway:PATCH\",\n \"apigateway:POST\",\n \"apigateway:PUT\"\n ],\n \"Resource\": [\n \"*\"\n ]\n },\n {\n \"Sid\": \"VisualEditor1\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"application-autoscaling:DeleteScalingPolicy\",\n \"application-autoscaling:DeregisterScalableTarget\",\n \"application-autoscaling:DescribeScalableTargets\",\n \"application-autoscaling:DescribeScalingPolicies\",\n \"application-autoscaling:PutScalingPolicy\",\n \"application-autoscaling:RegisterScalableTarget\"\n ],\n \"Resource\": [\n \"*\"\n ]\n },\n {\n \"Sid\": \"VisualEditor2\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"dynamodb:CreateTable\",\n \"dynamodb:DeleteTable\",\n \"dynamodb:DescribeContinuousBackups\",\n \"dynamodb:DescribeTable\",\n \"dynamodb:DescribeTimeToLive\",\n \"dynamodb:ListTagsOfResource\",\n \"dynamodb:TagResource\",\n \"dynamodb:UntagResource\",\n \"dynamodb:UpdateTable\",\n \"dynamodb:UpdateTimeToLive\"\n ],\n \"Resource\": [\n \"*\"\n ]\n },\n {\n \"Sid\": \"VisualEditor3\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"ec2:DescribeAccountAttributes\"\n ],\n \"Resource\": [\n \"*\"\n ]\n },\n {\n \"Sid\": \"VisualEditor4\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"iam:AttachRolePolicy\",\n \"iam:CreatePolicy\",\n \"iam:CreateRole\",\n \"iam:CreateServiceLinkedRole\",\n \"iam:DeletePolicy\",\n \"iam:DeleteRole\",\n \"iam:DeleteRolePermissionsBoundary\",\n \"iam:DetachRolePolicy\",\n \"iam:GetPolicy\",\n \"iam:GetPolicyVersion\",\n \"iam:GetRole\",\n \"iam:ListAttachedRolePolicies\",\n \"iam:ListInstanceProfilesForRole\",\n \"iam:ListPolicies\",\n \"iam:ListPolicyVersions\",\n \"iam:ListRolePolicies\",\n \"iam:PassRole\",\n \"iam:PutRolePermissionsBoundary\",\n \"iam:TagPolicy\",\n \"iam:TagRole\",\n \"iam:UntagPolicy\",\n \"iam:UpdateRoleDescription\"\n ],\n \"Resource\": [\n \"*\"\n ]\n },\n {\n \"Sid\": \"VisualEditor5\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"lambda:AddPermission\",\n \"lambda:CreateEventSourceMapping\",\n \"lambda:CreateFunction\",\n \"lambda:CreateFunctionUrlConfig\",\n \"lambda:DeleteEventSourceMapping\",\n \"lambda:DeleteFunction\",\n \"lambda:DeleteFunctionEventInvokeConfig\",\n \"lambda:DeleteFunctionUrlConfig\",\n \"lambda:DeleteLayerVersion\",\n \"lambda:DeleteProvisionedConcurrencyConfig\",\n \"lambda:GetEventSourceMapping\",\n \"lambda:GetFunction\",\n \"lambda:GetFunctionCodeSigningConfig\",\n \"lambda:GetFunctionEventInvokeConfig\",\n \"lambda:GetFunctionUrlConfig\",\n \"lambda:GetLayerVersion\",\n \"lambda:GetPolicy\",\n \"lambda:GetProvisionedConcurrencyConfig\",\n \"lambda:ListVersionsByFunction\",\n \"lambda:PublishLayerVersion\",\n \"lambda:PutFunctionEventInvokeConfig\",\n \"lambda:PutProvisionedConcurrencyConfig\",\n \"lambda:RemovePermission\",\n \"lambda:TagResource\",\n \"lambda:UntagResource\",\n \"lambda:UpdateEventSourceMapping\",\n \"lambda:UpdateFunctionEventInvokeConfig\",\n \"lambda:UpdateFunctionUrlConfig\"\n ],\n \"Resource\": [\n \"*\"\n ]\n },\n {\n \"Sid\": \"VisualEditor6\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"logs:AssociateKmsKey\",\n \"logs:CreateLogGroup\",\n \"logs:DeleteLogGroup\",\n \"logs:DeleteRetentionPolicy\",\n \"logs:DescribeLogGroups\",\n \"logs:DisassociateKmsKey\",\n \"logs:ListTagsLogGroup\",\n \"logs:PutRetentionPolicy\",\n \"logs:TagLogGroup\",\n \"logs:UntagLogGroup\"\n ],\n \"Resource\": [\n \"*\"\n ]\n },\n {\n \"Sid\": \"VisualEditor7\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:DeleteObject\",\n \"s3:GetObject\",\n \"s3:GetObjectTagging\",\n \"s3:PutObject\"\n ],\n \"Resource\": [\n \"*\"\n ]\n }\n ]\n}\n", + `{ + "Version": "2012-10-17", + "Statement": [{ + "Sid": "VisualEditor0", + "Effect": "Allow", + "Action": ["apigateway:DELETE", "apigateway:GET", "apigateway:PATCH", "apigateway:POST", "apigateway:PUT"], + "Resource": ["*"] + }, { + "Sid": "VisualEditor1", + "Effect": "Allow", + "Action": ["application-autoscaling:DeleteScalingPolicy", "application-autoscaling:DeregisterScalableTarget", "application-autoscaling:DescribeScalableTargets", "application-autoscaling:DescribeScalingPolicies", "application-autoscaling:PutScalingPolicy", "application-autoscaling:RegisterScalableTarget"], + "Resource": ["*"] + }, { + "Sid": "VisualEditor2", + "Effect": "Allow", + "Action": ["dynamodb:BatchWriteItem", "dynamodb:CreateTable", "dynamodb:CreateTableReplica", "dynamodb:DeleteItem", "dynamodb:DeleteTable", "dynamodb:DeleteTableReplica", "dynamodb:DescribeContinuousBackups", "dynamodb:DescribeTable", "dynamodb:DescribeTimeToLive", "dynamodb:GetItem", "dynamodb:ListTagsOfResource", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:Scan", "dynamodb:TagResource", "dynamodb:UntagResource", "dynamodb:UpdateContinuousBackups", "dynamodb:UpdateItem", "dynamodb:UpdateTable", "dynamodb:UpdateTimeToLive"], + "Resource": ["*"] + }, { + "Sid": "VisualEditor3", + "Effect": "Allow", + "Action": ["ec2:DescribeAccountAttributes"], + "Resource": ["*"] + }, { + "Sid": "VisualEditor4", + "Effect": "Allow", + "Action": ["iam:AttachRolePolicy", "iam:CreatePolicy", "iam:CreateRole", "iam:CreateServiceLinkedRole", "iam:DeletePolicy", "iam:DeleteRole", "iam:DeleteRolePermissionsBoundary", "iam:DetachRolePolicy", "iam:GetPolicy", "iam:GetPolicyVersion", "iam:GetRole", "iam:ListAttachedRolePolicies", "iam:ListInstanceProfilesForRole", "iam:ListPolicies", "iam:ListPolicyVersions", "iam:ListRolePolicies", "iam:PassRole", "iam:PutRolePermissionsBoundary", "iam:TagPolicy", "iam:TagRole", "iam:UntagPolicy", "iam:UpdateRoleDescription"], + "Resource": ["*"] + }, { + "Sid": "VisualEditor5", + "Effect": "Allow", + "Action": ["lambda:AddPermission", "lambda:CreateEventSourceMapping", "lambda:CreateFunction", "lambda:CreateFunctionUrlConfig", "lambda:DeleteEventSourceMapping", "lambda:DeleteFunction", "lambda:DeleteFunctionEventInvokeConfig", "lambda:DeleteFunctionUrlConfig", "lambda:DeleteLayerVersion", "lambda:DeleteProvisionedConcurrencyConfig", "lambda:GetEventSourceMapping", "lambda:GetFunction", "lambda:GetFunctionCodeSigningConfig", "lambda:GetFunctionEventInvokeConfig", "lambda:GetFunctionUrlConfig", "lambda:GetLayerVersion", "lambda:GetPolicy", "lambda:GetProvisionedConcurrencyConfig", "lambda:ListVersionsByFunction", "lambda:PublishLayerVersion", "lambda:PutFunctionEventInvokeConfig", "lambda:PutProvisionedConcurrencyConfig", "lambda:RemovePermission", "lambda:TagResource", "lambda:UntagResource", "lambda:UpdateEventSourceMapping", "lambda:UpdateFunctionEventInvokeConfig", "lambda:UpdateFunctionUrlConfig"], + "Resource": ["*"] + }, { + "Sid": "VisualEditor6", + "Effect": "Allow", + "Action": ["logs:AssociateKmsKey", "logs:CreateLogGroup", "logs:DeleteLogGroup", "logs:DeleteRetentionPolicy", "logs:DescribeLogGroups", "logs:DisassociateKmsKey", "logs:ListTagsLogGroup", "logs:PutRetentionPolicy", "logs:TagLogGroup", "logs:UntagLogGroup"], + "Resource": ["*"] + }, { + "Sid": "VisualEditor7", + "Effect": "Allow", + "Action": ["s3:DeleteObject", "s3:GetObject", "s3:GetObjectTagging", "s3:PutObject"], + "Resource": ["*"] + }] + }`, false, }, { @@ -187,10 +233,26 @@ func TestMakePolicy(t *testing.T) { "", true, }, + { + "dynamic", + args{"", &dynamic, false}, + `{ + "Version": "2012-10-17", + "Statement": [{ + "Sid": "VisualEditor0", + "Effect": "Allow", + "Action": ["autoscaling:CreateAutoScalingGroup", "autoscaling:CreateOrUpdateTags", "autoscaling:DeleteAutoScalingGroup", "autoscaling:DeleteTags", "autoscaling:DescribeAutoScalingGroups", "autoscaling:DescribeScalingActivities", "autoscaling:UpdateAutoScalingGroup"], + "Resource": ["*"] + }] +}`, + false, + }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() got, err := pike.MakePolicy(tt.args.dirName, tt.args.file, tt.args.init) if (err != nil) != tt.wantErr { t.Errorf("MakePolicy() error = %v, wantErr %v", err, tt.wantErr) diff --git a/src/testdata/scan/examples/dynamic/dynamic.tf b/src/testdata/scan/examples/dynamic/dynamic.tf new file mode 100644 index 00000000..7786ee28 --- /dev/null +++ b/src/testdata/scan/examples/dynamic/dynamic.tf @@ -0,0 +1,41 @@ +locals { + standard_tags = { + Repo = "my-asg-repo" + CreatedBy = "Terraform" + Environment = "${var.namespace}-${var.stage}" + } +} + +##################################################### +# ASG Groups +##################################################### +resource "aws_autoscaling_group" "azbuildgroup_win" { + count = var.azure_windows_asg_count + name = var.azure_windows_asg_name + min_size = 1 + max_size = var.azure_windows_asg_max_instances_day + desired_capacity = var.azure_windows_asg_max_instances_day + health_check_grace_period = 30 + health_check_type = "EC2" + force_delete = true + termination_policies = ["OldestInstance"] + vpc_zone_identifier = data.terraform_remote_state.vpc.outputs.private_subnets + wait_for_capacity_timeout = "2m" + metrics_granularity = "1Minute" + launch_template { + id = aws_launch_template.azure_win_template[0].id + version = "$Latest" + } + depends_on = [ + aws_launch_template.azure_win_template[0] + ] + dynamic "tag" { + for_each = local.standard_tags + + content { + key = tag.key + value = tag.value + propagate_at_launch = false + } + } +} From be2bd3e4d55da1a84222994058f295f4a4fc4d41 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 20 Aug 2023 10:47:44 +0100 Subject: [PATCH 2/4] FIX TEST FOR PR --- src/scan_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/scan_test.go b/src/scan_test.go index d75a43d7..74fd9c80 100644 --- a/src/scan_test.go +++ b/src/scan_test.go @@ -1,6 +1,7 @@ package pike_test import ( + "os" "path/filepath" "reflect" "runtime" @@ -114,6 +115,10 @@ func TestInit(t *testing.T) { dirName, _ := filepath.Abs("testdata/init/nicconf") + err := os.RemoveAll(filepath.Join(dirName, ".terraform")) + + log.Print(err) + tests := []struct { name string args args From 4a5f4b1187c8de977abbd19b55ecb2f3305a1f53 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 20 Aug 2023 11:57:52 +0100 Subject: [PATCH 3/4] not parallel --- src/scan_test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/scan_test.go b/src/scan_test.go index 74fd9c80..5bb0545e 100644 --- a/src/scan_test.go +++ b/src/scan_test.go @@ -107,8 +107,6 @@ func Test_stringInSlice(t *testing.T) { } func TestInit(t *testing.T) { - t.Parallel() - type args struct { dirName string } @@ -130,9 +128,7 @@ func TestInit(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { - t.Parallel() got, modules, err := pike.Init(tt.args.dirName) log.Print(modules) if (err != nil) != tt.wantErr { From 76ed4cc53fc25c22798d8c5f13c91aac8274ce11 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Sun, 20 Aug 2023 13:39:09 +0100 Subject: [PATCH 4/4] update version and build --- .github/ISSUE_TEMPLATE/bug_report.md | 82 ++++++++++++++-------------- .github/workflows/pr.yml | 3 + src/scan.go | 7 ++- 3 files changed, 50 insertions(+), 42 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 32059266..13f55594 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,41 +1,41 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: - -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - -- OS: [e.g. iOS] -- Browser [e.g. chrome, safari] -- Version [e.g. 22] - -**Smartphone (please complete the following information):** - -- Device: [e.g. iPhone6] -- OS: [e.g. iOS8.1] -- Browser [e.g. stock browser, safari] -- Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] + +**Smartphone (please complete the following information):** + +- Device: [e.g. iPhone6] +- OS: [e.g. iOS8.1] +- Browser [e.g. stock browser, safari] +- Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3355136d..f3b91237 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -27,6 +27,9 @@ jobs: platform: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: + - uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 + with: + terraform_version: 1.5.4 - name: Checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Install Go diff --git a/src/scan.go b/src/scan.go index b482603d..d15b58ef 100644 --- a/src/scan.go +++ b/src/scan.go @@ -16,7 +16,7 @@ import ( "github.com/rs/zerolog/log" ) -const tfVersion = "1.3.5" +const tfVersion = "1.5.4" // Scan looks for resources in a given directory func Scan(dirName string, output string, file *string, init bool, write bool) error { @@ -41,11 +41,13 @@ func Scan(dirName string, output string, file *string, init bool, write bool) er func WriteOutput(OutPolicy OutputPolicy, output, location string) error { newPath, _ := filepath.Abs(location + "/.pike") err := os.MkdirAll(newPath, os.ModePerm) + if err != nil { return err } var outFile string + d1 := []byte(OutPolicy.AsString(output)) switch strings.ToLower(output) { @@ -98,10 +100,12 @@ func Init(dirName string) (*string, []string, error) { //filter var found []string + for _, module := range modules { if module.Name() == "modules.json" || module.Name() == ".DS_Store" { continue } + found = append(found, module.Name()) } @@ -131,6 +135,7 @@ func LocateTerraform() (string, error) { return "", err } } + return tfPath, nil }