Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Starlark code generator #45

Merged
merged 8 commits into from
May 22, 2020
Merged

Conversation

jonnylangefeld
Copy link
Collaborator

@jonnylangefeld jonnylangefeld commented May 20, 2020

Try it out:

isopod generate testdata/generator/clusterrolebinding.yaml 

Works with yaml or json.
The code generator uses the kubernetes parser to get runtime.Objects.
Reflect and a recursive function is used to generate the starlark code.

The test covers all code by generating multiple files.

Fix #46

Supports CRD
Supports kube.put for now, so that's all k8s resources. Should support kube.put_yaml later for custom resources

@jonnylangefeld jonnylangefeld requested a review from cxuu May 20, 2020 03:54
Try it out:
```
isopod generate testdata/clusterrolebinding.yaml
```

Works with yaml or python.
The code generator uses the kubernetes parser to get `runtime.Object`s.
Reflect and a recursive function is used to generate the python code.

The test covers all code by generating an entire file.
@jonnylangefeld jonnylangefeld force-pushed the jlf/starlark-code-generator branch 4 times, most recently from 4a2aa30 to 492529b Compare May 20, 2020 16:14
pkg/runtime/generate.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@cxuu cxuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so cool! Thank you for implementing this!

pkg/runtime/generate.go Outdated Show resolved Hide resolved
pkg/runtime/generate.go Outdated Show resolved Hide resolved
pkg/runtime/generate.go Outdated Show resolved Hide resolved
pkg/runtime/generate.go Outdated Show resolved Hide resolved
pkg/runtime/generate.go Show resolved Hide resolved
pkg/runtime/generate.go Show resolved Hide resolved
pkg/runtime/generate.go Outdated Show resolved Hide resolved
pkg/runtime/generate_test.go Outdated Show resolved Hide resolved
pkg/runtime/runtime.go Outdated Show resolved Hide resolved
the method in the previous commit didnt work, because the string slice was in a different order than the value slice. They had to be ordered at the same time. The solution now is to introduce a separate map, that maps from strinkKey => valueKey. Now its bullet proof.
@jonnylangefeld jonnylangefeld merged commit 617ccb7 into master May 22, 2020
@jonnylangefeld jonnylangefeld deleted the jlf/starlark-code-generator branch May 22, 2020 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add Starlark code generator
3 participants