Skip to content

Commit

Permalink
Check that docker is available earlier in the Image creation
Browse files Browse the repository at this point in the history
Fixes: #88
  • Loading branch information
stack72 committed Feb 26, 2020
1 parent 2a69578 commit 827635e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## HEAD (Unreleased)
* Upgrade to v2.7.0 of the Docker Terraform Provider
* Ensure that we check that docker is available earlier in the build process

## 1.2.0 (2020-01-29)
* Upgrade to pulumi-terraform-bridge v1.6.4
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Docker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ private static string GetFailureMessage(
/// when an error happens. In general reporting the full command line is fine. But it should be set
/// to false if it might contain sensitive information (like a username/password)
/// </summary>
private static async Task<string> RunCommandThatMustSucceed(
public static async Task<string> RunCommandThatMustSucceed(
string cmd,
string[] args,
Resource logResource,
Expand Down Expand Up @@ -692,4 +692,4 @@ private static async Task WaitForExitAsync(Process process)
void ProcessExited(object? sender, EventArgs e) => tcs.TrySetResult(true);
}
}
}
}
4 changes: 3 additions & 1 deletion sdk/dotnet/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public Image(string name, ImageArgs args, ComponentResourceOptions? options = nu
{
var imageName = imageArgs.Item1;

Docker.RunCommandThatMustSucceed("docker", new[] { "ps"}, this).ConfigureAwait(false);

// If there is no localImageName set it equal to imageName. Note: this means
// that if imageName contains a tag, localImageName will contain the same tag.
var localImageName = imageArgs.Item2 ?? imageName;
Expand Down Expand Up @@ -177,4 +179,4 @@ public Image(string name, ImageArgs args, ComponentResourceOptions? options = nu
});
}
}
}
}
2 changes: 1 addition & 1 deletion sdk/nodejs/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ function getFailureMessage(
// [reportFullCommandLine] is used to determine if the full command line should be reported
// when an error happens. In general reporting the full command line is fine. But it should be set
// to false if it might contain sensitive information (like a username/password)
async function runCommandThatMustSucceed(
export async function runCommandThatMustSucceed(
cmd: string,
args: string[],
logResource: pulumi.Resource,
Expand Down
2 changes: 2 additions & 0 deletions sdk/nodejs/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export class Image extends pulumi.ComponentResource {
const imageData = pulumi.output(args).apply(async (imageArgs) => {
const imageName = imageArgs.imageName;

await docker.runCommandThatMustSucceed( "docker", ["ps"], this);

// If there is no localImageName set it equal to imageName. Note: this means
// that if imageName contains a tag, localImageName will contain the same tag.
const localImageName = imageArgs.localImageName || imageName;
Expand Down

0 comments on commit 827635e

Please sign in to comment.