Documentation
¶
Overview ¶
Example ¶
package main import ( "fmt" "github.com/bitrise-io/go-steputils/cache" ) // Create ItemCollectors for listing Bitrise cache include and exclude patterns. type SampleItemCollector struct{} // List of include and exclude patterns are collected in a given directory, cacheLevel describes what files should be included in the cache. func (c SampleItemCollector) Collect(dir string, cacheLevel cache.Level) ([]string, []string, error) { return []string{"include_me.md"}, []string{"exclude_me.txt"}, nil } func main() { // Create a cache, usually using cache.New() getterSetter := NewMockGetterSetter() testConfig := cache.Config{getterSetter, []cache.VariableSetter{getterSetter}} c := testConfig.NewCache() for _, collector := range []cache.ItemCollector{SampleItemCollector{}} { // Run some Cache ItemCollectors in, ex, err := collector.Collect("", cache.LevelDeps) if err != nil { panic(err) } // Store the include and exclude patterns in the cache c.IncludePath(in...) c.ExcludePath(ex...) } // Commit the cache changes if err := c.Commit(); err != nil { panic(err) } printIncludeAndExcludeEnvs(getterSetter) } func printIncludeAndExcludeEnvs(getterSetter MockGetterSetter) { includePaths, err := getterSetter.Get(cache.CacheIncludePathsEnvKey) if err != nil { panic(err) } fmt.Println(includePaths) excludePaths, err := getterSetter.Get(cache.CacheExcludePathsEnvKey) if err != nil { panic(err) } fmt.Println(excludePaths) }
Output: include_me.md exclude_me.txt
Index ¶
Examples ¶
Constants ¶
View Source
const ( LevelNone = Level("none") LevelDeps = Level("only_deps") LevelAll = Level("all") )
Cache level
View Source
const CacheExcludePathsEnvKey = "BITRISE_CACHE_EXCLUDE_PATHS"
CacheExcludePathsEnvKey ...
View Source
const CacheIncludePathsEnvKey = "BITRISE_CACHE_INCLUDE_PATHS"
CacheIncludePathsEnvKey ...
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { VariableGetter VariableGetter VariableSetters []VariableSetter }
Config ...
type EnvmanVariableSetter ¶
type EnvmanVariableSetter struct { }
EnvmanVariableSetter ...
func (EnvmanVariableSetter) Set ¶
func (e EnvmanVariableSetter) Set(key, value string) error
Set ...
type ItemCollector ¶
ItemCollector ...
type Level ¶
type Level string
Level defines the extent to which caching should be used. - LevelNone: no caching - LevelDeps: only dependencies will be cached - LevelAll: dependencies and build files will be cache
type VariableGetter ¶
VariableGetter ...
type VariableSetter ¶
VariableSetter ...
func NewEnvmanVariableSetter ¶
func NewEnvmanVariableSetter() VariableSetter
NewEnvmanVariableSetter ...
Click to show internal directories.
Click to hide internal directories.