layers

package
v0.0.0-...-aa10f78 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Walk

Walk creates layer entries for the given context.

Example
package main

import (
	"fmt"
	"os"
	"path"

	"github.com/containerd/continuity"
	"github.com/depot/orca/filter"
	"github.com/depot/orca/layers"
)

func main() {
	// Make some test data:
	root, _ := os.MkdirTemp("", "testwalk")
	f, err := os.Create(path.Join(root, "index.ts"))
	if err != nil {
		panic(err)
	}
	f.Write([]byte(`console.log("hello world")`))
	_ = f.Close()

	// This dockerignore filter will ignore all files in node_modules.
	ignoreNodeModules, err := filter.NewDockerIgnoreFilter([]string{"node_modules"})
	if err != nil {
		panic(err)
	}

	// Create a context that will walk the file tree and filter out node_modules.
	ctx, err := filter.NewDockerIgnoreContext(root, ignoreNodeModules, continuity.ContextOptions{
		// This digester will create chunked digests for each file.
		Digester: &filter.Digester{},
	})
	if err != nil {
		panic(err)
	}

	layer, _ := layers.Walk(ctx)
	for _, entry := range layer.Entries {
		fmt.Printf("%v\n", entry.Path[0])
		fmt.Printf("%v\n", entry.Blocks[0])
	}
}
Output:
/index.ts
size_bytes:26 digest:{algorithm:ALGORITHM_XXH64 sum:15630286323523909447}

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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