Initial provider implementation (#18)
This brings over the initial buildx prototype from pulumi/pulumi-docker and fixes various build and release issues.
This commit is contained in:
117
sdk/python/README.md
generated
117
sdk/python/README.md
generated
@@ -1,106 +1,23 @@
|
||||
# Pulumi Native Provider Boilerplate
|
||||
[](https://slack.pulumi.com)
|
||||
[](https://www.npmjs.com/package/@pulumi/docker-build)
|
||||
[](https://pypi.org/project/pulumi-docker-build)
|
||||
[](https://badge.fury.io/nu/pulumi.dockerbuild)
|
||||
[](https://pkg.go.dev/github.com/pulumi/pulumi-docker-build/sdk/go)
|
||||
[](https://github.com/pulumi/pulumi-docker-build/blob/main/LICENSE)
|
||||
|
||||
This repository is a boilerplate showing how to create and locally test a native Pulumi provider.
|
||||
# Docker-Build Resource Provider
|
||||
|
||||
## Authoring a Pulumi Native Provider
|
||||
A [Pulumi](http://pulumi.com) provider for building modern Docker images with [buildx](https://docs.docker.com/build/architecture/) and [BuildKit](https://docs.docker.com/build/buildkit/).
|
||||
|
||||
This boilerplate creates a working Pulumi-owned provider named `xyz`.
|
||||
It implements a random number generator that you can [build and test out for yourself](#test-against-the-example) and then replace the Random code with code specific to your provider.
|
||||
Not to be confused with the earlier
|
||||
[Docker](http://github.com/pulumi/pulumi-docker) provider, which is still
|
||||
appropriate for managing resources unrelated to building images.
|
||||
|
||||
| Provider | Use cases |
|
||||
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `@pulumi/docker-build` | Anything related to building images with `docker build`. |
|
||||
| `@pulumi/docker` | Everything else -- including running containers and creating networks. |
|
||||
|
||||
### Prerequisites
|
||||
## Reference
|
||||
|
||||
Prerequisites for this repository are already satisfied by the [Pulumi Devcontainer](https://github.com/pulumi/devcontainer) if you are using Github Codespaces, or VSCode.
|
||||
|
||||
If you are not using VSCode, you will need to ensure the following tools are installed and present in your `$PATH`:
|
||||
|
||||
* [`pulumictl`](https://github.com/pulumi/pulumictl#installation)
|
||||
* [Go 1.21](https://golang.org/dl/) or 1.latest
|
||||
* [NodeJS](https://nodejs.org/en/) 14.x. We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage NodeJS installations.
|
||||
* [Yarn](https://yarnpkg.com/)
|
||||
* [TypeScript](https://www.typescriptlang.org/)
|
||||
* [Python](https://www.python.org/downloads/) (called as `python3`). For recent versions of MacOS, the system-installed version is fine.
|
||||
* [.NET](https://dotnet.microsoft.com/download)
|
||||
|
||||
|
||||
### Build & test the boilerplate XYZ provider
|
||||
|
||||
1. Create a new Github CodeSpaces environment using this repository.
|
||||
1. Open a terminal in the CodeSpaces environment.
|
||||
1. Run `make build install` to build and install the provider.
|
||||
1. Run `make gen_examples` to generate the example programs in `examples/` off of the source `examples/yaml` example program.
|
||||
1. Run `make up` to run the example program in `examples/yaml`.
|
||||
1. Run `make down` to tear down the example program.
|
||||
|
||||
### Creating a new provider repository
|
||||
|
||||
Pulumi offers this repository as a [GitHub template repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) for convenience. From this repository:
|
||||
|
||||
1. Click "Use this template".
|
||||
1. Set the following options:
|
||||
* Owner: pulumi
|
||||
* Repository name: pulumi-xyz-native (replace "xyz" with the name of your provider)
|
||||
* Description: Pulumi provider for xyz
|
||||
* Repository type: Public
|
||||
1. Clone the generated repository.
|
||||
|
||||
From the templated repository:
|
||||
|
||||
1. Search-replace `xyz` with the name of your desired provider.
|
||||
|
||||
#### Build the provider and install the plugin
|
||||
|
||||
```bash
|
||||
$ make build install
|
||||
```
|
||||
|
||||
This will:
|
||||
|
||||
1. Create the SDK codegen binary and place it in a `./bin` folder (gitignored)
|
||||
2. Create the provider binary and place it in the `./bin` folder (gitignored)
|
||||
3. Generate the dotnet, Go, Node, and Python SDKs and place them in the `./sdk` folder
|
||||
4. Install the provider on your machine.
|
||||
|
||||
#### Test against the example
|
||||
|
||||
```bash
|
||||
$ cd examples/simple
|
||||
$ yarn link @pulumi/xyz
|
||||
$ yarn install
|
||||
$ pulumi stack init test
|
||||
$ pulumi up
|
||||
```
|
||||
|
||||
Now that you have completed all of the above steps, you have a working provider that generates a random string for you.
|
||||
|
||||
#### A brief repository overview
|
||||
|
||||
You now have:
|
||||
|
||||
1. A `provider/` folder containing the building and implementation logic
|
||||
1. `cmd/pulumi-resource-xyz/main.go` - holds the provider's sample implementation logic.
|
||||
2. `deployment-templates` - a set of files to help you around deployment and publication
|
||||
3. `sdk` - holds the generated code libraries created by `pulumi-gen-xyz/main.go`
|
||||
4. `examples` a folder of Pulumi programs to try locally and/or use in CI.
|
||||
5. A `Makefile` and this `README`.
|
||||
|
||||
#### Additional Details
|
||||
|
||||
This repository depends on the pulumi-go-provider library. For more details on building providers, please check
|
||||
the [Pulumi Go Provider docs](https://github.com/pulumi/pulumi-go-provider).
|
||||
|
||||
### Build Examples
|
||||
|
||||
Create an example program using the resources defined in your provider, and place it in the `examples/` folder.
|
||||
|
||||
You can now repeat the steps for [build, install, and test](#test-against-the-example).
|
||||
|
||||
## Configuring CI and releases
|
||||
|
||||
1. Follow the instructions laid out in the [deployment templates](./deployment-templates/README-DEPLOYMENT.md).
|
||||
|
||||
## References
|
||||
|
||||
Other resources/examples for implementing providers:
|
||||
* [Pulumi Command provider](https://github.com/pulumi/pulumi-command/blob/master/provider/pkg/provider/provider.go)
|
||||
* [Pulumi Go Provider repository](https://github.com/pulumi/pulumi-go-provider)
|
||||
For more information, including examples and migration guidance, please see the Docker-Build provider's detailed [API documentation](https://www.pulumi.com/registry/packages/docker-build/).
|
||||
|
||||
1
sdk/python/pulumi_docker_build/README.md
generated
Normal file
1
sdk/python/pulumi_docker_build/README.md
generated
Normal file
@@ -0,0 +1 @@
|
||||
A Pulumi provider for building modern Docker images with buildx and BuildKit.
|
||||
46
sdk/python/pulumi_docker_build/__init__.py
generated
Normal file
46
sdk/python/pulumi_docker_build/__init__.py
generated
Normal file
@@ -0,0 +1,46 @@
|
||||
# coding=utf-8
|
||||
# *** WARNING: this file was generated by pulumi-language-python. ***
|
||||
# *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
from . import _utilities
|
||||
import typing
|
||||
# Export this package's modules as members:
|
||||
from ._enums import *
|
||||
from .image import *
|
||||
from .index import *
|
||||
from .provider import *
|
||||
from ._inputs import *
|
||||
from . import outputs
|
||||
|
||||
# Make subpackages available:
|
||||
if typing.TYPE_CHECKING:
|
||||
import pulumi_docker_build.config as __config
|
||||
config = __config
|
||||
else:
|
||||
config = _utilities.lazy_import('pulumi_docker_build.config')
|
||||
|
||||
_utilities.register(
|
||||
resource_modules="""
|
||||
[
|
||||
{
|
||||
"pkg": "docker-build",
|
||||
"mod": "index",
|
||||
"fqn": "pulumi_docker_build",
|
||||
"classes": {
|
||||
"docker-build:index:Image": "Image",
|
||||
"docker-build:index:Index": "Index"
|
||||
}
|
||||
}
|
||||
]
|
||||
""",
|
||||
resource_packages="""
|
||||
[
|
||||
{
|
||||
"pkg": "docker-build",
|
||||
"token": "pulumi:providers:docker-build",
|
||||
"fqn": "pulumi_docker_build",
|
||||
"class": "Provider"
|
||||
}
|
||||
]
|
||||
"""
|
||||
)
|
||||
84
sdk/python/pulumi_docker_build/_enums.py
generated
Normal file
84
sdk/python/pulumi_docker_build/_enums.py
generated
Normal file
@@ -0,0 +1,84 @@
|
||||
# coding=utf-8
|
||||
# *** WARNING: this file was generated by pulumi-language-python. ***
|
||||
# *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
from enum import Enum
|
||||
|
||||
__all__ = [
|
||||
'CacheMode',
|
||||
'CompressionType',
|
||||
'NetworkMode',
|
||||
'Platform',
|
||||
]
|
||||
|
||||
|
||||
class CacheMode(str, Enum):
|
||||
MIN = "min"
|
||||
"""
|
||||
Only layers that are exported into the resulting image are cached.
|
||||
"""
|
||||
MAX = "max"
|
||||
"""
|
||||
All layers are cached, even those of intermediate steps.
|
||||
"""
|
||||
|
||||
|
||||
class CompressionType(str, Enum):
|
||||
GZIP = "gzip"
|
||||
"""
|
||||
Use `gzip` for compression.
|
||||
"""
|
||||
ESTARGZ = "estargz"
|
||||
"""
|
||||
Use `estargz` for compression.
|
||||
"""
|
||||
ZSTD = "zstd"
|
||||
"""
|
||||
Use `zstd` for compression.
|
||||
"""
|
||||
|
||||
|
||||
class NetworkMode(str, Enum):
|
||||
DEFAULT = "default"
|
||||
"""
|
||||
The default sandbox network mode.
|
||||
"""
|
||||
HOST = "host"
|
||||
"""
|
||||
Host network mode.
|
||||
"""
|
||||
NONE = "none"
|
||||
"""
|
||||
Disable network access.
|
||||
"""
|
||||
|
||||
|
||||
class Platform(str, Enum):
|
||||
DARWIN_386 = "darwin/386"
|
||||
DARWIN_AMD64 = "darwin/amd64"
|
||||
DARWIN_ARM = "darwin/arm"
|
||||
DARWIN_ARM64 = "darwin/arm64"
|
||||
DRAGONFLY_AMD64 = "dragonfly/amd64"
|
||||
FREEBSD_386 = "freebsd/386"
|
||||
FREEBSD_AMD64 = "freebsd/amd64"
|
||||
FREEBSD_ARM = "freebsd/arm"
|
||||
LINUX_386 = "linux/386"
|
||||
LINUX_AMD64 = "linux/amd64"
|
||||
LINUX_ARM = "linux/arm"
|
||||
LINUX_ARM64 = "linux/arm64"
|
||||
LINUX_MIPS64 = "linux/mips64"
|
||||
LINUX_MIPS64LE = "linux/mips64le"
|
||||
LINUX_PPC64LE = "linux/ppc64le"
|
||||
LINUX_RISCV64 = "linux/riscv64"
|
||||
LINUX_S390X = "linux/s390x"
|
||||
NETBSD_386 = "netbsd/386"
|
||||
NETBSD_AMD64 = "netbsd/amd64"
|
||||
NETBSD_ARM = "netbsd/arm"
|
||||
OPENBSD_386 = "openbsd/386"
|
||||
OPENBSD_AMD64 = "openbsd/amd64"
|
||||
OPENBSD_ARM = "openbsd/arm"
|
||||
PLAN9_386 = "plan9/386"
|
||||
PLAN9_AMD64 = "plan9/amd64"
|
||||
SOLARIS_AMD64 = "solaris/amd64"
|
||||
WINDOWS_386 = "windows/386"
|
||||
WINDOWS_AMD64 = "windows/amd64"
|
||||
2672
sdk/python/pulumi_docker_build/_inputs.py
generated
Normal file
2672
sdk/python/pulumi_docker_build/_inputs.py
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -288,4 +288,4 @@ async def _await_output(o: pulumi.Output[typing.Any]) -> typing.Tuple[object, bo
|
||||
)
|
||||
|
||||
def get_plugin_download_url():
|
||||
return "github.com/pulumi/pulumi-dockerbuild"
|
||||
return None
|
||||
8
sdk/python/pulumi_docker_build/config/__init__.py
generated
Normal file
8
sdk/python/pulumi_docker_build/config/__init__.py
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
# coding=utf-8
|
||||
# *** WARNING: this file was generated by pulumi-language-python. ***
|
||||
# *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
import sys
|
||||
from .vars import _ExportableConfig
|
||||
|
||||
sys.modules[__name__].__class__ = _ExportableConfig
|
||||
19
sdk/python/pulumi_docker_build/config/__init__.pyi
generated
Normal file
19
sdk/python/pulumi_docker_build/config/__init__.pyi
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
# coding=utf-8
|
||||
# *** WARNING: this file was generated by pulumi-language-python. ***
|
||||
# *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
import copy
|
||||
import warnings
|
||||
import pulumi
|
||||
import pulumi.runtime
|
||||
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
||||
from .. import _utilities
|
||||
from .. import outputs as _root_outputs
|
||||
|
||||
host: str
|
||||
"""
|
||||
The build daemon's address.
|
||||
"""
|
||||
|
||||
registries: Optional[str]
|
||||
|
||||
29
sdk/python/pulumi_docker_build/config/vars.py
generated
Normal file
29
sdk/python/pulumi_docker_build/config/vars.py
generated
Normal file
@@ -0,0 +1,29 @@
|
||||
# coding=utf-8
|
||||
# *** WARNING: this file was generated by pulumi-language-python. ***
|
||||
# *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
import copy
|
||||
import warnings
|
||||
import pulumi
|
||||
import pulumi.runtime
|
||||
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
||||
from .. import _utilities
|
||||
from .. import outputs as _root_outputs
|
||||
|
||||
import types
|
||||
|
||||
__config__ = pulumi.Config('docker-build')
|
||||
|
||||
|
||||
class _ExportableConfig(types.ModuleType):
|
||||
@property
|
||||
def host(self) -> str:
|
||||
"""
|
||||
The build daemon's address.
|
||||
"""
|
||||
return __config__.get('host') or (_utilities.get_env('DOCKER_HOST') or '')
|
||||
|
||||
@property
|
||||
def registries(self) -> Optional[str]:
|
||||
return __config__.get('registries')
|
||||
|
||||
1799
sdk/python/pulumi_docker_build/image.py
generated
Normal file
1799
sdk/python/pulumi_docker_build/image.py
generated
Normal file
File diff suppressed because it is too large
Load Diff
376
sdk/python/pulumi_docker_build/index.py
generated
Normal file
376
sdk/python/pulumi_docker_build/index.py
generated
Normal file
@@ -0,0 +1,376 @@
|
||||
# coding=utf-8
|
||||
# *** WARNING: this file was generated by pulumi-language-python. ***
|
||||
# *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
import copy
|
||||
import warnings
|
||||
import pulumi
|
||||
import pulumi.runtime
|
||||
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
||||
from . import _utilities
|
||||
from . import outputs
|
||||
from ._inputs import *
|
||||
|
||||
__all__ = ['IndexArgs', 'Index']
|
||||
|
||||
@pulumi.input_type
|
||||
class IndexArgs:
|
||||
def __init__(__self__, *,
|
||||
sources: pulumi.Input[Sequence[pulumi.Input[str]]],
|
||||
tag: pulumi.Input[str],
|
||||
push: Optional[pulumi.Input[bool]] = None,
|
||||
registry: Optional[pulumi.Input['RegistryArgs']] = None):
|
||||
"""
|
||||
The set of arguments for constructing a Index resource.
|
||||
:param pulumi.Input[Sequence[pulumi.Input[str]]] sources: Existing images to include in the index.
|
||||
:param pulumi.Input[str] tag: The tag to apply to the index.
|
||||
:param pulumi.Input[bool] push: If true, push the index to the target registry.
|
||||
|
||||
Defaults to `true`.
|
||||
:param pulumi.Input['RegistryArgs'] registry: Authentication for the registry where the tagged index will be pushed.
|
||||
|
||||
Credentials can also be included with the provider's configuration.
|
||||
"""
|
||||
pulumi.set(__self__, "sources", sources)
|
||||
pulumi.set(__self__, "tag", tag)
|
||||
if push is None:
|
||||
push = True
|
||||
if push is not None:
|
||||
pulumi.set(__self__, "push", push)
|
||||
if registry is not None:
|
||||
pulumi.set(__self__, "registry", registry)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def sources(self) -> pulumi.Input[Sequence[pulumi.Input[str]]]:
|
||||
"""
|
||||
Existing images to include in the index.
|
||||
"""
|
||||
return pulumi.get(self, "sources")
|
||||
|
||||
@sources.setter
|
||||
def sources(self, value: pulumi.Input[Sequence[pulumi.Input[str]]]):
|
||||
pulumi.set(self, "sources", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def tag(self) -> pulumi.Input[str]:
|
||||
"""
|
||||
The tag to apply to the index.
|
||||
"""
|
||||
return pulumi.get(self, "tag")
|
||||
|
||||
@tag.setter
|
||||
def tag(self, value: pulumi.Input[str]):
|
||||
pulumi.set(self, "tag", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def push(self) -> Optional[pulumi.Input[bool]]:
|
||||
"""
|
||||
If true, push the index to the target registry.
|
||||
|
||||
Defaults to `true`.
|
||||
"""
|
||||
return pulumi.get(self, "push")
|
||||
|
||||
@push.setter
|
||||
def push(self, value: Optional[pulumi.Input[bool]]):
|
||||
pulumi.set(self, "push", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def registry(self) -> Optional[pulumi.Input['RegistryArgs']]:
|
||||
"""
|
||||
Authentication for the registry where the tagged index will be pushed.
|
||||
|
||||
Credentials can also be included with the provider's configuration.
|
||||
"""
|
||||
return pulumi.get(self, "registry")
|
||||
|
||||
@registry.setter
|
||||
def registry(self, value: Optional[pulumi.Input['RegistryArgs']]):
|
||||
pulumi.set(self, "registry", value)
|
||||
|
||||
|
||||
class Index(pulumi.CustomResource):
|
||||
@overload
|
||||
def __init__(__self__,
|
||||
resource_name: str,
|
||||
opts: Optional[pulumi.ResourceOptions] = None,
|
||||
push: Optional[pulumi.Input[bool]] = None,
|
||||
registry: Optional[pulumi.Input[pulumi.InputType['RegistryArgs']]] = None,
|
||||
sources: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
|
||||
tag: Optional[pulumi.Input[str]] = None,
|
||||
__props__=None):
|
||||
"""
|
||||
A wrapper around `docker buildx imagetools create` to create an index
|
||||
(or manifest list) referencing one or more existing images.
|
||||
|
||||
In most cases you do not need an `Index` to build a multi-platform
|
||||
image -- specifying multiple platforms on the `Image` will handle this
|
||||
for you automatically.
|
||||
|
||||
However, as of April 2024, building multi-platform images _with
|
||||
caching_ will only export a cache for one platform at a time (see [this
|
||||
discussion](https://github.com/docker/buildx/discussions/1382) for more
|
||||
details).
|
||||
|
||||
Therefore this resource can be helpful if you are building
|
||||
multi-platform images with caching: each platform can be built and
|
||||
cached separately, and an `Index` can join them all together. An
|
||||
example of this is shown below.
|
||||
|
||||
This resource creates an OCI image index or a Docker manifest list
|
||||
depending on the media types of the source images.
|
||||
|
||||
## Example Usage
|
||||
### Multi-platform registry caching
|
||||
```python
|
||||
import pulumi
|
||||
import pulumi_docker_build as docker_build
|
||||
|
||||
amd64 = docker_build.Image("amd64",
|
||||
cache_from=[docker_build.CacheFromArgs(
|
||||
registry=docker_build.CacheFromRegistryArgs(
|
||||
ref="docker.io/pulumi/pulumi:cache-amd64",
|
||||
),
|
||||
)],
|
||||
cache_to=[docker_build.CacheToArgs(
|
||||
registry=docker_build.CacheToRegistryArgs(
|
||||
mode=docker_build.CacheMode.MAX,
|
||||
ref="docker.io/pulumi/pulumi:cache-amd64",
|
||||
),
|
||||
)],
|
||||
context=docker_build.BuildContextArgs(
|
||||
location="app",
|
||||
),
|
||||
platforms=[docker_build.Platform.LINUX_AMD64],
|
||||
tags=["docker.io/pulumi/pulumi:3.107.0-amd64"])
|
||||
arm64 = docker_build.Image("arm64",
|
||||
cache_from=[docker_build.CacheFromArgs(
|
||||
registry=docker_build.CacheFromRegistryArgs(
|
||||
ref="docker.io/pulumi/pulumi:cache-arm64",
|
||||
),
|
||||
)],
|
||||
cache_to=[docker_build.CacheToArgs(
|
||||
registry=docker_build.CacheToRegistryArgs(
|
||||
mode=docker_build.CacheMode.MAX,
|
||||
ref="docker.io/pulumi/pulumi:cache-arm64",
|
||||
),
|
||||
)],
|
||||
context=docker_build.BuildContextArgs(
|
||||
location="app",
|
||||
),
|
||||
platforms=[docker_build.Platform.LINUX_ARM64],
|
||||
tags=["docker.io/pulumi/pulumi:3.107.0-arm64"])
|
||||
index = docker_build.Index("index",
|
||||
sources=[
|
||||
amd64.ref,
|
||||
arm64.ref,
|
||||
],
|
||||
tag="docker.io/pulumi/pulumi:3.107.0")
|
||||
pulumi.export("ref", index.ref)
|
||||
```
|
||||
|
||||
:param str resource_name: The name of the resource.
|
||||
:param pulumi.ResourceOptions opts: Options for the resource.
|
||||
:param pulumi.Input[bool] push: If true, push the index to the target registry.
|
||||
|
||||
Defaults to `true`.
|
||||
:param pulumi.Input[pulumi.InputType['RegistryArgs']] registry: Authentication for the registry where the tagged index will be pushed.
|
||||
|
||||
Credentials can also be included with the provider's configuration.
|
||||
:param pulumi.Input[Sequence[pulumi.Input[str]]] sources: Existing images to include in the index.
|
||||
:param pulumi.Input[str] tag: The tag to apply to the index.
|
||||
"""
|
||||
...
|
||||
@overload
|
||||
def __init__(__self__,
|
||||
resource_name: str,
|
||||
args: IndexArgs,
|
||||
opts: Optional[pulumi.ResourceOptions] = None):
|
||||
"""
|
||||
A wrapper around `docker buildx imagetools create` to create an index
|
||||
(or manifest list) referencing one or more existing images.
|
||||
|
||||
In most cases you do not need an `Index` to build a multi-platform
|
||||
image -- specifying multiple platforms on the `Image` will handle this
|
||||
for you automatically.
|
||||
|
||||
However, as of April 2024, building multi-platform images _with
|
||||
caching_ will only export a cache for one platform at a time (see [this
|
||||
discussion](https://github.com/docker/buildx/discussions/1382) for more
|
||||
details).
|
||||
|
||||
Therefore this resource can be helpful if you are building
|
||||
multi-platform images with caching: each platform can be built and
|
||||
cached separately, and an `Index` can join them all together. An
|
||||
example of this is shown below.
|
||||
|
||||
This resource creates an OCI image index or a Docker manifest list
|
||||
depending on the media types of the source images.
|
||||
|
||||
## Example Usage
|
||||
### Multi-platform registry caching
|
||||
```python
|
||||
import pulumi
|
||||
import pulumi_docker_build as docker_build
|
||||
|
||||
amd64 = docker_build.Image("amd64",
|
||||
cache_from=[docker_build.CacheFromArgs(
|
||||
registry=docker_build.CacheFromRegistryArgs(
|
||||
ref="docker.io/pulumi/pulumi:cache-amd64",
|
||||
),
|
||||
)],
|
||||
cache_to=[docker_build.CacheToArgs(
|
||||
registry=docker_build.CacheToRegistryArgs(
|
||||
mode=docker_build.CacheMode.MAX,
|
||||
ref="docker.io/pulumi/pulumi:cache-amd64",
|
||||
),
|
||||
)],
|
||||
context=docker_build.BuildContextArgs(
|
||||
location="app",
|
||||
),
|
||||
platforms=[docker_build.Platform.LINUX_AMD64],
|
||||
tags=["docker.io/pulumi/pulumi:3.107.0-amd64"])
|
||||
arm64 = docker_build.Image("arm64",
|
||||
cache_from=[docker_build.CacheFromArgs(
|
||||
registry=docker_build.CacheFromRegistryArgs(
|
||||
ref="docker.io/pulumi/pulumi:cache-arm64",
|
||||
),
|
||||
)],
|
||||
cache_to=[docker_build.CacheToArgs(
|
||||
registry=docker_build.CacheToRegistryArgs(
|
||||
mode=docker_build.CacheMode.MAX,
|
||||
ref="docker.io/pulumi/pulumi:cache-arm64",
|
||||
),
|
||||
)],
|
||||
context=docker_build.BuildContextArgs(
|
||||
location="app",
|
||||
),
|
||||
platforms=[docker_build.Platform.LINUX_ARM64],
|
||||
tags=["docker.io/pulumi/pulumi:3.107.0-arm64"])
|
||||
index = docker_build.Index("index",
|
||||
sources=[
|
||||
amd64.ref,
|
||||
arm64.ref,
|
||||
],
|
||||
tag="docker.io/pulumi/pulumi:3.107.0")
|
||||
pulumi.export("ref", index.ref)
|
||||
```
|
||||
|
||||
:param str resource_name: The name of the resource.
|
||||
:param IndexArgs args: The arguments to use to populate this resource's properties.
|
||||
:param pulumi.ResourceOptions opts: Options for the resource.
|
||||
"""
|
||||
...
|
||||
def __init__(__self__, resource_name: str, *args, **kwargs):
|
||||
resource_args, opts = _utilities.get_resource_args_opts(IndexArgs, pulumi.ResourceOptions, *args, **kwargs)
|
||||
if resource_args is not None:
|
||||
__self__._internal_init(resource_name, opts, **resource_args.__dict__)
|
||||
else:
|
||||
__self__._internal_init(resource_name, *args, **kwargs)
|
||||
|
||||
def _internal_init(__self__,
|
||||
resource_name: str,
|
||||
opts: Optional[pulumi.ResourceOptions] = None,
|
||||
push: Optional[pulumi.Input[bool]] = None,
|
||||
registry: Optional[pulumi.Input[pulumi.InputType['RegistryArgs']]] = None,
|
||||
sources: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
|
||||
tag: Optional[pulumi.Input[str]] = None,
|
||||
__props__=None):
|
||||
opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
|
||||
if not isinstance(opts, pulumi.ResourceOptions):
|
||||
raise TypeError('Expected resource options to be a ResourceOptions instance')
|
||||
if opts.id is None:
|
||||
if __props__ is not None:
|
||||
raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
|
||||
__props__ = IndexArgs.__new__(IndexArgs)
|
||||
|
||||
if push is None:
|
||||
push = True
|
||||
__props__.__dict__["push"] = push
|
||||
__props__.__dict__["registry"] = registry
|
||||
if sources is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'sources'")
|
||||
__props__.__dict__["sources"] = sources
|
||||
if tag is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'tag'")
|
||||
__props__.__dict__["tag"] = tag
|
||||
__props__.__dict__["ref"] = None
|
||||
super(Index, __self__).__init__(
|
||||
'docker-build:index:Index',
|
||||
resource_name,
|
||||
__props__,
|
||||
opts)
|
||||
|
||||
@staticmethod
|
||||
def get(resource_name: str,
|
||||
id: pulumi.Input[str],
|
||||
opts: Optional[pulumi.ResourceOptions] = None) -> 'Index':
|
||||
"""
|
||||
Get an existing Index resource's state with the given name, id, and optional extra
|
||||
properties used to qualify the lookup.
|
||||
|
||||
:param str resource_name: The unique name of the resulting resource.
|
||||
:param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
|
||||
:param pulumi.ResourceOptions opts: Options for the resource.
|
||||
"""
|
||||
opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
|
||||
|
||||
__props__ = IndexArgs.__new__(IndexArgs)
|
||||
|
||||
__props__.__dict__["push"] = None
|
||||
__props__.__dict__["ref"] = None
|
||||
__props__.__dict__["registry"] = None
|
||||
__props__.__dict__["sources"] = None
|
||||
__props__.__dict__["tag"] = None
|
||||
return Index(resource_name, opts=opts, __props__=__props__)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def push(self) -> pulumi.Output[Optional[bool]]:
|
||||
"""
|
||||
If true, push the index to the target registry.
|
||||
|
||||
Defaults to `true`.
|
||||
"""
|
||||
return pulumi.get(self, "push")
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def ref(self) -> pulumi.Output[str]:
|
||||
"""
|
||||
The pushed tag with digest.
|
||||
|
||||
Identical to the tag if the index was not pushed.
|
||||
"""
|
||||
return pulumi.get(self, "ref")
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def registry(self) -> pulumi.Output[Optional['outputs.Registry']]:
|
||||
"""
|
||||
Authentication for the registry where the tagged index will be pushed.
|
||||
|
||||
Credentials can also be included with the provider's configuration.
|
||||
"""
|
||||
return pulumi.get(self, "registry")
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def sources(self) -> pulumi.Output[Sequence[str]]:
|
||||
"""
|
||||
Existing images to include in the index.
|
||||
"""
|
||||
return pulumi.get(self, "sources")
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def tag(self) -> pulumi.Output[str]:
|
||||
"""
|
||||
The tag to apply to the index.
|
||||
"""
|
||||
return pulumi.get(self, "tag")
|
||||
|
||||
2399
sdk/python/pulumi_docker_build/outputs.py
generated
Normal file
2399
sdk/python/pulumi_docker_build/outputs.py
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,16 +8,46 @@ import pulumi
|
||||
import pulumi.runtime
|
||||
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
||||
from . import _utilities
|
||||
from ._inputs import *
|
||||
|
||||
__all__ = ['ProviderArgs', 'Provider']
|
||||
|
||||
@pulumi.input_type
|
||||
class ProviderArgs:
|
||||
def __init__(__self__):
|
||||
def __init__(__self__, *,
|
||||
host: Optional[pulumi.Input[str]] = None,
|
||||
registries: Optional[pulumi.Input[Sequence[pulumi.Input['RegistryArgs']]]] = None):
|
||||
"""
|
||||
The set of arguments for constructing a Provider resource.
|
||||
:param pulumi.Input[str] host: The build daemon's address.
|
||||
"""
|
||||
pass
|
||||
if host is None:
|
||||
host = (_utilities.get_env('DOCKER_HOST') or '')
|
||||
if host is not None:
|
||||
pulumi.set(__self__, "host", host)
|
||||
if registries is not None:
|
||||
pulumi.set(__self__, "registries", registries)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def host(self) -> Optional[pulumi.Input[str]]:
|
||||
"""
|
||||
The build daemon's address.
|
||||
"""
|
||||
return pulumi.get(self, "host")
|
||||
|
||||
@host.setter
|
||||
def host(self, value: Optional[pulumi.Input[str]]):
|
||||
pulumi.set(self, "host", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def registries(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['RegistryArgs']]]]:
|
||||
return pulumi.get(self, "registries")
|
||||
|
||||
@registries.setter
|
||||
def registries(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['RegistryArgs']]]]):
|
||||
pulumi.set(self, "registries", value)
|
||||
|
||||
|
||||
class Provider(pulumi.ProviderResource):
|
||||
@@ -25,11 +55,14 @@ class Provider(pulumi.ProviderResource):
|
||||
def __init__(__self__,
|
||||
resource_name: str,
|
||||
opts: Optional[pulumi.ResourceOptions] = None,
|
||||
host: Optional[pulumi.Input[str]] = None,
|
||||
registries: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RegistryArgs']]]]] = None,
|
||||
__props__=None):
|
||||
"""
|
||||
Create a Dockerbuild resource with the given unique name, props, and options.
|
||||
Create a Docker-build resource with the given unique name, props, and options.
|
||||
:param str resource_name: The name of the resource.
|
||||
:param pulumi.ResourceOptions opts: Options for the resource.
|
||||
:param pulumi.Input[str] host: The build daemon's address.
|
||||
"""
|
||||
...
|
||||
@overload
|
||||
@@ -38,7 +71,7 @@ class Provider(pulumi.ProviderResource):
|
||||
args: Optional[ProviderArgs] = None,
|
||||
opts: Optional[pulumi.ResourceOptions] = None):
|
||||
"""
|
||||
Create a Dockerbuild resource with the given unique name, props, and options.
|
||||
Create a Docker-build resource with the given unique name, props, and options.
|
||||
:param str resource_name: The name of the resource.
|
||||
:param ProviderArgs args: The arguments to use to populate this resource's properties.
|
||||
:param pulumi.ResourceOptions opts: Options for the resource.
|
||||
@@ -54,6 +87,8 @@ class Provider(pulumi.ProviderResource):
|
||||
def _internal_init(__self__,
|
||||
resource_name: str,
|
||||
opts: Optional[pulumi.ResourceOptions] = None,
|
||||
host: Optional[pulumi.Input[str]] = None,
|
||||
registries: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RegistryArgs']]]]] = None,
|
||||
__props__=None):
|
||||
opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
|
||||
if not isinstance(opts, pulumi.ResourceOptions):
|
||||
@@ -63,9 +98,21 @@ class Provider(pulumi.ProviderResource):
|
||||
raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
|
||||
__props__ = ProviderArgs.__new__(ProviderArgs)
|
||||
|
||||
if host is None:
|
||||
host = (_utilities.get_env('DOCKER_HOST') or '')
|
||||
__props__.__dict__["host"] = host
|
||||
__props__.__dict__["registries"] = pulumi.Output.from_input(registries).apply(pulumi.runtime.to_json) if registries is not None else None
|
||||
super(Provider, __self__).__init__(
|
||||
'dockerbuild',
|
||||
'docker-build',
|
||||
resource_name,
|
||||
__props__,
|
||||
opts)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def host(self) -> pulumi.Output[Optional[str]]:
|
||||
"""
|
||||
The build daemon's address.
|
||||
"""
|
||||
return pulumi.get(self, "host")
|
||||
|
||||
4
sdk/python/pulumi_docker_build/pulumi-plugin.json
generated
Normal file
4
sdk/python/pulumi_docker_build/pulumi-plugin.json
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"resource": true,
|
||||
"name": "docker-build"
|
||||
}
|
||||
1
sdk/python/pulumi_dockerbuild/README.md
generated
1
sdk/python/pulumi_dockerbuild/README.md
generated
@@ -1 +0,0 @@
|
||||
Description
|
||||
33
sdk/python/pulumi_dockerbuild/__init__.py
generated
33
sdk/python/pulumi_dockerbuild/__init__.py
generated
@@ -1,33 +0,0 @@
|
||||
# coding=utf-8
|
||||
# *** WARNING: this file was generated by pulumi-language-python. ***
|
||||
# *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
from . import _utilities
|
||||
import typing
|
||||
# Export this package's modules as members:
|
||||
from .provider import *
|
||||
from .random import *
|
||||
_utilities.register(
|
||||
resource_modules="""
|
||||
[
|
||||
{
|
||||
"pkg": "dockerbuild",
|
||||
"mod": "index",
|
||||
"fqn": "pulumi_dockerbuild",
|
||||
"classes": {
|
||||
"dockerbuild:index:Random": "Random"
|
||||
}
|
||||
}
|
||||
]
|
||||
""",
|
||||
resource_packages="""
|
||||
[
|
||||
{
|
||||
"pkg": "dockerbuild",
|
||||
"token": "pulumi:providers:dockerbuild",
|
||||
"fqn": "pulumi_dockerbuild",
|
||||
"class": "Provider"
|
||||
}
|
||||
]
|
||||
"""
|
||||
)
|
||||
5
sdk/python/pulumi_dockerbuild/pulumi-plugin.json
generated
5
sdk/python/pulumi_dockerbuild/pulumi-plugin.json
generated
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"resource": true,
|
||||
"name": "dockerbuild",
|
||||
"server": "github.com/pulumi/pulumi-dockerbuild"
|
||||
}
|
||||
117
sdk/python/pulumi_dockerbuild/random.py
generated
117
sdk/python/pulumi_dockerbuild/random.py
generated
@@ -1,117 +0,0 @@
|
||||
# coding=utf-8
|
||||
# *** WARNING: this file was generated by pulumi-language-python. ***
|
||||
# *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
import copy
|
||||
import warnings
|
||||
import pulumi
|
||||
import pulumi.runtime
|
||||
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
||||
from . import _utilities
|
||||
|
||||
__all__ = ['RandomArgs', 'Random']
|
||||
|
||||
@pulumi.input_type
|
||||
class RandomArgs:
|
||||
def __init__(__self__, *,
|
||||
length: pulumi.Input[int]):
|
||||
"""
|
||||
The set of arguments for constructing a Random resource.
|
||||
"""
|
||||
pulumi.set(__self__, "length", length)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def length(self) -> pulumi.Input[int]:
|
||||
return pulumi.get(self, "length")
|
||||
|
||||
@length.setter
|
||||
def length(self, value: pulumi.Input[int]):
|
||||
pulumi.set(self, "length", value)
|
||||
|
||||
|
||||
class Random(pulumi.CustomResource):
|
||||
@overload
|
||||
def __init__(__self__,
|
||||
resource_name: str,
|
||||
opts: Optional[pulumi.ResourceOptions] = None,
|
||||
length: Optional[pulumi.Input[int]] = None,
|
||||
__props__=None):
|
||||
"""
|
||||
Create a Random resource with the given unique name, props, and options.
|
||||
:param str resource_name: The name of the resource.
|
||||
:param pulumi.ResourceOptions opts: Options for the resource.
|
||||
"""
|
||||
...
|
||||
@overload
|
||||
def __init__(__self__,
|
||||
resource_name: str,
|
||||
args: RandomArgs,
|
||||
opts: Optional[pulumi.ResourceOptions] = None):
|
||||
"""
|
||||
Create a Random resource with the given unique name, props, and options.
|
||||
:param str resource_name: The name of the resource.
|
||||
:param RandomArgs args: The arguments to use to populate this resource's properties.
|
||||
:param pulumi.ResourceOptions opts: Options for the resource.
|
||||
"""
|
||||
...
|
||||
def __init__(__self__, resource_name: str, *args, **kwargs):
|
||||
resource_args, opts = _utilities.get_resource_args_opts(RandomArgs, pulumi.ResourceOptions, *args, **kwargs)
|
||||
if resource_args is not None:
|
||||
__self__._internal_init(resource_name, opts, **resource_args.__dict__)
|
||||
else:
|
||||
__self__._internal_init(resource_name, *args, **kwargs)
|
||||
|
||||
def _internal_init(__self__,
|
||||
resource_name: str,
|
||||
opts: Optional[pulumi.ResourceOptions] = None,
|
||||
length: Optional[pulumi.Input[int]] = None,
|
||||
__props__=None):
|
||||
opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
|
||||
if not isinstance(opts, pulumi.ResourceOptions):
|
||||
raise TypeError('Expected resource options to be a ResourceOptions instance')
|
||||
if opts.id is None:
|
||||
if __props__ is not None:
|
||||
raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
|
||||
__props__ = RandomArgs.__new__(RandomArgs)
|
||||
|
||||
if length is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'length'")
|
||||
__props__.__dict__["length"] = length
|
||||
__props__.__dict__["result"] = None
|
||||
super(Random, __self__).__init__(
|
||||
'dockerbuild:index:Random',
|
||||
resource_name,
|
||||
__props__,
|
||||
opts)
|
||||
|
||||
@staticmethod
|
||||
def get(resource_name: str,
|
||||
id: pulumi.Input[str],
|
||||
opts: Optional[pulumi.ResourceOptions] = None) -> 'Random':
|
||||
"""
|
||||
Get an existing Random resource's state with the given name, id, and optional extra
|
||||
properties used to qualify the lookup.
|
||||
|
||||
:param str resource_name: The unique name of the resulting resource.
|
||||
:param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
|
||||
:param pulumi.ResourceOptions opts: Options for the resource.
|
||||
"""
|
||||
opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
|
||||
|
||||
__props__ = RandomArgs.__new__(RandomArgs)
|
||||
|
||||
__props__.__dict__["length"] = None
|
||||
__props__.__dict__["result"] = None
|
||||
return Random(resource_name, opts=opts, __props__=__props__)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def length(self) -> pulumi.Output[int]:
|
||||
return pulumi.get(self, "length")
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def result(self) -> pulumi.Output[str]:
|
||||
return pulumi.get(self, "result")
|
||||
|
||||
14
sdk/python/pyproject.toml
generated
14
sdk/python/pyproject.toml
generated
@@ -1,14 +1,16 @@
|
||||
[project]
|
||||
name = "pulumi_dockerbuild"
|
||||
description = "Description"
|
||||
name = "pulumi_docker_build"
|
||||
description = "A Pulumi provider for building modern Docker images with buildx and BuildKit."
|
||||
dependencies = ["parver>=0.2.1", "pulumi>=3.0.0,<4.0.0", "semver>=2.8.1"]
|
||||
keywords = ["keywords"]
|
||||
keywords = ["docker", "buildkit", "buildx", "kind/native"]
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
version = "0.0.0"
|
||||
[project.license]
|
||||
text = "Apache-2.0"
|
||||
[project.urls]
|
||||
Homepage = "pulumi.com"
|
||||
Repository = "https://github.com/pulumi/pulumi-dockerbuild"
|
||||
Homepage = "https://pulumi.com"
|
||||
Repository = "https://github.com/pulumi/pulumi-docker-build"
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=61.0"]
|
||||
@@ -17,4 +19,4 @@
|
||||
[tool]
|
||||
[tool.setuptools]
|
||||
[tool.setuptools.package-data]
|
||||
pulumi_dockerbuild = ["py.typed", "pulumi-plugin.json"]
|
||||
pulumi_docker_build = ["py.typed", "pulumi-plugin.json"]
|
||||
|
||||
Reference in New Issue
Block a user