opensearchconfig

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 12 Imported by: 0

README

OpenSearch Config

Pulls environment variables to configure the opensearch-go library

Usage

package main

import (
	"context"

    "github.com/shopsmart/opensearchconfig"
)

func main() {
	ctx := context.Background()

	client, err := opensearchconfig.NewClientFromEnv(ctx)
	if err != nil {
        panic(err) // Beware the scary panic
	}

    // Do stuff with the client
}

Configuring

Available environment variables
  • OPENSEARCH_URL is parsed by the opensearch-go library and configures the various addresses to be used with the client. Separate endpoints with a comma.
  • OPENSEARCH_SKIP_SSL set to true will enable skipping the SSL check
  • OPENSEARCH_AUTH sets what type of auth to use for connecting to the OpenSearch cluster. By default, it will use none auth. Options are: none, basic, iam.
  • OPENSEARCH_USERNAME represents the username for the user to login with only if auth is set to basic
  • OPENSEARCH_PASSWORD represents the password for the user to login with only if auth is set to basic

Documentation

Index

Constants

View Source
const (
	// AuthNone is the auth type to use if no auth is configured on the cluster
	AuthNone = "none"
	// AuthBasic is the auth type to use if using the internal user database on the cluster
	AuthBasic = "basic"
	// AuthIAM is the auth type to use if not using the internal user database on the cluster
	AuthIAM = "iam"
	// ENV variable to control whether traces are send to datadog
	DD_TRACE_ENABLED = "DD_TRACE_ENABLED"
	// Identify the name of the trace in datadog
	Opensearch = "opensearch"
)

Variables

View Source
var (
	// ErrMissingCredentials will be thrown when basic auth is configured but either username or password is not available
	ErrMissingCredentials = errors.New("basic auth has been set but username or password is missing")
)

Functions

func ConfigFromEnv

func ConfigFromEnv(ctx context.Context) (opensearch.Config, error)

ConfigFromEnv creates an OpenSearch config object from environment variables

func NewClientFromEnv

func NewClientFromEnv(ctx context.Context) (*opensearch.Client, error)

NewClientFromEnv creates an OpenSearch client pulling configurations from the environment

Types

type Config

type Config struct {
	// Skips ssl if true
	SkipSSL bool // OPENSEARCH_SKIP_SSL
	// The auth type to use.  Options are none, basic, iam
	Auth string // OPENSEARCH_AUTH
	// The username if auth is basic
	Username string // OPENSEARCH_USERNAME
	// The password if auth is basic
	Password string // OPENSEARCH_PASSWORD
}

Config represents the configuration options available with this package

func GetConfig

func GetConfig() (Config, error)

GetConfig will get the Config object from the environment

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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