Skip to content

Instantly share code, notes, and snippets.

@Aagat
Created December 26, 2018 18:44
Show Gist options
  • Save Aagat/934a4a0c4ed05c6bc5f357eacda0ed27 to your computer and use it in GitHub Desktop.
Save Aagat/934a4a0c4ed05c6bc5f357eacda0ed27 to your computer and use it in GitHub Desktop.
k8s yaml deployment manifest to client-go structure
package main
import (
"fmt"
"io/ioutil"
"github.com/ghodss/yaml"
"k8s.io/api/apps/v1"
)
func main() {
bytes, err := ioutil.ReadFile("deployment.yml")
if err != nil {
panic(err.Error())
}
var spec v1.Deployment
err = yaml.Unmarshal(bytes, &spec)
if err != nil {
panic(err.Error())
}
fmt.Println("%#v", spec)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment