s3

package module
v0.0.0-...-77b3516 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2019 License: MIT Imports: 9 Imported by: 0

README

AWS S3 Provider

A package that facilitates working with http://vaultproject.io/ in context of CLI. It increases the security of Golang applications by populating a command line arguments from the vault.

Installation

Make sure you have a working Go environment. Go version 1.2+ is supported.

See the install instructions for Go.

To install vault, simply run:

$ go get github.com/phogolabs/cli/provider/aws/s3

Getting Started

In order to have the provider enabled, you need to set its token either directly or authenticating the client with Kuberenetes. For that purpose, you will need to set the following flags in your application:

import (
	"os"

	"github.com/phogolabs/cli"
	"github.com/phogolabs/cli/provider/aws/s3"
)

func main() {
	app := &cli.App{
		Name:      "prana",
		HelpName:  "prana",
		Usage:     "Golang Database Manager",
		UsageText: "prana [global options]",
		Version:   "1.0-beta-04",
		Action:    run,
		Providers: []cli.Provider{
			&s3.Provider{},
		},
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:   "aws-access-key-id",
				Usage:  "AWS Access Key ID",
				EnvVar: "AWS_ACCESS_KEY_ID",
			},
			&cli.StringFlag{
				Name:   "aws-secret-access-key",
				Usage:  "AWS Secret Access Key",
				EnvVar: "AWS_SECRET_ACCESS_KEY",
			},
			&cli.StringFlag{
				Name:   "aws-region",
				Usage:  "AWS Region",
				EnvVar: "AWS_DEFAULT_REGION",
			},
			&cli.StringFlag{
				Name:   "aws-bucket",
				Usage:  "AWS S3 Bucket",
				EnvVar: "AWS_BUCKET",
			},
			&cli.StringFlag{
				Name:   "config",
				Usage:  "Aplication's config",
				EnvVar: "APP_CONFIG",
				FilePath: "s3://config.json",
			},
		},
	}

	if err := app.Run(os.Args); err != nil {
		panic(err)
	}
}

func run(ctx *cli.Context) error {
	fmt.Println("Application started")
	return nil
}

As you can see in order to match the flag with a file on S# you should set the FilePath field in the following format:

s3://<your_file_name>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config *ClientConfig
}

Client is the client

func (*Client) Glob

func (c *Client) Glob(pattern string) ([]string, error)

Glob returns a list of all paths

func (*Client) ReadFile

func (c *Client) ReadFile(path string) ([]byte, error)

ReadFile reads a file from the bucket

type ClientConfig

type ClientConfig struct {
	Region string
	Bucket string
}

ClientConfig is the client's config

type FileSystem

type FileSystem interface {
	// Glob returns a list of all paths
	Glob(pattern string) ([]string, error)
	// ReadFile reads a file from the bucket
	ReadFile(path string) ([]byte, error)
}

FileSystem represents a file system

type Provider

type Provider struct {
	FileSystem FileSystem
}

Provider is a parser that populates flags from AWS S3

func (*Provider) Provide

func (m *Provider) Provide(ctx *cli.Context) error

Provide parses the args

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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