public void MergeComponent() { var awsDefault = new DependencyProviderResource("urn:pulumi:stack::project::pulumi:providers:aws::default_4_13_0"); var awsExplicit = new DependencyProviderResource("urn:pulumi:stack::project::pulumi:providers:aws::explicit"); var azureDefault = new DependencyProviderResource("urn:pulumi:stack::project::pulumi:providers:azure::default_4_13_0"); var o1 = new ComponentResourceOptions { Providers = new List <ProviderResource> { awsDefault, azureDefault }, Protect = true, }; var o2 = new ComponentResourceOptions { Providers = new List <ProviderResource> { awsExplicit }, Protect = false, }; var result = ComponentResourceOptions.Merge(o1, o2); Assert.False(result.Protect); Assert.Equal(azureDefault, result.Providers[0]); Assert.Equal(awsExplicit, result.Providers[1]); Assert.Equal(2, result.Providers.Count); }
private static ComponentResourceOptions MakeResourceOptions(ComponentResourceOptions?options, Input <string>?id) { var defaultOptions = new ComponentResourceOptions { Version = Utilities.Version, }; var merged = ComponentResourceOptions.Merge(defaultOptions, options); // Override the ID if one was specified for consistency with other language SDKs. merged.Id = id ?? merged.Id; return(merged); }
public ComponentSixParent(string name, ComponentResourceOptions options = null) : base("my:module:ComponentSixParent-v10", name, ComponentResourceOptions.Merge(options, new ComponentResourceOptions { // Add an alias that references the old type of this resource // and then make the base() call with the new type of this resource and the added alias. Aliases = GenerateAliases() })) { this.child = new ComponentSix("child", new ComponentResourceOptions { Parent = this }); }
public ComponentFour(string name, ComponentResourceOptions options = null) : base("my:differentmodule:ComponentFourWithADifferentTypeName", name, ComponentResourceOptions.Merge(options, new ComponentResourceOptions { // Add an alias that references the old type of this resource // and then make the base() call with the new type of this resource and the added alias. Aliases = { new Alias { Type = "my:module:ComponentFour" } } })) { // The child resource will also pick up an implicit alias due to the new type of the component it is parented to. this.resource = new Resource("otherchild", new ComponentResourceOptions { Parent = this }); }
public ComponentSix(string name, ComponentResourceOptions options = null) : base("my:module:ComponentSix-v100", name, ComponentResourceOptions.Merge(options, new ComponentResourceOptions { // Add an alias that references the old type of this resource // and then make the base() call with the new type of this resource and the added alias. Aliases = GenerateAliases() })) { // The child resource will also pick up an implicit alias due to the new type of the component it is parented to. this.resource = new Resource("otherchild", new ComponentResourceOptions { Parent = this }); }
public Component4(string name, ComponentResourceOptions options = null) : base("my:module:Component4", name, ComponentResourceOptions.Merge( new ComponentResourceOptions { Aliases = { new Alias { NoParent = true }, new Alias { NoParent = true } }, }, options)) { }
public void MergeComponentEmpty() { var awsDefault = new DependencyProviderResource("urn:pulumi:stack::project::pulumi:providers:aws::default_4_13_0"); var awsExplicit = new DependencyProviderResource("urn:pulumi:stack::project::pulumi:providers:aws::explicit"); var azureDefault = new DependencyProviderResource("urn:pulumi:stack::project::pulumi:providers:azure::default_4_13_0"); var o1 = new ComponentResourceOptions { Providers = new List <ProviderResource> { awsDefault, azureDefault }, Provider = awsExplicit, }; Assert.Equal(o1.Providers, ComponentResourceOptions.Merge(o1, null).Providers); }
private static ComponentResourceOptions MakeResourceOptions(ComponentResourceOptions?options) { var defaultOptions = new ComponentResourceOptions { Version = Utilities.Version, Aliases = { new Pulumi.Alias { Type = "kubernetes:helm.sh/v2:Chart" }, }, }; var merged = ComponentResourceOptions.Merge(defaultOptions, options); return(merged); }
public void MergeComponentSingleton() { var aws = new DependencyProviderResource("urn:pulumi:stack::project::pulumi:providers:aws::default_4_13_0"); var o1 = new ComponentResourceOptions { Providers = new List <ProviderResource> { aws }, }; var o2 = new ComponentResourceOptions { Protect = true, }; var result = ComponentResourceOptions.Merge(o1, o2); Assert.True(result.Protect); Assert.Null(result.Provider); Assert.Equal(aws, result.Providers[0]); }
/// <summary> /// Directory is a component representing a collection of resources described by a kustomize directory (kustomization). /// </summary> /// <param name="name">Name of the kustomization (e.g., nginx-ingress).</param> /// <param name="args">Configuration options for the kustomization.</param> /// <param name="options">Resource options.</param> public Directory(string name, DirectoryArgs args, ComponentResourceOptions?options = null) : base("kubernetes:kustomize:Directory", MakeName(args, name), options) { name = GetName(args, name); var objs = Invokes.KustomizeDirectory(new KustomizeDirectoryArgs { Directory = args.Directory }); var configGroupArgs = new ConfigGroupArgs { ResourcePrefix = args.ResourcePrefix, Objs = objs, Transformations = args.Transformations }; var opts = ComponentResourceOptions.Merge(options, new ComponentResourceOptions { Parent = this }); var resources = Parser.Parse(configGroupArgs, opts); RegisterResources(resources); }