bundle

package
v0.0.0-...-0c0d4ac Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package bundle implements functions for serializing data into single-file Terraform modules.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(content []byte, name string) ([]byte, error)

Bytes bundles content into a byte stream, and is referred to as name.

Example
package main

import (
	"fmt"
	"io/ioutil"

	"github.com/joshdk/tfbundle/bundle"
)

func main() {
	content := []byte("Hello, world!")

	body, err := bundle.Bytes(content, "hello.txt")
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	if err := ioutil.WriteFile("module.tgz", body, 0400); err != nil {
		fmt.Println(err.Error())
		return
	}
}
Output:

func File

func File(path string) ([]byte, error)

File bundles the contents of the file referenced by path into a byte stream. The original name of the file is used as the name of the artifact.

Example
package main

import (
	"fmt"
	"io/ioutil"

	"github.com/joshdk/tfbundle/bundle"
)

func main() {
	body, err := bundle.File("hello.txt")
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	if err := ioutil.WriteFile("module.tgz", body, 0400); err != nil {
		fmt.Println(err.Error())
		return
	}
}
Output:

func Reader

func Reader(content io.Reader, name string) ([]byte, error)

Reader bundles content into a byte stream, and is referred to as name.

Example
package main

import (
	"fmt"
	"io/ioutil"
	"strings"

	"github.com/joshdk/tfbundle/bundle"
)

func main() {
	content := strings.NewReader("Hello, world!")

	body, err := bundle.Reader(content, "hello.txt")
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	if err := ioutil.WriteFile("module.tgz", body, 0400); err != nil {
		fmt.Println(err.Error())
		return
	}
}
Output:

func String

func String(content string, name string) ([]byte, error)

String bundles content into a byte stream, and is referred to as name.

Example
package main

import (
	"fmt"
	"io/ioutil"

	"github.com/joshdk/tfbundle/bundle"
)

func main() {
	content := "Hello, world!"

	body, err := bundle.String(content, "hello.txt")
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	if err := ioutil.WriteFile("module.tgz", body, 0400); err != nil {
		fmt.Println(err.Error())
		return
	}
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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