github.com/cdmixer/woolloomooloo@v0.1.0/pkg/resource/deploy/target.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 deploy 16 17 import ( 18 "github.com/pulumi/pulumi/sdk/v2/go/common/resource" 19 "github.com/pulumi/pulumi/sdk/v2/go/common/resource/config" 20 "github.com/pulumi/pulumi/sdk/v2/go/common/tokens" 21 ) 22 23 // Target represents information about a deployment target. 24 type Target struct { 25 Name tokens.QName // the target stack name. 26 Config config.Map // optional configuration key/value pairs. 27 Decrypter config.Decrypter // decrypter for secret configuration values. 28 Snapshot *Snapshot // the last snapshot deployed to the target. 29 } 30 31 // GetPackageConfig returns the set of configuration parameters for the indicated package, if any. 32 func (t *Target) GetPackageConfig(pkg tokens.Package) (resource.PropertyMap, error) { 33 result := resource.PropertyMap{} 34 if t == nil { 35 return result, nil 36 } 37 38 for k, c := range t.Config { 39 if tokens.Package(k.Namespace()) != pkg { 40 continue 41 } 42 43 v, err := c.Value(t.Decrypter) 44 if err != nil { 45 return nil, err 46 } 47 48 propertyValue := resource.NewStringProperty(v) 49 if c.Secure() { 50 propertyValue = resource.MakeSecret(propertyValue) 51 } 52 result[resource.PropertyKey(k.Name())] = propertyValue 53 } 54 return result, nil 55 }