dotenv

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: MIT Imports: 3 Imported by: 0

README

xk6-dotenv

A k6 extension that loads env vars from a .env file.

This extension follow the convention for managing multiple environments (i.e. development, test, production). The actual environment name came from an env variable named K6_ENV. Setting this to false value disable the convention mentoined above and no .env file will be loaded automatically.

Hierarchy Priority Filename K6_ENV Should I .gitignoreit? Notes
1st (highest) .env.development.local development Yes! Local overrides of environment-specific settings.
1st .env.test.local test Yes! Local overrides of environment-specific settings.
1st .env.production.local production Yes! Local overrides of environment-specific settings.
2nd .env.local (any expect false) Definitely. Local overrides. This file is loaded for all environments except test.
3rd .env.development development No. Shared environment-specific settings
3rd .env.test test No. Shared environment-specific settings
3rd .env.production production No. Shared environment-specific settings
Last .env (any expect false) Depends The Original

The underlying implementation is https://github.com/joho/godotenv

Built for k6 using xk6.

Usage

Import an entire module's contents:

import * as dotenv from "k6/x/dotenv";

Import a single export from a module:

import { parse } from "k6/x/dotenv";

API

This extension can be used as a library:

For complete API documentation click here!

Build

To build a k6 binary with this extension, first ensure you have the prerequisites:

Then:

  1. Install xk6:
$ go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the binary:
$ xk6 build --with github.com/szkiba/xk6-dotenv@latest

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct{}

func New

func New() *Module

func (*Module) Parse

func (m *Module) Parse(text string) (interface{}, error)

func (*Module) Stringify

func (m *Module) Stringify(value map[string]string) (string, error)

Jump to

Keyboard shortcuts

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