Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wozniakjan/reverse-kube-resource

Revert kubernetes yaml files to native go code
https://github.com/wozniakjan/reverse-kube-resource

golang kubernetes yaml

Last synced: 3 months ago
JSON representation

Revert kubernetes yaml files to native go code

Awesome Lists containing this project

README

        

Reverse Kube Resources
===

![test](https://github.com/wozniakjan/reverse-kube-resource/actions/workflows/test.yaml/badge.svg)

This tool is intended to generate golang code tightly coupled with [Kubernetes client-go](https://github.com/kubernetes/client-go).

The input are raw yaml manifests and the tool leverages Kubernetes scheme to generate valid golang structures compatible with client-go.

### Example:
The directory [`examples`](./examples) contains few sample yaml files with kubernetes resources.

```yaml
apiVersion: v1
kind: Namespace
metadata:
name: test
spec: {}
status: {}
```

After executing the generator with following arguments:
```
$ go run github.com/wozniakjan/reverse-kube-resource -package test -src ./examples/ns.yaml > output/ns.go
```

The output is a buildable go file:
```go
// Code generated by reverse-kube-resource. DO NOT EDIT.

package test

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var testNamespace = corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
Spec: corev1.NamespaceSpec{},
Status: corev1.NamespaceStatus{},
}
```