Skip to content

Commit

Permalink
feat(terraform): rework dep types (#9116)
Browse files Browse the repository at this point in the history
Improves the `depType` values returned by the terraform manager.

Closes #8792

BREAKING CHANGE: Values for extracted `depType` in terraform manager have changed, please see the `terraform` manager readme for details.
  • Loading branch information
secustor authored and rarkins committed Apr 22, 2021
1 parent d5d2954 commit c2980e9
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 59 deletions.
87 changes: 46 additions & 41 deletions lib/manager/terraform/__snapshots__/extract.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ Object {
"currentValue": "1.0.1",
"datasource": "helm",
"depName": "redis",
"depType": "helm",
"depType": "helm_release",
"registryUrls": Array [
"https://charts.helm.sh/stable",
],
},
Object {
"datasource": "helm",
"depName": "redis",
"depType": "helm",
"depType": "helm_release",
"registryUrls": Array [
"https://charts.helm.sh/stable",
],
},
Object {
"datasource": "helm",
"depName": "./charts/example",
"depType": "helm",
"depType": "helm_release",
"registryUrls": Array [
undefined,
],
Expand All @@ -33,7 +33,7 @@ Object {
"currentValue": "4.0.1",
"datasource": "helm",
"depName": undefined,
"depType": "helm",
"depType": "helm_release",
"registryUrls": Array [
"https://charts.helm.sh/stable",
],
Expand All @@ -43,7 +43,7 @@ Object {
"currentValue": "5.0.1",
"datasource": "helm",
"depName": "redis",
"depType": "helm",
"depType": "helm_release",
"registryUrls": Array [
"https://charts.helm.sh/stable",
],
Expand All @@ -52,7 +52,7 @@ Object {
"currentValue": "6.0.1",
"datasource": "helm",
"depName": "redis",
"depType": "helm",
"depType": "helm_release",
"registryUrls": Array [
undefined,
],
Expand All @@ -68,86 +68,86 @@ Object {
"currentValue": "v1.0.0",
"datasource": "github-tags",
"depName": "github.com/hashicorp/example",
"depType": "github",
"depType": "module",
"lookupName": "hashicorp/example",
},
Object {
"currentValue": "next",
"datasource": "github-tags",
"depName": "github.com/hashicorp/example",
"depType": "github",
"depType": "module",
"lookupName": "hashicorp/example",
},
Object {
"currentValue": "tfmodule_one-v0.0.9",
"datasource": "github-tags",
"depName": "github.com/githubuser/myrepo",
"depType": "github",
"depType": "module",
"lookupName": "githubuser/myrepo",
},
Object {
"currentValue": "v1.0.0",
"datasource": "github-tags",
"depName": "github.com/hashicorp/example.2.3",
"depType": "github",
"depType": "module",
"lookupName": "hashicorp/example.2.3",
},
Object {
"currentValue": "v1.0.0",
"datasource": "github-tags",
"depName": "github.com/hashicorp/example.2.3",
"depType": "github",
"depType": "module",
"lookupName": "hashicorp/example.2.3",
},
Object {
"currentValue": "0.1.0",
"datasource": "terraform-module",
"depName": "hashicorp/consul/aws",
"depType": "terraform",
"depType": "module",
},
Object {
"currentValue": "v0.1.0",
"datasource": "github-tags",
"depName": "github.com/tieto-cem/terraform-aws-ecs-task-definition",
"depType": "github",
"depType": "module",
"lookupName": "tieto-cem/terraform-aws-ecs-task-definition",
},
Object {
"currentValue": "v0.1.0",
"datasource": "github-tags",
"depName": "github.com/tieto-cem/terraform-aws-ecs-task-definition",
"depType": "github",
"depType": "module",
"lookupName": "tieto-cem/terraform-aws-ecs-task-definition",
},
Object {
"currentValue": "v2.0.0",
"datasource": "github-tags",
"depName": "github.com/hashicorp/example",
"depType": "github",
"depType": "module",
"lookupName": "hashicorp/example",
},
Object {
"datasource": "terraform-module",
"depName": "terraform-aws-modules/security-group/aws",
"depType": "terraform",
"depType": "module",
},
Object {
"currentValue": "<= 2.4.0",
"datasource": "terraform-module",
"depName": "terraform-aws-modules/security-group/aws",
"depType": "terraform",
"depType": "module",
},
Object {
"currentValue": "1.28.3",
"datasource": "terraform-module",
"depName": "particuleio/addons/kubernetes",
"depType": "terraform",
"depType": "module",
},
Object {
"currentValue": "~> 1.1.0",
"datasource": "terraform-module",
"depName": "app.terraform.io/example-corp/k8s-cluster/azurerm",
"depType": "terraform",
"depType": "module",
"registryUrls": Array [
"https://app.terraform.io",
],
Expand All @@ -156,7 +156,7 @@ Object {
"currentValue": "~> 1.1",
"datasource": "terraform-module",
"depName": "app.terraform.io/example-corp/k8s-cluster/azurerm",
"depType": "terraform",
"depType": "module",
"registryUrls": Array [
"https://app.terraform.io",
],
Expand All @@ -165,7 +165,7 @@ Object {
"currentValue": "~~ 1.1",
"datasource": "terraform-module",
"depName": "app.terraform.io/example-corp/k8s-cluster/azurerm",
"depType": "terraform",
"depType": "module",
"registryUrls": Array [
"https://app.terraform.io",
],
Expand All @@ -174,7 +174,7 @@ Object {
"currentValue": ">= 1.0.0, <= 2.0.0",
"datasource": "terraform-module",
"depName": "hashicorp/consul/aws",
"depType": "terraform",
"depType": "module",
},
Object {
"skipReason": "local",
Expand All @@ -186,97 +186,98 @@ Object {
"currentValue": "1.36.1",
"datasource": "terraform-provider",
"depName": "azurerm",
"depType": "terraform",
"depType": "provider",
},
Object {
"currentValue": "=2.4",
"datasource": "terraform-provider",
"depName": "gitlab",
"depType": "terraform",
"depType": "provider",
},
Object {
"currentValue": "=1.3",
"datasource": "terraform-provider",
"depName": "gitlab",
"depType": "terraform",
"depType": "provider",
},
Object {
"datasource": "terraform-provider",
"depName": "helm",
"depType": "terraform",
"depType": "provider",
},
Object {
"currentValue": "V1.9",
"datasource": "terraform-provider",
"depName": "newrelic",
"depType": "terraform",
"depType": "provider",
},
Object {
"currentValue": "v1.0.0",
"datasource": "git-tags",
"depName": "bitbucket.com/hashicorp/example",
"depType": "gitTags",
"depType": "module",
"lookupName": "https://bitbucket.com/hashicorp/example",
},
Object {
"currentValue": "v1.0.0",
"datasource": "git-tags",
"depName": "bitbucket.com/hashicorp/example",
"depType": "gitTags",
"depType": "module",
"lookupName": "https://bitbucket.com/hashicorp/example",
},
Object {
"currentValue": "next",
"datasource": "git-tags",
"depName": "bitbucket.com/hashicorp/example",
"depType": "gitTags",
"depType": "module",
"lookupName": "https://bitbucket.com/hashicorp/example",
},
Object {
"currentValue": "v1.0.1",
"datasource": "git-tags",
"depName": "bitbucket.com/hashicorp/example",
"depType": "gitTags",
"depType": "module",
"lookupName": "https://bitbucket.com/hashicorp/example",
},
Object {
"currentValue": "v1.0.2",
"datasource": "git-tags",
"depName": "bitbucket.com/hashicorp/example",
"depType": "gitTags",
"depType": "module",
"lookupName": "http://bitbucket.com/hashicorp/example",
},
Object {
"currentValue": "v1.0.3",
"datasource": "git-tags",
"depName": "bitbucket.com/hashicorp/example",
"depType": "gitTags",
"depType": "module",
"lookupName": "ssh://[email protected]/hashicorp/example",
},
Object {
"currentValue": ">= 2.7.0",
"datasource": "terraform-provider",
"depName": "aws",
"depType": "terraform",
"depType": "required_provider",
},
Object {
"currentValue": ">= 2.0.0",
"datasource": "terraform-provider",
"depName": "azurerm",
"depType": "terraform",
"depType": "required_provider",
},
Object {
"currentValue": ">= 0.13",
"datasource": "github-tags",
"depName": "hashicorp/terraform",
"depType": "required_version",
"extractVersion": "v(?<version>.*)$",
"lineNumber": 230,
},
Object {
"currentValue": "2.7.2",
"datasource": "terraform-provider",
"depName": "docker",
"depType": "terraform",
"depType": "required_provider",
"registryUrls": Array [
"https://releases.hashicorp.com",
],
Expand All @@ -285,34 +286,34 @@ Object {
"currentValue": "2.7.0",
"datasource": "terraform-provider",
"depName": "aws",
"depType": "terraform",
"depType": "required_provider",
"lookupName": "aws",
},
Object {
"currentValue": "=2.27.0",
"datasource": "terraform-provider",
"depName": "azurerm",
"depType": "terraform",
"depType": "required_provider",
},
Object {
"currentValue": "1.2.4",
"datasource": "terraform-provider",
"depName": "invalid",
"depType": "terraform",
"depType": "required_provider",
"skipReason": "unsupported-url",
},
Object {
"currentValue": "1.2.4",
"datasource": "terraform-provider",
"depName": "helm",
"depType": "terraform",
"depType": "required_provider",
"lookupName": "hashicorp/helm",
},
Object {
"currentValue": ">= 1.0",
"datasource": "terraform-provider",
"depName": "kubernetes",
"depType": "terraform",
"depType": "required_provider",
"lookupName": "hashicorp/kubernetes",
"registryUrls": Array [
"https://terraform.example.com",
Expand All @@ -324,6 +325,7 @@ Object {
"currentValue": "1.7.8",
"datasource": "docker",
"depName": "nginx",
"depType": "docker_image",
"replaceString": "nginx:1.7.8",
},
Object {
Expand All @@ -332,6 +334,7 @@ Object {
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"datasource": "docker",
"depType": "docker_image",
"replaceString": "\${data.docker_registry_image.ubuntu.name}",
"skipReason": "contains-variable",
},
Expand All @@ -341,6 +344,7 @@ Object {
"currentValue": "1.7.8",
"datasource": "docker",
"depName": "nginx",
"depType": "docker_container",
"replaceString": "nginx:1.7.8",
},
Object {
Expand All @@ -352,6 +356,7 @@ Object {
"currentValue": "v1",
"datasource": "docker",
"depName": "repo.mycompany.com:8080/foo-service",
"depType": "docker_service",
"replaceString": "repo.mycompany.com:8080/foo-service:v1",
},
Object {
Expand Down
7 changes: 6 additions & 1 deletion lib/manager/terraform/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
analyzeTerraformProvider,
extractTerraformProvider,
} from './providers';
import { extractTerraformRequiredProviders } from './required-providers';
import {
analyzeTerraformRequiredProvider,
extractTerraformRequiredProviders,
} from './required-providers';
import {
analyseTerraformVersion,
extractTerraformRequiredVersion,
Expand Down Expand Up @@ -98,6 +101,8 @@ export function extractPackageFile(content: string): PackageFile | null {
deps.forEach((dep) => {
switch (dep.managerData.terraformDependencyType) {
case TerraformDependencyTypes.required_providers:
analyzeTerraformRequiredProvider(dep);
break;
case TerraformDependencyTypes.provider:
analyzeTerraformProvider(dep);
break;
Expand Down
Loading

0 comments on commit c2980e9

Please sign in to comment.