Skip to content

Commit

Permalink
Move yaml module into a directory
Browse files Browse the repository at this point in the history
The tsdocgen utility works better if module definitions
are split into directories. Move the yaml definitions
into a yaml directory, and update the index files
so that the usage doesn't change.
  • Loading branch information
lblackstone committed Apr 1, 2019
1 parent 313f5f2 commit 6f4025c
Show file tree
Hide file tree
Showing 9 changed files with 3,259 additions and 3,286 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Improvements

- Move helm module into a directory (https://github.com/pulumi/pulumi-kubernetes/pull/512)
- Move yaml module into a directory (https://github.com/pulumi/pulumi-kubernetes/pull/513)

### Bug fixes

Expand Down
4 changes: 2 additions & 2 deletions cmd/pulumi-gen-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
}

func writeNodeJSClient(data map[string]interface{}, outdir, templateDir string) {
inputAPIts, ouputAPIts, providerts, indexts, packagejson, groupsts, err := gen.NodeJSClient(
inputAPIts, ouputAPIts, indexts, yamlts, packagejson, groupsts, err := gen.NodeJSClient(
data, templateDir)
if err != nil {
panic(err)
Expand All @@ -83,7 +83,7 @@ func writeNodeJSClient(data map[string]interface{}, outdir, templateDir string)
panic(err)
}

err = ioutil.WriteFile(fmt.Sprintf("%s/provider.ts", outdir), []byte(providerts), 0777)
err = ioutil.WriteFile(fmt.Sprintf("%s/yaml/yaml.ts", outdir), []byte(yamlts), 0777)
if err != nil {
panic(err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/gen/nodejs-templates/providerIndex.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

export * from "./provider";
import * as helm from "./helm/index";
export { helm };
import * as yaml from "./yaml/index";
export { helm, yaml };

// Import groups
{{#Groups}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import * as fs from "fs";
import * as glob from "glob";
import * as jsyaml from "js-yaml";
import fetch from "node-fetch";
import * as k8s from "./index";
import * as outputApi from "./types/output";
import * as k8s from "../index";
import * as outputApi from "../types/output";

export namespace yaml {
export interface ConfigGroupOpts {
/** Set of paths or a URLs that uniquely identify files. */
files?: string[] | string;
Expand Down Expand Up @@ -311,48 +310,3 @@ export namespace yaml {
}))];
}
}
}

/**
* The provider type for the kubernetes package.
*/
export class Provider extends pulumi.ProviderResource {
/**
* Create a Provider resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: ProviderArgs, opts?: pulumi.ResourceOptions) {
let inputs: pulumi.Inputs = {
"cluster": args ? args.cluster : undefined,
"context": args ? args.context : undefined,
"kubeconfig": args ? args.kubeconfig : undefined,
"namespace": args ? args.namespace : undefined,
};
super("kubernetes", name, inputs, opts);
}
}

/**
* The set of arguments for constructing a Provider.
*/
export interface ProviderArgs {
/**
* If present, the name of the kubeconfig cluster to use.
*/
readonly cluster?: pulumi.Input<string>;
/**
* If present, the name of the kubeconfig context to use.
*/
readonly context?: pulumi.Input<string>;
/**
* The contents of a kubeconfig file. If this is set, this config will be used instead of $KUBECONFIG.
*/
readonly kubeconfig?: pulumi.Input<string>;
/**
* If present, the namespace scope to use.
*/
readonly namespace?: pulumi.Input<string>;
}
14 changes: 7 additions & 7 deletions pkg/gen/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type VersionTS struct {

// NodeJSClient will generate a Pulumi Kubernetes provider client SDK for nodejs.
func NodeJSClient(swagger map[string]interface{}, templateDir string,
) (inputsts, outputsts, providerts, indexts, packagejson string, groupsts map[string]*GroupTS, err error) {
) (inputsts, outputsts, indexts, yamlts, packagejson string, groupsts map[string]*GroupTS, err error) {
definitions := swagger["definitions"].(map[string]interface{})

groupsSlice := createGroups(definitions, nodeJSInputs())
Expand Down Expand Up @@ -114,29 +114,29 @@ func NodeJSClient(swagger map[string]interface{}, templateDir string,
groupsts[group.Group()] = groupTS
}

providerts, err = mustache.RenderFile(fmt.Sprintf("%s/provider.ts.mustache", templateDir),
packagejson, err = mustache.RenderFile(fmt.Sprintf("%s/package.json.mustache", templateDir),
map[string]interface{}{
"Groups": groupsSlice,
"ProviderVersion": providerVersion.Version,
})
if err != nil {
return
}

packagejson, err = mustache.RenderFile(fmt.Sprintf("%s/package.json.mustache", templateDir),
indexts, err = mustache.RenderFile(fmt.Sprintf("%s/providerIndex.ts.mustache", templateDir),
map[string]interface{}{
"ProviderVersion": providerVersion.Version,
"Groups": groupsSlice,
})
if err != nil {
return
}

indexts, err = mustache.RenderFile(fmt.Sprintf("%s/providerIndex.ts.mustache", templateDir),
yamlts, err = mustache.RenderFile(fmt.Sprintf("%s/yaml.ts.mustache", templateDir),
map[string]interface{}{
"Groups": groupsSlice,
})
if err != nil {
return
}

return inputsts, outputsts, providerts, indexts, packagejson, groupsts, nil
return inputsts, outputsts, indexts, yamlts, packagejson, groupsts, nil
}
3 changes: 2 additions & 1 deletion sdk/nodejs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

export * from "./provider";
import * as helm from "./helm/index";
export { helm };
import * as yaml from "./yaml/index";
export { helm, yaml };

// Import groups
import * as admissionregistration from "./admissionregistration/index";
Expand Down
Loading

0 comments on commit 6f4025c

Please sign in to comment.