-
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.
Add apiextensions.CustomResource to Go SDK (#1125)
- Loading branch information
1 parent
3a3095d
commit 12bf7f9
Showing
33 changed files
with
1,077 additions
and
23 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
129 changes: 129 additions & 0 deletions
129
provider/pkg/gen/go-templates/apiextensions/customResource.tmpl
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,129 @@ | ||
// 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 apiextensions | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
|
||
"github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes" | ||
metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v2/go/kubernetes/meta/v1" | ||
"github.com/pulumi/pulumi/sdk/v2/go/pulumi" | ||
) | ||
|
||
// CustomResource represents a resource definition we'd use to create an instance of a | ||
// Kubernetes CustomResourceDefinition (CRD). For example, the CoreOS Prometheus operator | ||
// exposes a CRD `monitoring.coreos.com/ServiceMonitor`; to create a `ServiceMonitor`, we'd | ||
// pass a `CustomResourceArgs` containing the `ServiceMonitor` definition to `apiextensions.CustomResource`. | ||
type CustomResource struct { | ||
pulumi.CustomResourceState | ||
|
||
// APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | ||
ApiVersion pulumi.StringOutput `pulumi:"apiVersion"` | ||
// Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
Kind pulumi.StringOutput `pulumi:"kind"` | ||
// Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata. | ||
Metadata metav1.ObjectMetaPtrOutput `pulumi:"metadata"` | ||
// Untyped map that holds any user-defined fields. | ||
OtherFields pulumi.MapOutput `pulumi:""` | ||
} | ||
|
||
// NewCustomResource registers a new resource with the given unique name, arguments, and options. | ||
func NewCustomResource(ctx *pulumi.Context, | ||
name string, args *CustomResourceArgs, opts ...pulumi.ResourceOption) (*CustomResource, error) { | ||
if args == nil { | ||
args = &CustomResourceArgs{} | ||
} | ||
|
||
untyped := kubernetes.UntypedArgs{} | ||
for k, v := range args.OtherFields { | ||
untyped[k] = v | ||
} | ||
untyped["apiVersion"] = args.ApiVersion | ||
untyped["kind"] = args.Kind | ||
untyped["metadata"] = args.Metadata | ||
|
||
var resource CustomResource | ||
err := ctx.RegisterResource(fmt.Sprintf("kubernetes:%s:%s", args.ApiVersion, args.Kind), name, untyped, &resource, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &resource, nil | ||
} | ||
|
||
// GetCustomResource gets an existing CustomResource resource's state with the given name, ID, and optional | ||
// state properties that are used to uniquely qualify the lookup (nil if not required). | ||
func GetCustomResource(ctx *pulumi.Context, | ||
name string, id pulumi.IDInput, state *CustomResourceState, opts ...pulumi.ResourceOption) (*CustomResource, error) { | ||
var resource CustomResource | ||
err := ctx.ReadResource(fmt.Sprintf("kubernetes:%s:%s", state.ApiVersion, state.Kind), name, id, state, &resource, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &resource, nil | ||
} | ||
|
||
// Input properties used for looking up and filtering CustomResource resources. | ||
type customResourceState struct { | ||
// APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | ||
ApiVersion *string `pulumi:"apiVersion"` | ||
// Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
Kind *string `pulumi:"kind"` | ||
// Standard object metadata. | ||
Metadata *metav1.ObjectMeta `pulumi:"metadata"` | ||
} | ||
|
||
type CustomResourceState struct { | ||
// APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | ||
ApiVersion pulumi.StringPtrInput | ||
// Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
Kind pulumi.StringPtrInput | ||
// Standard object metadata. | ||
Metadata metav1.ObjectMetaPtrInput | ||
} | ||
|
||
func (CustomResourceState) ElementType() reflect.Type { | ||
return reflect.TypeOf((*customResourceState)(nil)).Elem() | ||
} | ||
|
||
type customResourceArgs struct { | ||
// APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | ||
ApiVersion string `pulumi:"apiVersion"` | ||
// Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
Kind string `pulumi:"kind"` | ||
// Standard object metadata. | ||
Metadata *metav1.ObjectMeta `pulumi:"metadata"` | ||
// Untyped map that holds any user-defined fields. | ||
OtherFields map[string]interface{} `pulumi:""` | ||
} | ||
|
||
// The set of arguments for constructing a Deployment resource. | ||
type CustomResourceArgs struct { | ||
// APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | ||
ApiVersion pulumi.StringInput | ||
// Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
Kind pulumi.StringInput | ||
// Standard object metadata. | ||
Metadata metav1.ObjectMetaPtrInput | ||
// Untyped map that holds any user-defined fields. | ||
OtherFields kubernetes.UntypedArgs | ||
} | ||
|
||
func (CustomResourceArgs) ElementType() reflect.Type { | ||
return reflect.TypeOf((*customResourceArgs)(nil)).Elem() | ||
} |
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
Oops, something went wrong.