github.1485827954.workers.dev/nektos/act@v0.2.63/pkg/common/dryrun.go (about) 1 package common 2 3 import ( 4 "context" 5 ) 6 7 type dryrunContextKey string 8 9 const dryrunContextKeyVal = dryrunContextKey("dryrun") 10 11 // Dryrun returns true if the current context is dryrun 12 func Dryrun(ctx context.Context) bool { 13 val := ctx.Value(dryrunContextKeyVal) 14 if val != nil { 15 if dryrun, ok := val.(bool); ok { 16 return dryrun 17 } 18 } 19 return false 20 } 21 22 // WithDryrun adds a value to the context for dryrun 23 func WithDryrun(ctx context.Context, dryrun bool) context.Context { 24 return context.WithValue(ctx, dryrunContextKeyVal, dryrun) 25 }