kubernetes

package module
v0.0.0-...-8cb36ec Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

viper-kubernetes

Provides Viper Remote Config from Kubernetes ConfigMaps and Secrets

Usage

package main

import (
	"log"
	"github.com/spf13/viper"
	_ "github.com/neermitt/viper-kubernetes"
)

func main() {
		v := viper.New()
    
    	err := v.AddRemoteProvider("secret", "dummy", "secretname/key")
    	if err != nil {
    		log.Printf("Failed to add remote provider %v", err)
    	}
    	v.SetConfigType("yaml")
    	err = v.ReadRemoteConfig()
    	if err != nil {
    		log.Printf("Failed to read remote config %v", err)
    	}
    	
    	log.Print(v.GetString("my.property.name"))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigFromReader

func GetConfigFromReader(configPath string) (*rest.Config, error)

Types

type ConfigManager

type ConfigManager interface {
	Get(key string) ([]byte, error)
	Watch(key string, stop chan bool) <-chan *Response
}

A ConfigManager retrieves and decrypts configuration from a key/value store.

func NewConfigMapConfigManager

func NewConfigMapConfigManager(configPath string) (ConfigManager, error)

func NewSecretConfigManager

func NewSecretConfigManager(configPath string) (ConfigManager, error)

type ConfigMapConfigManager

type ConfigMapConfigManager struct {
	Client kubernetes.Interface
}

func (ConfigMapConfigManager) Get

func (kcm ConfigMapConfigManager) Get(key string) ([]byte, error)

func (ConfigMapConfigManager) Watch

func (kcm ConfigMapConfigManager) Watch(key string, stop chan bool) <-chan *Response

type Response

type Response struct {
	Value []byte
	Error error
}

type SecretConfigManager

type SecretConfigManager struct {
	Client kubernetes.Interface
}

func (SecretConfigManager) Get

func (scm SecretConfigManager) Get(key string) ([]byte, error)

func (SecretConfigManager) Watch

func (scm SecretConfigManager) Watch(key string, stop chan bool) <-chan *Response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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