github.com/hashicorp/go-slug
go get github.com/hashicorp/go-slug

github.com/hashicorp/go-slug

The slug package provides functions to create slug archives

by hashicorp

v0.7.0 (see all)License:MPL-2.0
go get github.com/hashicorp/go-slug
Readme

go-slug

Build Status GitHub license GoDoc Go Report Card GitHub issues

Package go-slug offers functions for packing and unpacking Terraform Enterprise compatible slugs. Slugs are gzip compressed tar files containing Terraform configuration files.

Installation

Installation can be done with a normal go get:

go get -u github.com/hashicorp/go-slug

Documentation

For the complete usage of go-slug, see the full package docs.

Example

Packing or unpacking a slug is pretty straight forward as shown in the following example:

package main

import (
    "bytes"
    "io/ioutil"
    "log"
    "os"

    slug "github.com/hashicorp/go-slug"
)

func main() {
    // First create a buffer for storing the slug.
    buf := bytes.NewBuffer(nil)

    // Then call the Pack function with a directory path containing the
    // configuration files and an io.Writer to write the slug to.
    if _, err := slug.Pack("testdata/archive-dir", buf, false); err != nil {
        log.Fatal(err)
    }

    // Create a directory to unpack the slug contents into.
    dst, err := ioutil.TempDir("", "slug")
    if err != nil {
        log.Fatal(err)
    }
    defer os.RemoveAll(dst)

    // Unpacking a slug is done by calling the Unpack function with an
    // io.Reader to read the slug from and a directory path of an existing
    // directory to store the unpacked configuration files.
    if err := slug.Unpack(buf, dst); err != nil {
        log.Fatal(err)
    }
}

Issues and Contributing

If you find an issue with this package, please report an issue. If you'd like, we welcome any contributions. Fork this repository and submit a pull request.

GitHub Stars

12

LAST COMMIT

1yr ago

MAINTAINERS

0

CONTRIBUTORS

9

OPEN ISSUES

4

OPEN PRs

1
VersionTagPublished
v0.0.0-20210226143659-447e7f0eaa48
9mos ago
v0.7.0
1yr ago
v0.6.0
1yr ago
v0.5.0
1yr ago
No alternatives found
No tutorials found
Add a tutorial