kubectl-envsecret

command module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MIT Imports: 5 Imported by: 0

README

kubectl-envsecret

Overview

kubectl-envsecret is a Kubernetes plugin designed to simplify the creation of Kubernetes secrets from .env files, including support for multiline environment variables. This tool streamlines the management of secrets, making it easier to handle configurations that include complex multiline values.

Features

  • Create Kubernetes secrets from .env files.
  • Support for multiline environment variables.
  • Easy integration with kubectl as a plugin.

Installation

To install kubectl-envsecret, you need to have Go installed on your machine. You can then use the following command to install the plugin:

go install github.com/ogticrd/kubectl-envsecret@latest

Usage

Basic Usage

The primary command provided by kubectl-envsecret is create, which reads a .env file and creates a corresponding Kubernetes secret.

kubectl envsecret create --from-env-file <path-to-env-file> --from-env-file <path-to-other-files>
Command Options
  • --from-env-file: Specifies the path(s) to the .env file. This option can be used multiple times to specify multiple .env files.
Examples
Create a Secret from a Single .env File
kubectl envsecret create --from-env-file /path/to/.env
Create a Secret from Multiple .env Files
kubectl envsecret create --from-env-file /path/to/.env --from-env-file /another/path/.env

Development

Prerequisites
  • Go
  • Cobra CLI
Downloading the project

First you need is cloning the project

git clone https://github.com/ogticrd/kubectl-envsecret.git
cd kubectl-envsecret
Building the Project

To build the project, clone the repository and run:

With go command
go build -o kubectl-envsecret main.go
Using make command
make build
Running the Project
With go command
go run main.go

[!NOTE]
Just run ./kubectl-envsecret if you already built it.

Using make command
make run

# For passing args and flags
make run CMD="create" ARGS="secret-name" FLAGS="--from-env-file /path/to/secret --namespace default"
Running Tests

To run the tests, use the following command:

With go command
go test ./...
Using make command
make test

Project Structure

.
├── LICENSE
├── Makefile
├── README.md
├── cmd
│   ├── create.go
│   └── root.go
├── go.mod
├── go.sum
├── internal
│   ├── k8sapi
│   │   └── k8s.go
│   ├── parser
│   │   └── env.go
│   └── utils
│       └── utils.go
└── main.go
  • cmd: Contains the CLI command definitions.
  • internal/k8sapi: Contains a wrapper of the usage of Kubernetes API to manage secrets.
  • internal/parser: Contains functions to parse .env files.
  • internal/utils: Contains utility functions used by the commands.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

This project uses the following libraries:

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cmd provides the command-line interface for the kubectl-envsecret plugin.
Package cmd provides the command-line interface for the kubectl-envsecret plugin.
internal
k8sapi
Package k8sapi provides functions and types for interacting with the Kubernetes API.
Package k8sapi provides functions and types for interacting with the Kubernetes API.
parser
Package parser provides utilities for parsing .env files.
Package parser provides utilities for parsing .env files.
utils
Package utils provides utility functions for common operations.
Package utils provides utility functions for common operations.

Jump to

Keyboard shortcuts

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