/usr/share/gocode/src/github.com/go-chef/chef/examples/cookbooks/cookbooks.go is in golang-github-go-chef-chef-dev 0.0.1+git20161023.60.deb8c38-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/go-chef/chef"
)
func main() {
// simple arg parsing
//cookPath := flag.String("cookbook", "c", "Path to cookbook for upload")
// flag.Parse()
// read a client key
key, err := ioutil.ReadFile("key.pem")
if err != nil {
fmt.Println("Couldn't read key.pem:", err)
os.Exit(1)
}
// build a client
client, err := chef.NewClient(&chef.Config{
Name: "foo",
Key: string(key),
// goiardi is on port 4545 by default. chef-zero is 8889
BaseURL: "http://localhost:8443",
})
if err != nil {
fmt.Println("Issue setting up client:", err)
os.Exit(1)
}
// List Cookbooks
cookList, err := client.Cookbooks.List()
if err != nil {
fmt.Println("Issue listing cookbooks:", err)
}
// Print out the list
fmt.Println(cookList)
/*
*'parse' metadata...
this would prefer .json over .rb
if it's .rb lets maybe try to eval it ?
otherwise just extract name/version if they exist
*/
/*
* generate sums
* create sandbox
* upload to sandbox
*
*/
}
|