pulumi/tests/integration/transformations/go/simple/random.go

50 lines
1.0 KiB
Go

// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
//go:build !all
// +build !all
// Exposes the Random resource from the testprovider.
package main
import (
"errors"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
type Random struct {
pulumi.CustomResourceState
Length pulumi.IntOutput `pulumi:"length"`
Result pulumi.StringOutput `pulumi:"result"`
}
func NewRandom(ctx *pulumi.Context,
name string, args *RandomArgs, opts ...pulumi.ResourceOption,
) (*Random, error) {
if args == nil || args.Length == nil {
return nil, errors.New("missing required argument 'Length'")
}
var resource Random
err := ctx.RegisterResource("testprovider:index:Random", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
type randomArgs struct {
Length int `pulumi:"length"`
Prefix string `pulumi:"prefix"`
}
type RandomArgs struct {
Length pulumi.IntInput
Prefix pulumi.StringInput
}
func (RandomArgs) ElementType() reflect.Type {
return reflect.TypeOf((*randomArgs)(nil)).Elem()
}