Rename to docker-build

This commit is contained in:
Bryce Lampe
2024-04-15 14:51:07 -07:00
parent 4cd6d49ba9
commit 12bf5dd689
139 changed files with 638 additions and 645 deletions

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:generate go run go.uber.org/mock/mockgen -typed -package internal -source client.go -destination mockcli_test.go --self_package github.com/pulumi/pulumi-dockerbuild/provider/internal
//go:generate go run go.uber.org/mock/mockgen -typed -package internal -source cli.go -destination mockcli_test.go --self_package github.com/pulumi/pulumi-docker-build/provider/internal
package internal

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:generate go run go.uber.org/mock/mockgen -typed -package internal -source client.go -destination mockclient_test.go --self_package github.com/pulumi/pulumi-dockerbuild/provider/internal
//go:generate go run go.uber.org/mock/mockgen -typed -package internal -source client.go -destination mockclient_test.go --self_package github.com/pulumi/pulumi-docker-build/provider/internal
package internal

View File

@@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:generate go run ../pkg/docs-gen/examples examples doc
// Package internal contains our clients, validation, and provider
// implementation for interacting with Docker's buildx APIs.
//

View File

@@ -1,11 +1,11 @@
## Migrating v3 and v4 Image resources
The `dockerbuild.Image` resource provides a superset of functionality over the `Image` resources available in versions 3 and 4 of the Pulumi Docker provider.
Existing `Image` resources can be converted to `dockerbuild.Image` resources with minor modifications.
The `Image` resource provides a superset of functionality over the `Image` resources available in versions 3 and 4 of the Pulumi Docker provider.
Existing `Image` resources can be converted to the docker-build `Image` resources with minor modifications.
### Behavioral differences
There are several key behavioral differences to keep in mind when transitioning images to the new `dockerbuild.Image` resource.
There are several key behavioral differences to keep in mind when transitioning images to the new `Image` resource.
#### Previews
@@ -16,8 +16,8 @@ Version `4.x` changed build-on-preview behavior to be opt-in.
By default, `v4.x` `Image` resources do _not_ build during previews, but this behavior can be toggled with the `buildOnPreview` option.
Some users felt this made previews in CI less helpful because they no longer detected bad images by default.
The default behavior of the `dockerbuild.Image` resource has been changed to strike a better balance between CI use cases and manual updates.
By default, Pulumi will now only build `dockerbuild.Image` resources during previews when it detects a CI environment like GitHub Actions.
The default behavior of the `Image` resource has been changed to strike a better balance between CI use cases and manual updates.
By default, Pulumi will now only build `Image` resources during previews when it detects a CI environment like GitHub Actions.
Previews run in non-CI environments will not build images.
This behavior is still configurable with `buildOnPreview`.
@@ -26,7 +26,7 @@ This behavior is still configurable with `buildOnPreview`.
Versions `3.x` and `4.x` of the Pulumi Docker provider attempt to push images to remote registries by default.
They expose a `skipPush: true` option to disable pushing.
The `dockerbuild.Image` resource matches the Docker CLI's behavior and does not push images anywhere by default.
The `Image` resource matches the Docker CLI's behavior and does not push images anywhere by default.
To push images to a registry you can include `push: true` (equivalent to Docker's `--push` flag) or configure an `export` of type `registry` (equivalent to Docker's `--output type=registry`).
Like Docker, if an image is configured without exports you will see a warning with instructions for how to enable pushing, but the build will still proceed normally.
@@ -37,7 +37,7 @@ Version `3.x` of the Pulumi Docker provider supports secrets by way of the `extr
Version `4.x` of the Pulumi Docker provider does not support secrets.
The `dockerbuild.Image` resource supports secrets but does not require those secrets to exist on-disk or in environment variables.
The `Image` resource supports secrets but does not require those secrets to exist on-disk or in environment variables.
Instead, they should be passed directly as values.
(Please be sure to familiarize yourself with Pulumi's [native secret handling](https://www.pulumi.com/docs/concepts/secrets/).)
Pulumi also provides [ESC](https://www.pulumi.com/product/esc/) to make it easier to share secrets across stacks and environments.
@@ -52,7 +52,7 @@ Version `4.x` exposes a similar parameter `cacheFrom: { images: [...] }` which p
Both versions 3 and 4 require specific environment variables to be set and deviate from Docker's native caching behavior.
This can result in inefficient builds due to unnecessary image pulls, repeated file transfers, etc.
The `dockerbuild.Image` resource delegates all caching behavior to Docker.
The `Image` resource delegates all caching behavior to Docker.
`cacheFrom` and `cacheTo` options (equivalent to Docker's `--cache-to` and `--cache-from`) are exposed and provide additional cache targets, such as local disk, S3 storage, etc.
#### Outputs
@@ -60,7 +60,7 @@ The `dockerbuild.Image` resource delegates all caching behavior to Docker.
Versions `3.x` and `4.x` of the provider exposed a `repoDigest` output which was a fully qualified tag with digest.
In `4.x` this could also be a single sha256 hash if the image wasn't pushed.
Unlike earlier providers the `dockerbuild.Image` resource can push multiple tags.
Unlike earlier providers the `Image` resource can push multiple tags.
As a convenience, it exposes a `ref` output consisting of a tag with digest as long as the image was pushed.
If multiple tags were pushed this uses one at random.
@@ -73,7 +73,7 @@ Versions 3 and 4 of Pulumi Docker provider do not delete tags when the `Image` r
The `buidx.Image` will query your registries during `refresh` to ensure the expected tags exist.
If any are missing a subsequent `update` will push them.
When a `dockerbuild.Image` is deleted, it will _attempt_ to also delete any pushed tags.
When a `Image` is deleted, it will _attempt_ to also delete any pushed tags.
Deletion of remote tags is not guaranteed because not all registries support the manifest `DELETE` API (`docker.io` in particular).
Manifests are _not_ deleted in the same way during updates -- to do so safely would require a full build to determine whether a Pulumi operation should be an update or update-replace.
@@ -81,11 +81,11 @@ Use the [`retainOnDelete: true`](https://www.pulumi.com/docs/concepts/options/re
### Example migration
Examples of "fully-featured" `v3` and `v4` `Image` resources are shown below, along with an example `dockerbuild.Image` resource showing how they would look after migration.
Examples of "fully-featured" `v3` and `v4` `Image` resources are shown below, along with an example `Image` resource showing how they would look after migration.
The `v3` resource leverages `buildx` via a `DOCKER_BUILDKIT` environment variable and CLI flags passed in with `extraOption`.
After migration, the environment variable is no longer needed and CLI flags are now properties on the `dockerbuild.Image`.
In almost all cases, properties of `dockerbuild.Image` are named after the Docker CLI flag they correspond to.
After migration, the environment variable is no longer needed and CLI flags are now properties on the `Image`.
In almost all cases, properties of `Image` are named after the Docker CLI flag they correspond to.
The `v4` resource is less functional than its `v3` counterpart because it lacks the flexibility of `extraOptions`.
It it is shown with parameters similar to the `v3` example for completeness.
@@ -136,7 +136,7 @@ const v3 = new docker.Image("v3-image", {
},
});
// v3 Image after migrating to dockerbuild.Image
// v3 Image after migrating to docker-build.Image
const v3Migrated = new dockerbuild.Image("v3-to-buildx", {
tags: ["myregistry.com/user/repo:latest", "local-tag"],
push: true,
@@ -195,7 +195,7 @@ const v4 = new docker.Image("v4-image", {
},
});
// v4 Image after migrating to dockerbuild.Image
// v4 Image after migrating to docker-build.Image
const v4Migrated = new dockerbuild.Image("v4-to-buildx", {
tags: ["myregistry.com/user/repo:latest"],
push: true,

View File

@@ -5,9 +5,9 @@
```typescript
import * as pulumi from "@pulumi/pulumi";
import * as dockerbuild from "@pulumi/dockerbuild";
import * as docker_build from "@pulumi/docker-build";
const amd64 = new dockerbuild.Image("amd64", {
const amd64 = new docker_build.Image("amd64", {
cacheFrom: [{
registry: {
ref: "docker.io/pulumi/pulumi:cache-amd64",
@@ -15,17 +15,17 @@ const amd64 = new dockerbuild.Image("amd64", {
}],
cacheTo: [{
registry: {
mode: dockerbuild.CacheMode.Max,
mode: docker_build.CacheMode.Max,
ref: "docker.io/pulumi/pulumi:cache-amd64",
},
}],
context: {
location: "app",
},
platforms: [dockerbuild.Platform.Linux_amd64],
platforms: [docker_build.Platform.Linux_amd64],
tags: ["docker.io/pulumi/pulumi:3.107.0-amd64"],
});
const arm64 = new dockerbuild.Image("arm64", {
const arm64 = new docker_build.Image("arm64", {
cacheFrom: [{
registry: {
ref: "docker.io/pulumi/pulumi:cache-arm64",
@@ -33,17 +33,17 @@ const arm64 = new dockerbuild.Image("arm64", {
}],
cacheTo: [{
registry: {
mode: dockerbuild.CacheMode.Max,
mode: docker_build.CacheMode.Max,
ref: "docker.io/pulumi/pulumi:cache-arm64",
},
}],
context: {
location: "app",
},
platforms: [dockerbuild.Platform.Linux_arm64],
platforms: [docker_build.Platform.Linux_arm64],
tags: ["docker.io/pulumi/pulumi:3.107.0-arm64"],
});
const index = new dockerbuild.Index("index", {
const index = new docker_build.Index("index", {
sources: [
amd64.ref,
arm64.ref,
@@ -54,43 +54,43 @@ export const ref = index.ref;
```
```python
import pulumi
import pulumi_dockerbuild as dockerbuild
import pulumi_docker_build as docker_build
amd64 = dockerbuild.Image("amd64",
cache_from=[dockerbuild.CacheFromArgs(
registry=dockerbuild.CacheFromRegistryArgs(
amd64 = docker_build.Image("amd64",
cache_from=[docker_build.CacheFromArgs(
registry=docker_build.CacheFromRegistryArgs(
ref="docker.io/pulumi/pulumi:cache-amd64",
),
)],
cache_to=[dockerbuild.CacheToArgs(
registry=dockerbuild.CacheToRegistryArgs(
mode=dockerbuild.CacheMode.MAX,
cache_to=[docker_build.CacheToArgs(
registry=docker_build.CacheToRegistryArgs(
mode=docker_build.CacheMode.MAX,
ref="docker.io/pulumi/pulumi:cache-amd64",
),
)],
context=dockerbuild.BuildContextArgs(
context=docker_build.BuildContextArgs(
location="app",
),
platforms=[dockerbuild.Platform.LINUX_AMD64],
platforms=[docker_build.Platform.LINUX_AMD64],
tags=["docker.io/pulumi/pulumi:3.107.0-amd64"])
arm64 = dockerbuild.Image("arm64",
cache_from=[dockerbuild.CacheFromArgs(
registry=dockerbuild.CacheFromRegistryArgs(
arm64 = docker_build.Image("arm64",
cache_from=[docker_build.CacheFromArgs(
registry=docker_build.CacheFromRegistryArgs(
ref="docker.io/pulumi/pulumi:cache-arm64",
),
)],
cache_to=[dockerbuild.CacheToArgs(
registry=dockerbuild.CacheToRegistryArgs(
mode=dockerbuild.CacheMode.MAX,
cache_to=[docker_build.CacheToArgs(
registry=docker_build.CacheToRegistryArgs(
mode=docker_build.CacheMode.MAX,
ref="docker.io/pulumi/pulumi:cache-arm64",
),
)],
context=dockerbuild.BuildContextArgs(
context=docker_build.BuildContextArgs(
location="app",
),
platforms=[dockerbuild.Platform.LINUX_ARM64],
platforms=[docker_build.Platform.LINUX_ARM64],
tags=["docker.io/pulumi/pulumi:3.107.0-arm64"])
index = dockerbuild.Index("index",
index = docker_build.Index("index",
sources=[
amd64.ref,
arm64.ref,
@@ -102,17 +102,17 @@ pulumi.export("ref", index.ref)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Dockerbuild = Pulumi.Dockerbuild;
using DockerBuild = Pulumi.DockerBuild;
return await Deployment.RunAsync(() =>
{
var amd64 = new Dockerbuild.Image("amd64", new()
var amd64 = new DockerBuild.Image("amd64", new()
{
CacheFrom = new[]
{
new Dockerbuild.Inputs.CacheFromArgs
new DockerBuild.Inputs.CacheFromArgs
{
Registry = new Dockerbuild.Inputs.CacheFromRegistryArgs
Registry = new DockerBuild.Inputs.CacheFromRegistryArgs
{
Ref = "docker.io/pulumi/pulumi:cache-amd64",
},
@@ -120,22 +120,22 @@ return await Deployment.RunAsync(() =>
},
CacheTo = new[]
{
new Dockerbuild.Inputs.CacheToArgs
new DockerBuild.Inputs.CacheToArgs
{
Registry = new Dockerbuild.Inputs.CacheToRegistryArgs
Registry = new DockerBuild.Inputs.CacheToRegistryArgs
{
Mode = Dockerbuild.CacheMode.Max,
Mode = DockerBuild.CacheMode.Max,
Ref = "docker.io/pulumi/pulumi:cache-amd64",
},
},
},
Context = new Dockerbuild.Inputs.BuildContextArgs
Context = new DockerBuild.Inputs.BuildContextArgs
{
Location = "app",
},
Platforms = new[]
{
Dockerbuild.Platform.Linux_amd64,
DockerBuild.Platform.Linux_amd64,
},
Tags = new[]
{
@@ -143,13 +143,13 @@ return await Deployment.RunAsync(() =>
},
});
var arm64 = new Dockerbuild.Image("arm64", new()
var arm64 = new DockerBuild.Image("arm64", new()
{
CacheFrom = new[]
{
new Dockerbuild.Inputs.CacheFromArgs
new DockerBuild.Inputs.CacheFromArgs
{
Registry = new Dockerbuild.Inputs.CacheFromRegistryArgs
Registry = new DockerBuild.Inputs.CacheFromRegistryArgs
{
Ref = "docker.io/pulumi/pulumi:cache-arm64",
},
@@ -157,22 +157,22 @@ return await Deployment.RunAsync(() =>
},
CacheTo = new[]
{
new Dockerbuild.Inputs.CacheToArgs
new DockerBuild.Inputs.CacheToArgs
{
Registry = new Dockerbuild.Inputs.CacheToRegistryArgs
Registry = new DockerBuild.Inputs.CacheToRegistryArgs
{
Mode = Dockerbuild.CacheMode.Max,
Mode = DockerBuild.CacheMode.Max,
Ref = "docker.io/pulumi/pulumi:cache-arm64",
},
},
},
Context = new Dockerbuild.Inputs.BuildContextArgs
Context = new DockerBuild.Inputs.BuildContextArgs
{
Location = "app",
},
Platforms = new[]
{
Dockerbuild.Platform.Linux_arm64,
DockerBuild.Platform.Linux_arm64,
},
Tags = new[]
{
@@ -180,7 +180,7 @@ return await Deployment.RunAsync(() =>
},
});
var index = new Dockerbuild.Index("index", new()
var index = new DockerBuild.Index("index", new()
{
Sources = new[]
{
@@ -201,7 +201,7 @@ return await Deployment.RunAsync(() =>
package main
import (
"github.com/pulumi/pulumi-dockerbuild/sdk/go/dockerbuild"
"github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
@@ -226,7 +226,7 @@ func main() {
Context: &dockerbuild.BuildContextArgs{
Location: pulumi.String("app"),
},
Platforms: dockerbuild.PlatformArray{
Platforms: docker - build.PlatformArray{
dockerbuild.Platform_Linux_amd64,
},
Tags: pulumi.StringArray{
@@ -255,7 +255,7 @@ func main() {
Context: &dockerbuild.BuildContextArgs{
Location: pulumi.String("app"),
},
Platforms: dockerbuild.PlatformArray{
Platforms: docker - build.PlatformArray{
dockerbuild.Platform_Linux_arm64,
},
Tags: pulumi.StringArray{
@@ -301,7 +301,7 @@ resources:
- linux/amd64
tags:
- docker.io/pulumi/pulumi:3.107.0-amd64
type: dockerbuild:Image
type: docker-build:Image
arm64:
properties:
cacheFrom:
@@ -317,14 +317,14 @@ resources:
- linux/arm64
tags:
- docker.io/pulumi/pulumi:3.107.0-arm64
type: dockerbuild:Image
type: docker-build:Image
index:
properties:
sources:
- ${amd64.ref}
- ${arm64.ref}
tag: docker.io/pulumi/pulumi:3.107.0
type: dockerbuild:Index
type: docker-build:Index
runtime: yaml
```
```java

View File

@@ -39,7 +39,7 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
var _fakeURN = resource.NewURN("test", "provider", "a", "dockerbuild:index:Image", "test")
var _fakeURN = resource.NewURN("test", "provider", "a", "docker-build:index:Image", "test")
func TestImageLifecycle(t *testing.T) {
t.Parallel()
@@ -273,7 +273,7 @@ func TestImageLifecycle(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
lc := integration.LifeCycleTest{
Resource: "dockerbuild:index:Image",
Resource: "docker-build:index:Image",
Create: tt.op(t),
}
s := newServer(tt.client(t))

View File

@@ -94,7 +94,7 @@ func TestIndexLifecycle(t *testing.T) {
t.Skip("missing environment variables")
}
lc := integration.LifeCycleTest{
Resource: "dockerbuild:index:Index",
Resource: "docker-build:index:Index",
Create: tt.op(t),
}
s := newServer(tt.client(t))
@@ -109,7 +109,7 @@ func TestIndexLifecycle(t *testing.T) {
func TestIndexDiff(t *testing.T) {
t.Parallel()
urn := resource.NewURN("test", "provider", "a", "dockerbuild:index:Index", "test")
urn := resource.NewURN("test", "provider", "a", "docker-build:index:Index", "test")
baseArgs := IndexArgs{Sources: []string{"docker.io/nginx:latest"}}
baseState := IndexState{IndexArgs: baseArgs}

View File

@@ -3,7 +3,7 @@
//
// Generated by this command:
//
// mockgen -typed -package internal -source client.go -destination mockclient_test.go --self_package github.com/pulumi/pulumi-dockerbuild/provider/internal
// mockgen -typed -package internal -source client.go -destination mockclient_test.go --self_package github.com/pulumi/pulumi-docker-build/provider/internal
//
// Package internal is a generated GoMock package.
package internal

View File

@@ -69,22 +69,22 @@ func NewBuildxProvider() provider.Provider {
return infer.Provider(
infer.Options{
Metadata: pschema.Metadata{
DisplayName: "dockerbuild",
DisplayName: "docker-build",
Keywords: []string{"docker", "buildkit", "buildx"},
Description: "A Pulumi provider for Docker buildx",
Homepage: "https://pulumi.io",
Publisher: "pulumi",
License: "Apache-2.0",
Repository: "https://github.com/pulumi/pulumi-dockerbuild",
PluginDownloadURL: "github.com/pulumi/pulumi-dockerbuild",
Repository: "https://github.com/pulumi/pulumi-docker-build",
PluginDownloadURL: "github.com/pulumi/pulumi-docker-build",
LanguageMap: map[string]any{
"go": gogen.GoPackageInfo{
// GenerateResourceContainerTypes: true,
Generics: gogen.GenericsSettingSideBySide,
PackageImportAliases: map[string]string{
"github.com/pulumi/pulumi-dockerbuild/sdk/go/dockerbuild": "dockerbuild",
"github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild": "dockerbuild",
},
ImportBasePath: "github.com/pulumi/pulumi-dockerbuild/sdk/go/dockerbuild",
ImportBasePath: "github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild",
},
"csharp": csgen.CSharpPackageInfo{
PackageReferences: map[string]string{
@@ -130,7 +130,7 @@ func NewBuildxProvider() provider.Provider {
// Schema returns our package specification.
func Schema(ctx context.Context, version string) schema.PackageSpec {
p := NewBuildxProvider()
spec, err := provider.GetSchema(ctx, "dockerbuild", version, p)
spec, err := provider.GetSchema(ctx, "docker-build", version, p)
contract.AssertNoErrorf(err, "missing schema")
return spec
}