pulumi/tests/integration/component_provider_schema/testcomponent-go/main.go
Justin Van Patten fe603568fd
Use provider.MainWithOptions to reduce boilerplate in integration tests (#7684)
We can use the new `provider.MainWithOptions` to reduce boilerplate in some of our testcomponent providers.

Also, while cleaning up here, I took this as an opportunity to replace use of `github.com/pkg/errors` in the `tests` dir to use the built-in functionality of the Go standard library.
2021-07-30 06:31:17 -07:00

36 lines
931 B
Go

// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
package main
import (
"fmt"
"os"
"github.com/pulumi/pulumi/pkg/v3/resource/provider"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
pulumiprovider "github.com/pulumi/pulumi/sdk/v3/go/pulumi/provider"
)
const providerName = "testcomponent"
const version = "0.0.1"
func main() {
var schema string
if _, ok := os.LookupEnv("INCLUDE_SCHEMA"); ok {
schema = `{"hello": "world"}`
}
err := provider.MainWithOptions(provider.Options{
Name: providerName,
Version: version,
Schema: []byte(schema),
Construct: func(ctx *pulumi.Context, typ, name string,
inputs pulumiprovider.ConstructInputs, options pulumi.ResourceOption) (*pulumiprovider.ConstructResult, error) {
return nil, fmt.Errorf("unknown resource type %s", typ)
},
})
if err != nil {
cmdutil.ExitError(err.Error())
}
}