noop

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package noop provider. Runs a command with the environment variables from the environment variables.

Index

Examples

Constants

View Source
const Name = "noop"

Name of the provider.

Variables

This section is empty.

Functions

func New

func New(override, rawValue bool) (provider.IProvider, error)

New sets up a new NoOp provider.

Example

ExampleNew creates a new noop instance and loads from it.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/thalesfsp/configurer/noop"
	"github.com/thalesfsp/configurer/util"
)

func main() {
	const key = "TEST_KEY"

	os.Setenv(key, "TEST_VALUE")
	defer os.Unsetenv(key)

	// Instantiate the provider of choice, in this case noop.
	de, err := noop.New(false, false)
	if err != nil {
		panic(err)
	}

	// Load will export to the environment all the variables.
	if _, err := de.Load(context.Background()); err != nil {
		panic(err)
	}

	// We can check it here.
	fmt.Println(os.Getenv(key))

	// Additionally, we can use the config into a struct.
	type Config struct {
		TestKey string `env:"TEST_KEY" json:"testKey"`
	}

	// ExportToStruct can be called from the provider...
	var c1 Config
	if err := de.ExportToStruct(&c1); err != nil {
		panic(err)
	}

	// or from the `util` package.
	var c2 Config
	if err := util.Dump(&c2); err != nil {
		panic(err)
	}

	// We can check it here.
	fmt.Println(c1.TestKey)
	fmt.Println(c2.TestKey)

}
Output:
TEST_VALUE
TEST_VALUE
TEST_VALUE

Types

type NoOp

type NoOp struct {
	*provider.Provider `json:"-" validate:"required"`
}

NoOp provider definition.

func (*NoOp) Load

func (n *NoOp) Load(ctx context.Context, opts ...option.LoadKeyFunc) (map[string]string, error)

Load retrieves the configuration, and exports it to the environment.

func (*NoOp) Write added in v1.1.32

func (n *NoOp) Write(ctx context.Context, values map[string]interface{}, opts ...option.WriteFunc) error

Write stores a new secret.

NOTE: Not all providers support writing secrets.

Jump to

Keyboard shortcuts

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