localenv

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package localenv generates passwords and reads and writes .env.local, the file that holds the secrets of a workspace.

Index

Constants

View Source
const (
	AdminUserKey               = "OPENARCH_ADMIN_USER"
	AdminPasswordKey           = "OPENARCH_ADMIN_PASSWORD"
	MongoRootPasswordKey       = "MONGODB_ROOT_PASSWORD"
	MongoAppPasswordKey        = "MONGODB_APP_PASSWORD"
	MongoAppURIKey             = "MONGODB_APP_URI"
	OpenSearchAdminPasswordKey = "OPENSEARCH_ADMIN_PASSWORD"
	OpenSearchAppPasswordKey   = "OPENSEARCH_APP_PASSWORD"
	DashboardsPasswordKey      = "OPENSEARCH_DASHBOARDS_PASSWORD"
)

Keys in .env.local. Docker Compose reads them as secret sources.

View Source
const (
	MongoRootUser       = "root"
	MongoAppUser        = "openarch"
	MongoAppDB          = "openarch"
	OpenSearchAdminUser = "admin"
	OpenSearchAppUser   = "openarch"
	// The OpenSearch security plugin gives the Dashboards server rights only to
	// the user named in its server_username setting, which defaults to kibanaserver.
	DashboardsUser = "kibanaserver"
)

Users that the CLI creates in MongoDB and OpenSearch.

View Source
const File = ".env.local"

File is the name of the secrets file in a workspace.

View Source
const PasswordLength = 24

PasswordLength is the length of generated passwords.

Variables

This section is empty.

Functions

func Hash

func Hash(password string) (string, error)

Hash returns a bcrypt hash of password.

func Matches

func Matches(hash, password string) bool

Matches reports whether a bcrypt hash matches password.

func Password

func Password(n int) string

Password returns a random password of n characters.

Types

type Env

type Env struct {
	AdminUser               string
	AdminPassword           string
	MongoRootPassword       string
	MongoAppPassword        string
	OpenSearchAdminPassword string
	OpenSearchAppPassword   string
	DashboardsPassword      string
}

Env is the content of .env.local.

func Parse

func Parse(data []byte) Env

Parse reads the keys this CLI uses from a .env file. Other lines are ignored.

func (*Env) Fill

func (e *Env) Fill(adminUser string) []string

Fill sets every empty value: the admin user to adminUser and the passwords to new random ones. It returns the keys it set.

func (Env) Marshal

func (e Env) Marshal() []byte

Marshal encodes e as a .env file.

func (Env) MongoAppURI

func (e Env) MongoAppURI() string

MongoAppURI is the MongoDB connection string of OpenArch.

Jump to

Keyboard shortcuts

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