-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5dde74
commit 54b5f76
Showing
27 changed files
with
2,331 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright 2016-2020, Pulumi Corporation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// *** WARNING: this file was generated by pulumigen. *** | ||
// *** Do not edit by hand unless you're certain you know what you are doing! *** | ||
|
||
package yaml | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/pulumi/pulumi/sdk/v2/go/pulumi" | ||
) | ||
|
||
// ConfigFile creates a set of Kubernetes resources from a Kubernetes YAML file. | ||
type ConfigFile struct { | ||
pulumi.ResourceState | ||
|
||
Resources map[string]pulumi.Resource | ||
} | ||
|
||
// The set of arguments for constructing a ConfigFile resource. | ||
type ConfigFileArgs struct { | ||
// File is a path or URL that uniquely identifies a file. | ||
File string | ||
// Transformations is an optional list of transformations to apply to Kubernetes resource definitions | ||
// before registering with the engine. | ||
Transformations []Transformation | ||
// ResourcePrefix is an optional prefix for the auto-generated resource names. For example, a resource named `bar` | ||
// created with resource prefix of `"foo"` would produce a resource named `"foo-bar"`. | ||
ResourcePrefix string | ||
} | ||
|
||
// NewConfigFile registers a new resource with the given unique name, arguments, and options. | ||
func NewConfigFile(ctx *pulumi.Context, | ||
name string, args *ConfigFileArgs, opts ...pulumi.ResourceOption) (*ConfigFile, error) { | ||
|
||
// Register the resulting resource state. | ||
configFile := &ConfigFile{ | ||
Resources: map[string]pulumi.Resource{}, | ||
} | ||
err := ctx.RegisterComponentResource("kubernetes:yaml:ConfigFile", name, configFile, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Now provision all child resources by parsing the YAML file. | ||
if args != nil { | ||
// Honor the resource name prefix if specified. | ||
if args.ResourcePrefix != "" { | ||
name = args.ResourcePrefix + "-" + name | ||
} | ||
|
||
// Parse and decode the YAML files. | ||
rs, err := parseDecodeYamlFiles(ctx, &ConfigGroupArgs{ | ||
Files: []string{args.File}, | ||
Transformations: args.Transformations, | ||
ResourcePrefix: args.ResourcePrefix, | ||
}, true, pulumi.Parent(configFile)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
configFile.Resources = rs | ||
} | ||
|
||
// Finally, register all of the resources found. | ||
err = ctx.RegisterResourceOutputs(configFile, pulumi.Map{}) | ||
if err != nil { | ||
return nil, errors.Wrapf(err, "registering child resources") | ||
} | ||
|
||
return configFile, nil | ||
} | ||
|
||
// GetResource returns a resource defined by a built-in Kubernetes group/version/kind, name and namespace. | ||
// For example, GetResource("v1/Pod", "foo", "") would return a Pod called "foo" from the "default" namespace. | ||
func (cf *ConfigFile) GetResource(gvk, name, namespace string) pulumi.Resource { | ||
id := name | ||
if len(namespace) > 0 && namespace != "default" { | ||
id = fmt.Sprintf("%s/%s", namespace, name) | ||
} | ||
key := fmt.Sprintf("%s::%s", gvk, id) | ||
return cf.Resources[key] | ||
} |
Oops, something went wrong.