Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
testdata/ | H | 03-May-2022 | - | |||
.gitignore | H A D | 15-Nov-2019 | 192 | |||
LICENSE | H A D | 15-Nov-2019 | 16.3 KiB | |||
README.md | H A D | 15-Nov-2019 | 2.2 KiB | |||
go.mod | H A D | 15-Nov-2019 | 45 | |||
slug.go | H A D | 15-Nov-2019 | 7.9 KiB | |||
slug_test.go | H A D | 15-Nov-2019 | 9.6 KiB | |||
terraformignore.go | H A D | 15-Nov-2019 | 5.1 KiB | |||
terraformignore_test.go | H A D | 15-Nov-2019 | 2.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