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:
Bryce Lampe
2024-04-25 11:03:59 -07:00
committed by GitHub
parent 2545dd3089
commit 26c144c916
398 changed files with 65361 additions and 1702 deletions

View File

@@ -7,13 +7,16 @@ import (
"context"
"reflect"
"github.com/pulumi/pulumi-dockerbuild/sdk/go/dockerbuild/internal"
"github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
)
type Provider struct {
pulumi.ProviderResourceState
// The build daemon's address.
Host pulumi.StringPtrOutput `pulumi:"host"`
}
// NewProvider registers a new resource with the given unique name, arguments, and options.
@@ -23,9 +26,14 @@ func NewProvider(ctx *pulumi.Context,
args = &ProviderArgs{}
}
if args.Host == nil {
if d := internal.GetEnvOrDefault("", nil, "DOCKER_HOST"); d != nil {
args.Host = pulumi.StringPtr(d.(string))
}
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Provider
err := ctx.RegisterResource("pulumi:providers:dockerbuild", name, args, &resource, opts...)
err := ctx.RegisterResource("pulumi:providers:docker-build", name, args, &resource, opts...)
if err != nil {
return nil, err
}
@@ -33,20 +41,51 @@ func NewProvider(ctx *pulumi.Context,
}
type providerArgs struct {
// The build daemon's address.
Host *string `pulumi:"host"`
Registries []Registry `pulumi:"registries"`
}
// The set of arguments for constructing a Provider resource.
type ProviderArgs struct {
// The build daemon's address.
Host pulumi.StringPtrInput
Registries RegistryArrayInput
}
func (ProviderArgs) ElementType() reflect.Type {
return reflect.TypeOf((*providerArgs)(nil)).Elem()
}
type ProviderInput interface {
pulumi.Input
ToProviderOutput() ProviderOutput
ToProviderOutputWithContext(ctx context.Context) ProviderOutput
}
func (*Provider) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
}
func (i *Provider) ToProviderOutput() ProviderOutput {
return i.ToProviderOutputWithContext(context.Background())
}
func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
}
func (i *Provider) ToOutput(ctx context.Context) pulumix.Output[*Provider] {
return pulumix.Output[*Provider]{
OutputState: i.ToProviderOutputWithContext(ctx).OutputState,
}
}
type ProviderOutput struct{ *pulumi.OutputState }
func (ProviderOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Provider)(nil)).Elem()
return reflect.TypeOf((**Provider)(nil)).Elem()
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
@@ -57,12 +96,18 @@ func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) Provide
return o
}
func (o ProviderOutput) ToOutput(ctx context.Context) pulumix.Output[Provider] {
return pulumix.Output[Provider]{
func (o ProviderOutput) ToOutput(ctx context.Context) pulumix.Output[*Provider] {
return pulumix.Output[*Provider]{
OutputState: o.OutputState,
}
}
// The build daemon's address.
func (o ProviderOutput) Host() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Provider) pulumi.StringPtrOutput { return v.Host }).(pulumi.StringPtrOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
pulumi.RegisterOutputType(ProviderOutput{})
}