// *** WARNING: this file was generated by pulumi-language-dotnet. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.DockerBuild
{
///
/// 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
/// ```csharp
/// using System.Collections.Generic;
/// using System.Linq;
/// using Pulumi;
/// using DockerBuild = Pulumi.DockerBuild;
///
/// return await Deployment.RunAsync(() =>
/// {
/// var amd64 = new DockerBuild.Image("amd64", new()
/// {
/// CacheFrom = new[]
/// {
/// new DockerBuild.Inputs.CacheFromArgs
/// {
/// Registry = new DockerBuild.Inputs.CacheFromRegistryArgs
/// {
/// Ref = "docker.io/pulumi/pulumi:cache-amd64",
/// },
/// },
/// },
/// CacheTo = new[]
/// {
/// new DockerBuild.Inputs.CacheToArgs
/// {
/// Registry = new DockerBuild.Inputs.CacheToRegistryArgs
/// {
/// Mode = DockerBuild.CacheMode.Max,
/// Ref = "docker.io/pulumi/pulumi:cache-amd64",
/// },
/// },
/// },
/// Context = new DockerBuild.Inputs.BuildContextArgs
/// {
/// Location = "app",
/// },
/// Platforms = new[]
/// {
/// DockerBuild.Platform.Linux_amd64,
/// },
/// Tags = new[]
/// {
/// "docker.io/pulumi/pulumi:3.107.0-amd64",
/// },
/// });
///
/// var arm64 = new DockerBuild.Image("arm64", new()
/// {
/// CacheFrom = new[]
/// {
/// new DockerBuild.Inputs.CacheFromArgs
/// {
/// Registry = new DockerBuild.Inputs.CacheFromRegistryArgs
/// {
/// Ref = "docker.io/pulumi/pulumi:cache-arm64",
/// },
/// },
/// },
/// CacheTo = new[]
/// {
/// new DockerBuild.Inputs.CacheToArgs
/// {
/// Registry = new DockerBuild.Inputs.CacheToRegistryArgs
/// {
/// Mode = DockerBuild.CacheMode.Max,
/// Ref = "docker.io/pulumi/pulumi:cache-arm64",
/// },
/// },
/// },
/// Context = new DockerBuild.Inputs.BuildContextArgs
/// {
/// Location = "app",
/// },
/// Platforms = new[]
/// {
/// DockerBuild.Platform.Linux_arm64,
/// },
/// Tags = new[]
/// {
/// "docker.io/pulumi/pulumi:3.107.0-arm64",
/// },
/// });
///
/// var index = new DockerBuild.Index("index", new()
/// {
/// Sources = new[]
/// {
/// amd64.Ref,
/// arm64.Ref,
/// },
/// Tag = "docker.io/pulumi/pulumi:3.107.0",
/// });
///
/// return new Dictionary<string, object?>
/// {
/// ["ref"] = index.Ref,
/// };
/// });
///
/// ```
///
[DockerBuildResourceType("docker-build:index:Index")]
public partial class Index : global::Pulumi.CustomResource
{
///
/// If true, push the index to the target registry.
///
/// Defaults to `true`.
///
[Output("push")]
public Output Push { get; private set; } = null!;
///
/// The pushed tag with digest.
///
/// Identical to the tag if the index was not pushed.
///
[Output("ref")]
public Output Ref { get; private set; } = null!;
///
/// Authentication for the registry where the tagged index will be pushed.
///
/// Credentials can also be included with the provider's configuration.
///
[Output("registry")]
public Output Registry { get; private set; } = null!;
///
/// Existing images to include in the index.
///
[Output("sources")]
public Output> Sources { get; private set; } = null!;
///
/// The tag to apply to the index.
///
[Output("tag")]
public Output Tag { get; private set; } = null!;
///
/// Create a Index resource with the given unique name, arguments, and options.
///
///
/// The unique name of the resource
/// The arguments used to populate this resource's properties
/// A bag of options that control this resource's behavior
public Index(string name, IndexArgs args, CustomResourceOptions? options = null)
: base("docker-build:index:Index", name, args ?? new IndexArgs(), MakeResourceOptions(options, ""))
{
}
private Index(string name, Input id, CustomResourceOptions? options = null)
: base("docker-build:index:Index", name, null, MakeResourceOptions(options, id))
{
}
private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input? id)
{
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
};
var merged = CustomResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
merged.Id = id ?? merged.Id;
return merged;
}
///
/// Get an existing Index resource's state with the given name, ID, and optional extra
/// properties used to qualify the lookup.
///
///
/// The unique name of the resulting resource.
/// The unique provider ID of the resource to lookup.
/// A bag of options that control this resource's behavior
public static Index Get(string name, Input id, CustomResourceOptions? options = null)
{
return new Index(name, id, options);
}
}
public sealed class IndexArgs : global::Pulumi.ResourceArgs
{
///
/// If true, push the index to the target registry.
///
/// Defaults to `true`.
///
[Input("push")]
public Input? Push { get; set; }
///
/// Authentication for the registry where the tagged index will be pushed.
///
/// Credentials can also be included with the provider's configuration.
///
[Input("registry")]
public Input? Registry { get; set; }
[Input("sources", required: true)]
private InputList? _sources;
///
/// Existing images to include in the index.
///
public InputList Sources
{
get => _sources ?? (_sources = new InputList());
set => _sources = value;
}
///
/// The tag to apply to the index.
///
[Input("tag", required: true)]
public Input Tag { get; set; } = null!;
public IndexArgs()
{
Push = true;
}
public static new IndexArgs Empty => new IndexArgs();
}
}