49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package test
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"path/filepath"
|
|
|
|
"github.com/pulumi/pulumi/pkg/v2/resource/deploy/deploytest"
|
|
"github.com/pulumi/pulumi/sdk/v2/go/common/resource/plugin"
|
|
)
|
|
|
|
func GetSchema(schemaDirectoryPath, providerName string) ([]byte, error) {
|
|
return ioutil.ReadFile(filepath.Join(schemaDirectoryPath, providerName+".json"))
|
|
}
|
|
|
|
func AWS(schemaDirectoryPath string) (plugin.Provider, error) {
|
|
schema, err := GetSchema(schemaDirectoryPath, "aws")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &deploytest.Provider{
|
|
GetSchemaF: func(version int) ([]byte, error) {
|
|
return schema, nil
|
|
},
|
|
}, nil
|
|
}
|
|
|
|
func Random(schemaDirectoryPath string) (plugin.Provider, error) {
|
|
schema, err := GetSchema(schemaDirectoryPath, "random")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &deploytest.Provider{
|
|
GetSchemaF: func(version int) ([]byte, error) {
|
|
return schema, nil
|
|
},
|
|
}, nil
|
|
}
|
|
|
|
func Kubernetes(schemaDirectoryPath string) (plugin.Provider, error) {
|
|
schema, err := GetSchema(schemaDirectoryPath, "kubernetes")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &deploytest.Provider{
|
|
GetSchemaF: func(version int) ([]byte, error) {
|
|
return schema, nil
|
|
},
|
|
}, nil
|
|
}
|