• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

testdata/H03-May-2022-

.gitignoreH A D15-Nov-2019192

LICENSEH A D15-Nov-201916.3 KiB

README.mdH A D15-Nov-20192.2 KiB

go.modH A D15-Nov-201945

slug.goH A D15-Nov-20197.9 KiB

slug_test.goH A D15-Nov-20199.6 KiB

terraformignore.goH A D15-Nov-20195.1 KiB

terraformignore_test.goH A D15-Nov-20192.1 KiB

README.md

1# go-slug
2
3[![Build Status](https://travis-ci.org/hashicorp/go-slug.svg?branch=master)](https://travis-ci.org/hashicorp/go-slug)
4[![GitHub license](https://img.shields.io/github/license/hashicorp/go-slug.svg)](https://github.com/hashicorp/go-slug/blob/master/LICENSE)
5[![GoDoc](https://godoc.org/github.com/hashicorp/go-slug?status.svg)](https://godoc.org/github.com/hashicorp/go-slug)
6[![Go Report Card](https://goreportcard.com/badge/github.com/hashicorp/go-slug)](https://goreportcard.com/report/github.com/hashicorp/go-slug)
7[![GitHub issues](https://img.shields.io/github/issues/hashicorp/go-slug.svg)](https://github.com/hashicorp/go-slug/issues)
8
9Package `go-slug` offers functions for packing and unpacking Terraform Enterprise
10compatible slugs. Slugs are gzip compressed tar files containing Terraform configuration files.
11
12## Installation
13
14Installation can be done with a normal `go get`:
15
16```
17go get -u github.com/hashicorp/go-slug
18```
19
20## Documentation
21
22For the complete usage of `go-slug`, see the full [package docs](https://godoc.org/github.com/hashicorp/go-slug).
23
24## Example
25
26Packing or unpacking a slug is pretty straight forward as shown in the
27following example:
28
29```go
30package main
31
32import (
33	"bytes"
34	"io/ioutil"
35	"log"
36	"os"
37
38	slug "github.com/hashicorp/go-slug"
39)
40
41func main() {
42	// First create a buffer for storing the slug.
43	buf := bytes.NewBuffer(nil)
44
45	// Then call the Pack function with a directory path containing the
46	// configuration files and an io.Writer to write the slug to.
47	if _, err := slug.Pack("testdata/archive-dir", buf, false); err != nil {
48		log.Fatal(err)
49	}
50
51	// Create a directory to unpack the slug contents into.
52	dst, err := ioutil.TempDir("", "slug")
53	if err != nil {
54		log.Fatal(err)
55	}
56	defer os.RemoveAll(dst)
57
58	// Unpacking a slug is done by calling the Unpack function with an
59	// io.Reader to read the slug from and a directory path of an existing
60	// directory to store the unpacked configuration files.
61	if err := slug.Unpack(buf, dst); err != nil {
62		log.Fatal(err)
63	}
64}
65```
66
67## Issues and Contributing
68
69If you find an issue with this package, please report an issue. If you'd like,
70we welcome any contributions. Fork this repository and submit a pull request.
71