/// <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); }
private Output <ImmutableDictionary <string, KubernetesResource> > ParseTemplate(string text, List <TransformationAction> transformations, string?resourcePrefix, ImmutableHashSet <Resource> dependsOn, string?defaultNamespace) { return(Invokes .YamlDecode(new YamlDecodeArgs { Text = text, DefaultNamespace = defaultNamespace }) .Apply(objs => { var args = new ConfigGroupArgs { ResourcePrefix = resourcePrefix, Objs = objs, Transformations = transformations }; var opts = new ComponentResourceOptions { Parent = this, DependsOn = dependsOn.ToArray() }; return Parser.Parse(args, opts); })); }
private Output <ImmutableDictionary <string, KubernetesResource> > ParseTemplate(Union <ChartArgsUnwrap, LocalChartArgsUnwrap> args, string releaseName, ImmutableHashSet <Resource> dependsOn) { // Build JSON args to Helm provider invoke. var serializeOptions = new JsonSerializerOptions { IgnoreNullValues = true, }; BaseChartArgsUnwrap cfgBase; // Convert args to JSON string format expected by the invoke function. JsonOpts jsonOpts; string jsonOptsString; if (args.IsT0) { var cfg = args.AsT0; cfgBase = cfg; jsonOpts = new JsonOpts { ApiVersions = cfgBase.ApiVersions, IncludeTestHookResources = cfgBase.IncludeTestHookResources, Namespace = cfgBase.Namespace, Values = cfgBase.Values, ReleaseName = releaseName, Repo = cfg.Repo, Chart = cfg.Chart, Version = cfg.Version, }; if (cfg.FetchOptions != null) { jsonOpts.FetchOptions = new JsonOptsFetch { Version = cfg.FetchOptions.Version, CAFile = cfg.FetchOptions.CAFile, CertFile = cfg.FetchOptions.CertFile, KeyFile = cfg.FetchOptions.KeyFile, Destination = cfg.FetchOptions.Destination, Keyring = cfg.FetchOptions.Keyring, Password = cfg.FetchOptions.Password, Repo = cfg.FetchOptions.Repo, UntarDir = cfg.FetchOptions.UntarDir, Username = cfg.FetchOptions.Username, Home = cfg.FetchOptions.Home, Devel = cfg.FetchOptions.Devel, Prov = cfg.FetchOptions.Prov, Untar = cfg.FetchOptions.Untar, Verify = cfg.FetchOptions.Verify, }; } } else { var cfg = args.AsT1; cfgBase = cfg; jsonOpts = new JsonOpts { ApiVersions = cfgBase.ApiVersions, IncludeTestHookResources = cfgBase.IncludeTestHookResources, Namespace = cfgBase.Namespace, Values = cfgBase.Values, ReleaseName = releaseName, Path = cfg.Path, }; } jsonOptsString = JsonSerializer.Serialize(jsonOpts, serializeOptions); return(Invokes .HelmTemplate(new HelmTemplateArgs { JsonOpts = jsonOptsString }) .Apply(objs => { var args = new ConfigGroupArgs { ResourcePrefix = cfgBase.ResourcePrefix, Objs = objs, Transformations = cfgBase.Transformations }; var opts = new ComponentResourceOptions { Parent = this, DependsOn = dependsOn.ToArray() }; return Parser.Parse(args, opts); })); }