No description
Find a file
Mohan Manikanta 2590db258d
Merge pull request #126 from hashicorp/dependabot/github_actions/github-actions-backward-compatible-502588e1ca
Bump the github-actions-backward-compatible group with 2 updates
2026-02-03 14:04:04 +05:30
.github Bump the github-actions-backward-compatible group with 2 updates 2026-02-01 20:23:35 +00:00
internal Merge branch 'main' into compliance/update-headers 2025-11-04 02:41:27 +05:30
sourceaddrs [COMPLIANCE] Update Copyright and License Headers 2025-11-03 20:38:34 +00:00
sourcebundle Add component registry source support (#115) 2025-11-17 09:29:51 -05:00
testdata Delete testdata/.DS_Store 2025-04-10 05:18:45 +08:00
.gitignore Update .gitignore 2025-04-10 05:17:05 +08:00
CHANGELOG.md Update CHANGELOG for version 0.18.2 (#122) 2026-01-06 09:24:41 +05:30
go.mod sec: use os.root for file manipulation 2025-09-16 00:53:41 -04:00
go.sum sec: use os.root for file manipulation 2025-09-16 00:53:41 -04:00
LICENSE [COMPLIANCE] Update Copyright and License Headers 2025-11-03 20:38:34 +00:00
README.md fix lint errors and run linter as part of acceptance checks 2025-06-17 14:15:50 +05:30
slug.go TF-27917 - Filter OSX metadata files during tar extraction (#119) 2026-01-06 00:35:39 +05:30
slug_test.go TF-27917 - Filter OSX metadata files during tar extraction (#119) 2026-01-06 00:35:39 +05:30
terraformignore.go [COMPLIANCE] Update Copyright and License Headers 2025-11-03 20:38:34 +00:00

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"
	"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 := os.MkdirTemp("", "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.