lyraproj / hierasdk

Software Development Kit for building lookup function plugins for Hiera

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Software Development Kit for hiera lookup functions

This module provides the API to create and run RESTful Hiera lookup plugins. Such a plugin can publish a set of Hiera lookup functions (i.e. data_dig, data_hash, or lookup_key functions) and make them available using https RESTful calls.

How to use

hierasdk is a Go module and is best installed using the command:

go get github.com/lyraproj/hierasdk

Example plugin

Skeleton plugin that provides one single data_hash function:

package main

import (
  "github.com/lyraproj/hierasdk/hiera"
  "github.com/lyraproj/hierasdk/plugin"
  "github.com/lyraproj/hierasdk/register"
  "github.com/lyraproj/hierasdk/vf"
)

func main() {
  // Register the data_hash function with the global registry
  register.DataHash(`my_data_hash`, myDataHash)

  // Start RESTful service that makes all registered functions available
  plugin.ServeAndExit()
}

func myDataHash(c hiera.ProviderContext) vf.Data {
  var dh map[string]interface{}
  // lookup data hash here and return it
  return vf.ToData(dh)
}

Third party dependencies

None.

About

Software Development Kit for building lookup function plugins for Hiera

License:Apache License 2.0


Languages

Language:Go 100.0%