Skip to content

Commit

Permalink
specify TPI version
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Jan 22, 2022
1 parent 824cb81 commit 026e936
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 65 deletions.
12 changes: 3 additions & 9 deletions src/terraform.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,11 @@ const mapCloudMetadata = (metadata) =>
Object.entries(metadata).map(([key, value]) => `${key} = "${value || ''}"`);

const iterativeProviderTpl = () => {
return `
terraform {
return `terraform {
required_providers {
iterative = {
source = "iterative/iterative"
}
iterative = { source = "iterative/iterative", version = ">= 0.9.10" }
}
}
provider "iterative" {}
`;
};
Expand Down Expand Up @@ -90,9 +86,7 @@ const iterativeCmlRunnerTpl = (opts = {}) => {
dockerVolumes
} = opts;

const template = `
${iterativeProviderTpl()}
const template = `${iterativeProviderTpl()}
resource "iterative_cml_runner" "runner" {
${repo ? `repo = "${repo}"` : ''}
${token ? `token = "${token}"` : ''}
Expand Down
70 changes: 14 additions & 56 deletions src/terraform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ describe('Terraform tests', () => {
test('default options', async () => {
const output = iterativeCmlRunnerTpl({});
expect(output).toMatchInlineSnapshot(`
"
terraform {
"terraform {
required_providers {
iterative = {
source = \\"iterative/iterative\\"
}
iterative = { source = \\"iterative/iterative\\", version = \\">= 0.9.10\\" }
}
}
provider \\"iterative\\" {}
resource \\"iterative_cml_runner\\" \\"runner\\" {
Expand Down Expand Up @@ -64,19 +58,13 @@ describe('Terraform tests', () => {
awsSecurityGroup: 'mysg'
});
expect(output).toMatchInlineSnapshot(`
"
terraform {
"terraform {
required_providers {
iterative = {
source = \\"iterative/iterative\\"
}
iterative = { source = \\"iterative/iterative\\", version = \\">= 0.9.10\\" }
}
}
provider \\"iterative\\" {}
resource \\"iterative_cml_runner\\" \\"runner\\" {
repo = \\"https://\\"
token = \\"abc\\"
Expand Down Expand Up @@ -123,19 +111,13 @@ describe('Terraform tests', () => {
spotPrice: '0.0001'
});
expect(output).toMatchInlineSnapshot(`
"
terraform {
"terraform {
required_providers {
iterative = {
source = \\"iterative/iterative\\"
}
iterative = { source = \\"iterative/iterative\\", version = \\">= 0.9.10\\" }
}
}
provider \\"iterative\\" {}
resource \\"iterative_cml_runner\\" \\"runner\\" {
repo = \\"https://\\"
token = \\"abc\\"
Expand Down Expand Up @@ -183,19 +165,13 @@ describe('Terraform tests', () => {
metadata: { one: 'value', two: null }
});
expect(output).toMatchInlineSnapshot(`
"
terraform {
"terraform {
required_providers {
iterative = {
source = \\"iterative/iterative\\"
}
iterative = { source = \\"iterative/iterative\\", version = \\">= 0.9.10\\" }
}
}
provider \\"iterative\\" {}
resource \\"iterative_cml_runner\\" \\"runner\\" {
repo = \\"https://\\"
token = \\"abc\\"
Expand Down Expand Up @@ -246,19 +222,13 @@ describe('Terraform tests', () => {
dockerVolumes: ['/aa:/aa', '/bb:/bb']
});
expect(output).toMatchInlineSnapshot(`
"
terraform {
"terraform {
required_providers {
iterative = {
source = \\"iterative/iterative\\"
}
iterative = { source = \\"iterative/iterative\\", version = \\">= 0.9.10\\" }
}
}
provider \\"iterative\\" {}
resource \\"iterative_cml_runner\\" \\"runner\\" {
repo = \\"https://\\"
token = \\"abc\\"
Expand Down Expand Up @@ -307,19 +277,13 @@ describe('Terraform tests', () => {
awsSecurityGroup: 'mysg'
});
expect(output).toMatchInlineSnapshot(`
"
terraform {
"terraform {
required_providers {
iterative = {
source = \\"iterative/iterative\\"
}
iterative = { source = \\"iterative/iterative\\", version = \\">= 0.9.10\\" }
}
}
provider \\"iterative\\" {}
resource \\"iterative_cml_runner\\" \\"runner\\" {
repo = \\"https://\\"
token = \\"abc\\"
Expand Down Expand Up @@ -367,19 +331,13 @@ describe('Terraform tests', () => {
startupScript: 'c3VkbyBlY2hvICdoZWxsbyB3b3JsZCcgPj4gL3Vzci9oZWxsby50eHQ='
});
expect(output).toMatchInlineSnapshot(`
"
terraform {
"terraform {
required_providers {
iterative = {
source = \\"iterative/iterative\\"
}
iterative = { source = \\"iterative/iterative\\", version = \\">= 0.9.10\\" }
}
}
provider \\"iterative\\" {}
resource \\"iterative_cml_runner\\" \\"runner\\" {
repo = \\"https://\\"
token = \\"abc\\"
Expand Down

1 comment on commit 026e936

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

Please sign in to comment.