chef

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2022 License: BSD-3-Clause Imports: 21 Imported by: 0

README

chef GoDoc

Functions

  • client(client_name, path_to_file_with_key, chef_url, http_client_ud) - returns chef client instance for further usage. Required http client instance as http_client_ud. Please note that you must specify last slash in chef_url.

Methods

client
  • search(index, query, [partical_data], [params] - make search by given INDEX and query. Also possible use partical search and specify offset, limit, order_by in params.
  • request(verb, url) - make request to chef server.

Examples


local http = require("http")
local chef = require("chef")
local inspect = require("inspect")

local http_client = http.client({insecure_ssl=true})
local client = chef.client(
    "client_name",
    "path/to/client.pem",
    "https://chef.org/organizations/org/",
    http_client
)

-- list nodes
local result, err = client:request("GET", "nodes")
if err then error(err) end
print(inspect(result)) -- { [node_name_1=url_node_name_1], [node_name_2=url_node_name_2] }

-- get node
local result, err = client:request("GET", "nodes/node_name")
print(result.name)
-- chef node:
--  result.name
-- attributes
--  result.automatic
--  result.default
--  result.normal
--  result.override


-- search node
local result, err = client:search("node", "fqdn:node_name")
print(result.total) -- total count
print(result.start) -- offset
print(inspect(result.rows)) -- table of nodes

-- partical search node
local result, err = client:search("node", "fqdn:node_name", {result_fqdn = {"fqdn"}})
print(inspect(result.rows)) -- table of results
print(result.rows[1]) -- {data = {result_fqdn = "node_name" }}

-- partical search node: limit = 2000, offset = 0, order by X_CHEF_id_CHEF_X asc
local result, err = client:search("node", "fqdn:node_name", {result_fqdn = {"fqdn"}}, {start=0, rows=2000})

Documentation

Overview

Package chef implements chef client api functionality for lua.

Index

Constants

View Source
const (
	ChefVersion = "11.12.0" // default client version
)

Variables

This section is empty.

Functions

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func NewClient

func NewClient(L *lua.LState) int

NewClient lua chef.client(client_name, path_to_file_with_key, chef_url, http_client_ud) returns (chef_client_ud, err)

func Preload

func Preload(L *lua.LState)

Preload adds chef to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:

local chef = require("chef")

func Request

func Request(L *lua.LState) int

Request lua chef_client_ud:request("GET|POST|PUT", "/api/path", "body") returns (table, error)

func Search(L *lua.LState) int

Search lua chef_client_ud:search( "index", "query",

"partical"={
  "return_name" = ["node_attribute_name"],
},
params={
   sort_by = "X_CHEF_id_CHEF_X asc",
   start = 0,
   rows  = 1000
}

) returns (table, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL