github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/resource/deploy/deploytest/backendclient.go (about)

     1  // Copyright 2016-2018, Pulumi Corporation.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package deploytest
    16  
    17  import (
    18  	"context"
    19  
    20  	"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
    21  )
    22  
    23  // BackendClient provides a simple implementation of deploy.BackendClient that defers to a function value.
    24  type BackendClient struct {
    25  	GetStackOutputsF         func(ctx context.Context, name string) (resource.PropertyMap, error)
    26  	GetStackResourceOutputsF func(ctx context.Context, name string) (resource.PropertyMap, error)
    27  }
    28  
    29  // GetStackOutputs returns the outputs (if any) for the named stack or an error if the stack cannot be found.
    30  func (b *BackendClient) GetStackOutputs(ctx context.Context, name string) (resource.PropertyMap, error) {
    31  	return b.GetStackOutputsF(ctx, name)
    32  }
    33  
    34  // GetStackResourceOutputs returns the resource outputs for a stack, or an error if the stack
    35  // cannot be found. Resources are retrieved from the latest stack snapshot, which may include
    36  // ongoing updates. They are returned in a `PropertyMap` mapping resource URN to another
    37  // `Propertymap` with members `type` (containing the Pulumi type ID for the resource) and
    38  // `outputs` (containing the resource outputs themselves).
    39  func (b *BackendClient) GetStackResourceOutputs(
    40  	ctx context.Context, name string) (resource.PropertyMap, error) {
    41  	return b.GetStackResourceOutputsF(ctx, name)
    42  }