id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
162,200
openshift/source-to-image
pkg/util/interrupt/interrupt.go
close
func (h *Handler) close() { h.once.Do(func() { for _, fn := range h.notify { fn() } }) }
go
func (h *Handler) close() { h.once.Do(func() { for _, fn := range h.notify { fn() } }) }
[ "func", "(", "h", "*", "Handler", ")", "close", "(", ")", "{", "h", ".", "once", ".", "Do", "(", "func", "(", ")", "{", "for", "_", ",", "fn", ":=", "range", "h", ".", "notify", "{", "fn", "(", ")", "\n", "}", "\n", "}", ")", "\n", "}" ]
// close calls the notify functions, used when no signal was caught and the Run // method returned.
[ "close", "calls", "the", "notify", "functions", "used", "when", "no", "signal", "was", "caught", "and", "the", "Run", "method", "returned", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/util/interrupt/interrupt.go#L83-L89
162,201
openshift/source-to-image
pkg/util/interrupt/interrupt.go
signal
func (h *Handler) signal(s os.Signal) { h.once.Do(func() { for _, fn := range h.notify { fn() } if h.final == nil { os.Exit(2) } h.final(s) }) }
go
func (h *Handler) signal(s os.Signal) { h.once.Do(func() { for _, fn := range h.notify { fn() } if h.final == nil { os.Exit(2) } h.final(s) }) }
[ "func", "(", "h", "*", "Handler", ")", "signal", "(", "s", "os", ".", "Signal", ")", "{", "h", ".", "once", ".", "Do", "(", "func", "(", ")", "{", "for", "_", ",", "fn", ":=", "range", "h", ".", "notify", "{", "fn", "(", ")", "\n", "}", "...
// signal calls the notify functions and final, used when a signal was caught // while the Run method was running. If final is nil, os.Exit will be called as // a default.
[ "signal", "calls", "the", "notify", "functions", "and", "final", "used", "when", "a", "signal", "was", "caught", "while", "the", "Run", "method", "was", "running", ".", "If", "final", "is", "nil", "os", ".", "Exit", "will", "be", "called", "as", "a", "...
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/util/interrupt/interrupt.go#L94-L104
162,202
openshift/source-to-image
pkg/scm/downloaders/empty/noop.go
Download
func (n *Noop) Download(config *api.Config) (*git.SourceInfo, error) { glog.V(1).Info("No source location defined (the assemble script is responsible for obtaining the source)") return &git.SourceInfo{}, nil }
go
func (n *Noop) Download(config *api.Config) (*git.SourceInfo, error) { glog.V(1).Info("No source location defined (the assemble script is responsible for obtaining the source)") return &git.SourceInfo{}, nil }
[ "func", "(", "n", "*", "Noop", ")", "Download", "(", "config", "*", "api", ".", "Config", ")", "(", "*", "git", ".", "SourceInfo", ",", "error", ")", "{", "glog", ".", "V", "(", "1", ")", ".", "Info", "(", "\"", "\"", ")", "\n\n", "return", "...
// Download is a no-op downloader so that Noop satisfies build.Downloader
[ "Download", "is", "a", "no", "-", "op", "downloader", "so", "that", "Noop", "satisfies", "build", ".", "Downloader" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/scm/downloaders/empty/noop.go#L17-L21
162,203
openshift/source-to-image
pkg/util/cmd/cmd.go
RunWithOptions
func (c *runner) RunWithOptions(opts CommandOpts, name string, arg ...string) error { cmd := exec.Command(name, arg...) if opts.Stdout != nil { cmd.Stdout = opts.Stdout } if opts.Stderr != nil { cmd.Stderr = opts.Stderr } if opts.Dir != "" { cmd.Dir = opts.Dir } if len(opts.EnvAppend) > 0 { cmd.Env = os...
go
func (c *runner) RunWithOptions(opts CommandOpts, name string, arg ...string) error { cmd := exec.Command(name, arg...) if opts.Stdout != nil { cmd.Stdout = opts.Stdout } if opts.Stderr != nil { cmd.Stderr = opts.Stderr } if opts.Dir != "" { cmd.Dir = opts.Dir } if len(opts.EnvAppend) > 0 { cmd.Env = os...
[ "func", "(", "c", "*", "runner", ")", "RunWithOptions", "(", "opts", "CommandOpts", ",", "name", "string", ",", "arg", "...", "string", ")", "error", "{", "cmd", ":=", "exec", ".", "Command", "(", "name", ",", "arg", "...", ")", "\n", "if", "opts", ...
// RunWithOptions runs a command with the provided options
[ "RunWithOptions", "runs", "a", "command", "with", "the", "provided", "options" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/util/cmd/cmd.go#L37-L53
162,204
openshift/source-to-image
pkg/util/cmd/cmd.go
Run
func (c *runner) Run(name string, arg ...string) error { return c.RunWithOptions(CommandOpts{}, name, arg...) }
go
func (c *runner) Run(name string, arg ...string) error { return c.RunWithOptions(CommandOpts{}, name, arg...) }
[ "func", "(", "c", "*", "runner", ")", "Run", "(", "name", "string", ",", "arg", "...", "string", ")", "error", "{", "return", "c", ".", "RunWithOptions", "(", "CommandOpts", "{", "}", ",", "name", ",", "arg", "...", ")", "\n", "}" ]
// Run executes a command with default options
[ "Run", "executes", "a", "command", "with", "default", "options" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/util/cmd/cmd.go#L56-L58
162,205
openshift/source-to-image
pkg/util/cmd/cmd.go
StartWithStdoutPipe
func (c *runner) StartWithStdoutPipe(opts CommandOpts, name string, arg ...string) (io.ReadCloser, error) { c.cmd = exec.Command(name, arg...) if opts.Stderr != nil { c.cmd.Stderr = opts.Stderr } if opts.Dir != "" { c.cmd.Dir = opts.Dir } if len(opts.EnvAppend) > 0 { c.cmd.Env = os.Environ() c.cmd.Env = a...
go
func (c *runner) StartWithStdoutPipe(opts CommandOpts, name string, arg ...string) (io.ReadCloser, error) { c.cmd = exec.Command(name, arg...) if opts.Stderr != nil { c.cmd.Stderr = opts.Stderr } if opts.Dir != "" { c.cmd.Dir = opts.Dir } if len(opts.EnvAppend) > 0 { c.cmd.Env = os.Environ() c.cmd.Env = a...
[ "func", "(", "c", "*", "runner", ")", "StartWithStdoutPipe", "(", "opts", "CommandOpts", ",", "name", "string", ",", "arg", "...", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "c", ".", "cmd", "=", "exec", ".", "Command", "(",...
// StartWithStdoutPipe executes a command returning a ReadCloser connected to // the command's stdout.
[ "StartWithStdoutPipe", "executes", "a", "command", "returning", "a", "ReadCloser", "connected", "to", "the", "command", "s", "stdout", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/util/cmd/cmd.go#L62-L79
162,206
openshift/source-to-image
pkg/build/config.go
GenerateConfigFromLabels
func GenerateConfigFromLabels(config *api.Config, metadata *docker.PullResult) error { if config == nil { return errors.New("config must be provided to GenerateConfigFromLabels") } if metadata == nil { return errors.New("image metadata must be provided to GenerateConfigFromLabels") } labels := metadata.Image....
go
func GenerateConfigFromLabels(config *api.Config, metadata *docker.PullResult) error { if config == nil { return errors.New("config must be provided to GenerateConfigFromLabels") } if metadata == nil { return errors.New("image metadata must be provided to GenerateConfigFromLabels") } labels := metadata.Image....
[ "func", "GenerateConfigFromLabels", "(", "config", "*", "api", ".", "Config", ",", "metadata", "*", "docker", ".", "PullResult", ")", "error", "{", "if", "config", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n",...
// GenerateConfigFromLabels generates the S2I Config struct from the Docker // image labels.
[ "GenerateConfigFromLabels", "generates", "the", "S2I", "Config", "struct", "from", "the", "Docker", "image", "labels", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/build/config.go#L15-L59
162,207
openshift/source-to-image
pkg/scripts/environment.go
ConvertEnvironmentList
func ConvertEnvironmentList(env api.EnvironmentList) (result []string) { for _, e := range env { result = append(result, fmt.Sprintf("%s=%s", e.Name, e.Value)) } return }
go
func ConvertEnvironmentList(env api.EnvironmentList) (result []string) { for _, e := range env { result = append(result, fmt.Sprintf("%s=%s", e.Name, e.Value)) } return }
[ "func", "ConvertEnvironmentList", "(", "env", "api", ".", "EnvironmentList", ")", "(", "result", "[", "]", "string", ")", "{", "for", "_", ",", "e", ":=", "range", "env", "{", "result", "=", "append", "(", "result", ",", "fmt", ".", "Sprintf", "(", "...
// ConvertEnvironmentList converts the EnvironmentList to "key=val" strings.
[ "ConvertEnvironmentList", "converts", "the", "EnvironmentList", "to", "key", "=", "val", "strings", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/scripts/environment.go#L46-L51
162,208
openshift/source-to-image
pkg/scripts/environment.go
ConvertEnvironmentToDocker
func ConvertEnvironmentToDocker(env api.EnvironmentList) (result string) { for i, e := range env { if i == 0 { result += fmt.Sprintf("ENV %s=\"%s\"", e.Name, e.Value) } else { result += fmt.Sprintf(" \\\n %s=\"%s\"", e.Name, e.Value) } } result += "\n" return }
go
func ConvertEnvironmentToDocker(env api.EnvironmentList) (result string) { for i, e := range env { if i == 0 { result += fmt.Sprintf("ENV %s=\"%s\"", e.Name, e.Value) } else { result += fmt.Sprintf(" \\\n %s=\"%s\"", e.Name, e.Value) } } result += "\n" return }
[ "func", "ConvertEnvironmentToDocker", "(", "env", "api", ".", "EnvironmentList", ")", "(", "result", "string", ")", "{", "for", "i", ",", "e", ":=", "range", "env", "{", "if", "i", "==", "0", "{", "result", "+=", "fmt", ".", "Sprintf", "(", "\"", "\\...
// ConvertEnvironmentToDocker converts the EnvironmentList into Dockerfile format.
[ "ConvertEnvironmentToDocker", "converts", "the", "EnvironmentList", "into", "Dockerfile", "format", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/scripts/environment.go#L54-L64
162,209
openshift/source-to-image
pkg/api/validation/validation.go
ValidateConfig
func ValidateConfig(config *api.Config) []Error { allErrs := []Error{} if len(config.BuilderImage) == 0 { allErrs = append(allErrs, NewFieldRequired("builderImage")) } switch config.BuilderPullPolicy { case api.PullNever, api.PullAlways, api.PullIfNotPresent: default: allErrs = append(allErrs, NewFieldInvalid...
go
func ValidateConfig(config *api.Config) []Error { allErrs := []Error{} if len(config.BuilderImage) == 0 { allErrs = append(allErrs, NewFieldRequired("builderImage")) } switch config.BuilderPullPolicy { case api.PullNever, api.PullAlways, api.PullIfNotPresent: default: allErrs = append(allErrs, NewFieldInvalid...
[ "func", "ValidateConfig", "(", "config", "*", "api", ".", "Config", ")", "[", "]", "Error", "{", "allErrs", ":=", "[", "]", "Error", "{", "}", "\n", "if", "len", "(", "config", ".", "BuilderImage", ")", "==", "0", "{", "allErrs", "=", "append", "("...
// ValidateConfig returns a list of error from validation.
[ "ValidateConfig", "returns", "a", "list", "of", "error", "from", "validation", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/api/validation/validation.go#L13-L42
162,210
openshift/source-to-image
pkg/api/validation/validation.go
NewFieldInvalidValueWithReason
func NewFieldInvalidValueWithReason(field, reason string) Error { return Error{Type: ErrorInvalidValue, Field: field, Reason: reason} }
go
func NewFieldInvalidValueWithReason(field, reason string) Error { return Error{Type: ErrorInvalidValue, Field: field, Reason: reason} }
[ "func", "NewFieldInvalidValueWithReason", "(", "field", ",", "reason", "string", ")", "Error", "{", "return", "Error", "{", "Type", ":", "ErrorInvalidValue", ",", "Field", ":", "field", ",", "Reason", ":", "reason", "}", "\n", "}" ]
// NewFieldInvalidValueWithReason returns a ValidationError indicating "invalid value" and a reason for the error
[ "NewFieldInvalidValueWithReason", "returns", "a", "ValidationError", "indicating", "invalid", "value", "and", "a", "reason", "for", "the", "error" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/api/validation/validation.go#L76-L78
162,211
openshift/source-to-image
pkg/cmd/cli/cmd/completion.go
NewCmdCompletion
func NewCmdCompletion(root *cobra.Command) *cobra.Command { shells := []string{} for s := range completionShells { shells = append(shells, s) } return &cobra.Command{ Use: "completion SHELL", Short: "Generate completion for the s2i command (bash or zsh)", Long: "Generate completion for the s2i command i...
go
func NewCmdCompletion(root *cobra.Command) *cobra.Command { shells := []string{} for s := range completionShells { shells = append(shells, s) } return &cobra.Command{ Use: "completion SHELL", Short: "Generate completion for the s2i command (bash or zsh)", Long: "Generate completion for the s2i command i...
[ "func", "NewCmdCompletion", "(", "root", "*", "cobra", ".", "Command", ")", "*", "cobra", ".", "Command", "{", "shells", ":=", "[", "]", "string", "{", "}", "\n", "for", "s", ":=", "range", "completionShells", "{", "shells", "=", "append", "(", "shells...
// NewCmdCompletion implements the S2I cli completion command.
[ "NewCmdCompletion", "implements", "the", "S2I", "cli", "completion", "command", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/cmd/cli/cmd/completion.go#L21-L47
162,212
openshift/source-to-image
pkg/errors/errors.go
NewInspectImageError
func NewInspectImageError(name string, err error) error { return Error{ Message: fmt.Sprintf("unable to get metadata for %s", name), Details: err, ErrorCode: InspectImageError, Suggestion: "check image name", } }
go
func NewInspectImageError(name string, err error) error { return Error{ Message: fmt.Sprintf("unable to get metadata for %s", name), Details: err, ErrorCode: InspectImageError, Suggestion: "check image name", } }
[ "func", "NewInspectImageError", "(", "name", "string", ",", "err", "error", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", ",", "Details", ":", "err", ",", "ErrorCode", ":", "Inspect...
// NewInspectImageError returns a new error which indicates there was a problem // inspecting the image
[ "NewInspectImageError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "inspecting", "the", "image" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L61-L68
162,213
openshift/source-to-image
pkg/errors/errors.go
NewPullImageError
func NewPullImageError(name string, err error) error { return Error{ Message: fmt.Sprintf("unable to get %s", name), Details: err, ErrorCode: PullImageError, Suggestion: fmt.Sprintf("check image name, or if using a local image set the builder image pull policy to %q", "never"), } }
go
func NewPullImageError(name string, err error) error { return Error{ Message: fmt.Sprintf("unable to get %s", name), Details: err, ErrorCode: PullImageError, Suggestion: fmt.Sprintf("check image name, or if using a local image set the builder image pull policy to %q", "never"), } }
[ "func", "NewPullImageError", "(", "name", "string", ",", "err", "error", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", ",", "Details", ":", "err", ",", "ErrorCode", ":", "PullImageE...
// NewPullImageError returns a new error which indicates there was a problem // pulling the image
[ "NewPullImageError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "pulling", "the", "image" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L72-L79
162,214
openshift/source-to-image
pkg/errors/errors.go
NewSaveArtifactsError
func NewSaveArtifactsError(name, output string, err error) error { return Error{ Message: fmt.Sprintf("saving artifacts for %s failed:\n%s", name, output), Details: err, ErrorCode: SaveArtifactsError, Suggestion: "check the save-artifacts script for errors", } }
go
func NewSaveArtifactsError(name, output string, err error) error { return Error{ Message: fmt.Sprintf("saving artifacts for %s failed:\n%s", name, output), Details: err, ErrorCode: SaveArtifactsError, Suggestion: "check the save-artifacts script for errors", } }
[ "func", "NewSaveArtifactsError", "(", "name", ",", "output", "string", ",", "err", "error", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "name", ",", "output", ")", ",", "Details", ":", ...
// NewSaveArtifactsError returns a new error which indicates there was a problem // calling save-artifacts script
[ "NewSaveArtifactsError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "calling", "save", "-", "artifacts", "script" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L83-L90
162,215
openshift/source-to-image
pkg/errors/errors.go
NewAssembleError
func NewAssembleError(name, output string, err error) error { return Error{ Message: fmt.Sprintf("assemble for %s failed:\n%s", name, output), Details: err, ErrorCode: AssembleError, Suggestion: "check the assemble script output for errors", } }
go
func NewAssembleError(name, output string, err error) error { return Error{ Message: fmt.Sprintf("assemble for %s failed:\n%s", name, output), Details: err, ErrorCode: AssembleError, Suggestion: "check the assemble script output for errors", } }
[ "func", "NewAssembleError", "(", "name", ",", "output", "string", ",", "err", "error", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "name", ",", "output", ")", ",", "Details", ":", "er...
// NewAssembleError returns a new error which indicates there was a problem // running assemble script
[ "NewAssembleError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "running", "assemble", "script" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L94-L101
162,216
openshift/source-to-image
pkg/errors/errors.go
NewWorkDirError
func NewWorkDirError(dir string, err error) error { return Error{ Message: fmt.Sprintf("creating temporary directory %s failed", dir), Details: err, ErrorCode: WorkdirError, Suggestion: "check if you have access to your system's temporary directory", } }
go
func NewWorkDirError(dir string, err error) error { return Error{ Message: fmt.Sprintf("creating temporary directory %s failed", dir), Details: err, ErrorCode: WorkdirError, Suggestion: "check if you have access to your system's temporary directory", } }
[ "func", "NewWorkDirError", "(", "dir", "string", ",", "err", "error", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "dir", ")", ",", "Details", ":", "err", ",", "ErrorCode", ":", "WorkdirError",...
// NewWorkDirError returns a new error which indicates there was a problem // when creating working directory
[ "NewWorkDirError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "when", "creating", "working", "directory" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L105-L112
162,217
openshift/source-to-image
pkg/errors/errors.go
NewBuildError
func NewBuildError(name string, err error) error { return Error{ Message: fmt.Sprintf("building %s failed", name), Details: err, ErrorCode: BuildError, Suggestion: "check the build output for errors", } }
go
func NewBuildError(name string, err error) error { return Error{ Message: fmt.Sprintf("building %s failed", name), Details: err, ErrorCode: BuildError, Suggestion: "check the build output for errors", } }
[ "func", "NewBuildError", "(", "name", "string", ",", "err", "error", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", ",", "Details", ":", "err", ",", "ErrorCode", ":", "BuildError", ...
// NewBuildError returns a new error which indicates there was a problem // building the image
[ "NewBuildError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "building", "the", "image" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L116-L123
162,218
openshift/source-to-image
pkg/errors/errors.go
NewTarTimeoutError
func NewTarTimeoutError() error { return Error{ Message: fmt.Sprintf("timeout waiting for tar stream"), Details: nil, ErrorCode: TarTimeoutError, Suggestion: "check the Source-To-Image scripts if it accepts tar stream for assemble and sends for save-artifacts", } }
go
func NewTarTimeoutError() error { return Error{ Message: fmt.Sprintf("timeout waiting for tar stream"), Details: nil, ErrorCode: TarTimeoutError, Suggestion: "check the Source-To-Image scripts if it accepts tar stream for assemble and sends for save-artifacts", } }
[ "func", "NewTarTimeoutError", "(", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ")", ",", "Details", ":", "nil", ",", "ErrorCode", ":", "TarTimeoutError", ",", "Suggestion", ":", "\"", "\"", ",", "}...
// NewTarTimeoutError returns a new error which indicates there was a problem // when sending or receiving tar stream
[ "NewTarTimeoutError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "when", "sending", "or", "receiving", "tar", "stream" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L138-L145
162,219
openshift/source-to-image
pkg/errors/errors.go
NewDownloadError
func NewDownloadError(url string, code int) error { return Error{ Message: fmt.Sprintf("failed to retrieve %s, response code %d", url, code), Details: nil, ErrorCode: DownloadError, Suggestion: "check the availability of the address", } }
go
func NewDownloadError(url string, code int) error { return Error{ Message: fmt.Sprintf("failed to retrieve %s, response code %d", url, code), Details: nil, ErrorCode: DownloadError, Suggestion: "check the availability of the address", } }
[ "func", "NewDownloadError", "(", "url", "string", ",", "code", "int", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "url", ",", "code", ")", ",", "Details", ":", "nil", ",", "ErrorCode", ":", ...
// NewDownloadError returns a new error which indicates there was a problem // when downloading a file
[ "NewDownloadError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "when", "downloading", "a", "file" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L149-L156
162,220
openshift/source-to-image
pkg/errors/errors.go
NewScriptsInsideImageError
func NewScriptsInsideImageError(url string) error { return Error{ Message: fmt.Sprintf("scripts inside the image: %s", url), Details: nil, ErrorCode: ScriptsInsideImageError, Suggestion: "", } }
go
func NewScriptsInsideImageError(url string) error { return Error{ Message: fmt.Sprintf("scripts inside the image: %s", url), Details: nil, ErrorCode: ScriptsInsideImageError, Suggestion: "", } }
[ "func", "NewScriptsInsideImageError", "(", "url", "string", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "url", ")", ",", "Details", ":", "nil", ",", "ErrorCode", ":", "ScriptsInsideImageError", ",...
// NewScriptsInsideImageError returns a new error which informs of scripts // being placed inside the image
[ "NewScriptsInsideImageError", "returns", "a", "new", "error", "which", "informs", "of", "scripts", "being", "placed", "inside", "the", "image" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L160-L167
162,221
openshift/source-to-image
pkg/errors/errors.go
NewInstallError
func NewInstallError(script string) error { return Error{ Message: fmt.Sprintf("failed to install %v", script), Details: nil, ErrorCode: InstallError, Suggestion: fmt.Sprintf("set the scripts URL parameter with the location of the S2I scripts, or check if the image has the %q label set", constants.Scrip...
go
func NewInstallError(script string) error { return Error{ Message: fmt.Sprintf("failed to install %v", script), Details: nil, ErrorCode: InstallError, Suggestion: fmt.Sprintf("set the scripts URL parameter with the location of the S2I scripts, or check if the image has the %q label set", constants.Scrip...
[ "func", "NewInstallError", "(", "script", "string", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "script", ")", ",", "Details", ":", "nil", ",", "ErrorCode", ":", "InstallError", ",", "Suggestion...
// NewInstallError returns a new error which indicates there was a problem // when downloading a script
[ "NewInstallError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "when", "downloading", "a", "script" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L171-L178
162,222
openshift/source-to-image
pkg/errors/errors.go
NewInstallRequiredError
func NewInstallRequiredError(scripts []string, label string) error { return Error{ Message: fmt.Sprintf("failed to install %v", scripts), Details: nil, ErrorCode: InstallErrorRequired, Suggestion: fmt.Sprintf("set the scripts URL parameter with the location of the S2I scripts, or check if the image has ...
go
func NewInstallRequiredError(scripts []string, label string) error { return Error{ Message: fmt.Sprintf("failed to install %v", scripts), Details: nil, ErrorCode: InstallErrorRequired, Suggestion: fmt.Sprintf("set the scripts URL parameter with the location of the S2I scripts, or check if the image has ...
[ "func", "NewInstallRequiredError", "(", "scripts", "[", "]", "string", ",", "label", "string", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "scripts", ")", ",", "Details", ":", "nil", ",", "Err...
// NewInstallRequiredError returns a new error which indicates there was a problem // when downloading a required script
[ "NewInstallRequiredError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "when", "downloading", "a", "required", "script" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L182-L189
162,223
openshift/source-to-image
pkg/errors/errors.go
NewURLHandlerError
func NewURLHandlerError(url string) error { return Error{ Message: fmt.Sprintf("no URL handler for %s", url), Details: nil, ErrorCode: URLHandlerError, Suggestion: "check the URL", } }
go
func NewURLHandlerError(url string) error { return Error{ Message: fmt.Sprintf("no URL handler for %s", url), Details: nil, ErrorCode: URLHandlerError, Suggestion: "check the URL", } }
[ "func", "NewURLHandlerError", "(", "url", "string", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "url", ")", ",", "Details", ":", "nil", ",", "ErrorCode", ":", "URLHandlerError", ",", "Suggestion...
// NewURLHandlerError returns a new error which indicates there was a problem // when trying to read scripts URL
[ "NewURLHandlerError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "when", "trying", "to", "read", "scripts", "URL" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L193-L200
162,224
openshift/source-to-image
pkg/errors/errors.go
NewContainerError
func NewContainerError(name string, code int, output string) error { return ContainerError{ Message: fmt.Sprintf("non-zero (%d) exit code from %s", code, name), Output: output, ErrorCode: STIContainerError, Suggestion: "check the container logs for more information on the failure", ExitCode: code, ...
go
func NewContainerError(name string, code int, output string) error { return ContainerError{ Message: fmt.Sprintf("non-zero (%d) exit code from %s", code, name), Output: output, ErrorCode: STIContainerError, Suggestion: "check the container logs for more information on the failure", ExitCode: code, ...
[ "func", "NewContainerError", "(", "name", "string", ",", "code", "int", ",", "output", "string", ")", "error", "{", "return", "ContainerError", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "code", ",", "name", ")", ",", "Output", "...
// NewContainerError return a new error which indicates there was a problem // invoking command inside container
[ "NewContainerError", "return", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "invoking", "command", "inside", "container" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L204-L212
162,225
openshift/source-to-image
pkg/errors/errors.go
NewSourcePathError
func NewSourcePathError(path string) error { return Error{ Message: fmt.Sprintf("Local filesystem source path does not exist: %s", path), Details: nil, ErrorCode: SourcePathError, Suggestion: "check the source code path on the local filesystem", } }
go
func NewSourcePathError(path string) error { return Error{ Message: fmt.Sprintf("Local filesystem source path does not exist: %s", path), Details: nil, ErrorCode: SourcePathError, Suggestion: "check the source code path on the local filesystem", } }
[ "func", "NewSourcePathError", "(", "path", "string", ")", "error", "{", "return", "Error", "{", "Message", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "path", ")", ",", "Details", ":", "nil", ",", "ErrorCode", ":", "SourcePathError", ",", "Suggesti...
// NewSourcePathError returns a new error which indicates there was a problem // when accessing the source code from the local filesystem
[ "NewSourcePathError", "returns", "a", "new", "error", "which", "indicates", "there", "was", "a", "problem", "when", "accessing", "the", "source", "code", "from", "the", "local", "filesystem" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L216-L223
162,226
openshift/source-to-image
pkg/errors/errors.go
NewUserNotAllowedError
func NewUserNotAllowedError(image string, onbuild bool) error { var msg string if onbuild { msg = fmt.Sprintf("image %q includes at least one ONBUILD instruction that sets the user to a user that is not allowed", image) } else { msg = fmt.Sprintf("image %q must specify a user that is numeric and within the range...
go
func NewUserNotAllowedError(image string, onbuild bool) error { var msg string if onbuild { msg = fmt.Sprintf("image %q includes at least one ONBUILD instruction that sets the user to a user that is not allowed", image) } else { msg = fmt.Sprintf("image %q must specify a user that is numeric and within the range...
[ "func", "NewUserNotAllowedError", "(", "image", "string", ",", "onbuild", "bool", ")", "error", "{", "var", "msg", "string", "\n", "if", "onbuild", "{", "msg", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "image", ")", "\n", "}", "else", "{", "m...
// NewUserNotAllowedError returns a new error that indicates that the build // could not run because the image uses a user outside of the range of allowed users
[ "NewUserNotAllowedError", "returns", "a", "new", "error", "that", "indicates", "that", "the", "build", "could", "not", "run", "because", "the", "image", "uses", "a", "user", "outside", "of", "the", "range", "of", "allowed", "users" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L227-L239
162,227
openshift/source-to-image
pkg/errors/errors.go
NewAssembleUserNotAllowedError
func NewAssembleUserNotAllowedError(image string, usesConfig bool) error { var msg, suggestion string if usesConfig { msg = "assemble user must be numeric and within the range of allowed users" suggestion = "build without the allowed UIDs or assemble user configurations set" } else { msg = fmt.Sprintf("image %...
go
func NewAssembleUserNotAllowedError(image string, usesConfig bool) error { var msg, suggestion string if usesConfig { msg = "assemble user must be numeric and within the range of allowed users" suggestion = "build without the allowed UIDs or assemble user configurations set" } else { msg = fmt.Sprintf("image %...
[ "func", "NewAssembleUserNotAllowedError", "(", "image", "string", ",", "usesConfig", "bool", ")", "error", "{", "var", "msg", ",", "suggestion", "string", "\n", "if", "usesConfig", "{", "msg", "=", "\"", "\"", "\n", "suggestion", "=", "\"", "\"", "\n", "}"...
// NewAssembleUserNotAllowedError returns a new error that indicates that the build // could not run because the build or image uses an assemble user outside of the range // of allowed users.
[ "NewAssembleUserNotAllowedError", "returns", "a", "new", "error", "that", "indicates", "that", "the", "build", "could", "not", "run", "because", "the", "build", "or", "image", "uses", "an", "assemble", "user", "outside", "of", "the", "range", "of", "allowed", ...
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L244-L258
162,228
openshift/source-to-image
pkg/errors/errors.go
CheckError
func CheckError(err error) { if err == nil { return } if e, ok := err.(Error); ok { glog.Errorf("An error occurred: %v", e) glog.Errorf("Suggested solution: %v", e.Suggestion) if e.Details != nil { glog.V(1).Infof("Details: %v", e.Details) } glog.Error("If the problem persists consult the docs at htt...
go
func CheckError(err error) { if err == nil { return } if e, ok := err.(Error); ok { glog.Errorf("An error occurred: %v", e) glog.Errorf("Suggested solution: %v", e.Suggestion) if e.Details != nil { glog.V(1).Infof("Details: %v", e.Details) } glog.Error("If the problem persists consult the docs at htt...
[ "func", "CheckError", "(", "err", "error", ")", "{", "if", "err", "==", "nil", "{", "return", "\n", "}", "\n\n", "if", "e", ",", "ok", ":=", "err", ".", "(", "Error", ")", ";", "ok", "{", "glog", ".", "Errorf", "(", "\"", "\"", ",", "e", ")",...
// CheckError checks input error. // 1. if the input error is nil, the function does nothing but return. // 2. if the input error is a kind of Error which is thrown during S2I execution, // the function handle it with Suggestion and Details. // 3. if the input error is a kind of system Error which is unknown, the funct...
[ "CheckError", "checks", "input", "error", ".", "1", ".", "if", "the", "input", "error", "is", "nil", "the", "function", "does", "nothing", "but", "return", ".", "2", ".", "if", "the", "input", "error", "is", "a", "kind", "of", "Error", "which", "is", ...
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/errors/errors.go#L280-L299
162,229
openshift/source-to-image
pkg/version/version.go
String
func (info Info) String() string { version := info.GitVersion if version == "" { version = "unknown" } return version }
go
func (info Info) String() string { version := info.GitVersion if version == "" { version = "unknown" } return version }
[ "func", "(", "info", "Info", ")", "String", "(", ")", "string", "{", "version", ":=", "info", ".", "GitVersion", "\n", "if", "version", "==", "\"", "\"", "{", "version", "=", "\"", "\"", "\n", "}", "\n", "return", "version", "\n", "}" ]
// String returns info as a human-friendly version string.
[ "String", "returns", "info", "as", "a", "human", "-", "friendly", "version", "string", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/version/version.go#L36-L42
162,230
openshift/source-to-image
pkg/scripts/download.go
NewDownloader
func NewDownloader(proxyConfig *api.ProxyConfig) Downloader { httpReader := NewHTTPURLReader(proxyConfig) return &downloader{ schemeReaders: map[string]schemeReader{ "http": httpReader, "https": httpReader, "file": &FileURLReader{}, "image": &ImageReader{}, }, } }
go
func NewDownloader(proxyConfig *api.ProxyConfig) Downloader { httpReader := NewHTTPURLReader(proxyConfig) return &downloader{ schemeReaders: map[string]schemeReader{ "http": httpReader, "https": httpReader, "file": &FileURLReader{}, "image": &ImageReader{}, }, } }
[ "func", "NewDownloader", "(", "proxyConfig", "*", "api", ".", "ProxyConfig", ")", "Downloader", "{", "httpReader", ":=", "NewHTTPURLReader", "(", "proxyConfig", ")", "\n", "return", "&", "downloader", "{", "schemeReaders", ":", "map", "[", "string", "]", "sche...
// NewDownloader creates an instance of the default Downloader implementation
[ "NewDownloader", "creates", "an", "instance", "of", "the", "default", "Downloader", "implementation" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/scripts/download.go#L34-L44
162,231
openshift/source-to-image
pkg/scripts/download.go
NewHTTPURLReader
func NewHTTPURLReader(proxyConfig *api.ProxyConfig) *HTTPURLReader { getFunc := http.Get if proxyConfig != nil { transportMapMutex.Lock() transport, ok := transportMap[*proxyConfig] if !ok { transport = &http.Transport{ Proxy: func(req *http.Request) (*url.URL, error) { if proxyConfig.HTTPSProxy != ...
go
func NewHTTPURLReader(proxyConfig *api.ProxyConfig) *HTTPURLReader { getFunc := http.Get if proxyConfig != nil { transportMapMutex.Lock() transport, ok := transportMap[*proxyConfig] if !ok { transport = &http.Transport{ Proxy: func(req *http.Request) (*url.URL, error) { if proxyConfig.HTTPSProxy != ...
[ "func", "NewHTTPURLReader", "(", "proxyConfig", "*", "api", ".", "ProxyConfig", ")", "*", "HTTPURLReader", "{", "getFunc", ":=", "http", ".", "Get", "\n", "if", "proxyConfig", "!=", "nil", "{", "transportMapMutex", ".", "Lock", "(", ")", "\n", "transport", ...
// NewHTTPURLReader returns a new HTTPURLReader.
[ "NewHTTPURLReader", "returns", "a", "new", "HTTPURLReader", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/scripts/download.go#L95-L118
162,232
openshift/source-to-image
pkg/scripts/download.go
Read
func (*FileURLReader) Read(url *url.URL) (io.ReadCloser, error) { // for some reason url.Host may contain information about the ./ or ../ when // specifying relative path, thus using that value as well return os.Open(filepath.Join(url.Host, url.Path)) }
go
func (*FileURLReader) Read(url *url.URL) (io.ReadCloser, error) { // for some reason url.Host may contain information about the ./ or ../ when // specifying relative path, thus using that value as well return os.Open(filepath.Join(url.Host, url.Path)) }
[ "func", "(", "*", "FileURLReader", ")", "Read", "(", "url", "*", "url", ".", "URL", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "// for some reason url.Host may contain information about the ./ or ../ when", "// specifying relative path, thus using that val...
// Read produces an io.Reader from a file URL
[ "Read", "produces", "an", "io", ".", "Reader", "from", "a", "file", "URL" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/scripts/download.go#L139-L143
162,233
openshift/source-to-image
pkg/scripts/download.go
Read
func (*ImageReader) Read(url *url.URL) (io.ReadCloser, error) { return nil, s2ierr.NewScriptsInsideImageError(url.String()) }
go
func (*ImageReader) Read(url *url.URL) (io.ReadCloser, error) { return nil, s2ierr.NewScriptsInsideImageError(url.String()) }
[ "func", "(", "*", "ImageReader", ")", "Read", "(", "url", "*", "url", ".", "URL", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "return", "nil", ",", "s2ierr", ".", "NewScriptsInsideImageError", "(", "url", ".", "String", "(", ")", ")", ...
// Read throws Not implemented error
[ "Read", "throws", "Not", "implemented", "error" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/scripts/download.go#L149-L151
162,234
openshift/source-to-image
pkg/build/strategies/dockerfile/dockerfile.go
New
func New(config *api.Config, fs fs.FileSystem) (*Dockerfile, error) { return &Dockerfile{ fs: fs, // where we will get the assemble/run scripts from on the host machine, // if any are provided. uploadScriptsDir: constants.UploadScripts, uploadSrcDir: constants.Source, result: &api.Result{}, ...
go
func New(config *api.Config, fs fs.FileSystem) (*Dockerfile, error) { return &Dockerfile{ fs: fs, // where we will get the assemble/run scripts from on the host machine, // if any are provided. uploadScriptsDir: constants.UploadScripts, uploadSrcDir: constants.Source, result: &api.Result{}, ...
[ "func", "New", "(", "config", "*", "api", ".", "Config", ",", "fs", "fs", ".", "FileSystem", ")", "(", "*", "Dockerfile", ",", "error", ")", "{", "return", "&", "Dockerfile", "{", "fs", ":", "fs", ",", "// where we will get the assemble/run scripts from on t...
// New creates a Dockerfile builder.
[ "New", "creates", "a", "Dockerfile", "builder", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/build/strategies/dockerfile/dockerfile.go#L58-L68
162,235
openshift/source-to-image
pkg/build/strategies/dockerfile/dockerfile.go
Build
func (builder *Dockerfile) Build(config *api.Config) (*api.Result, error) { // Handle defaulting of the configuration that is unique to the dockerfile strategy if strings.HasSuffix(config.AsDockerfile, string(os.PathSeparator)) { config.AsDockerfile = config.AsDockerfile + "Dockerfile" } if len(config.AssembleUs...
go
func (builder *Dockerfile) Build(config *api.Config) (*api.Result, error) { // Handle defaulting of the configuration that is unique to the dockerfile strategy if strings.HasSuffix(config.AsDockerfile, string(os.PathSeparator)) { config.AsDockerfile = config.AsDockerfile + "Dockerfile" } if len(config.AssembleUs...
[ "func", "(", "builder", "*", "Dockerfile", ")", "Build", "(", "config", "*", "api", ".", "Config", ")", "(", "*", "api", ".", "Result", ",", "error", ")", "{", "// Handle defaulting of the configuration that is unique to the dockerfile strategy", "if", "strings", ...
// Build produces a Dockerfile that when run with the correct filesystem // context, will produce the application image.
[ "Build", "produces", "a", "Dockerfile", "that", "when", "run", "with", "the", "correct", "filesystem", "context", "will", "produce", "the", "application", "image", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/build/strategies/dockerfile/dockerfile.go#L72-L110
162,236
openshift/source-to-image
pkg/build/strategies/dockerfile/dockerfile.go
installScripts
func (builder *Dockerfile) installScripts(scriptsURL string, config *api.Config) []api.InstallResult { scriptInstaller := scripts.NewInstaller( "", scriptsURL, config.ScriptDownloadProxyConfig, nil, api.AuthConfig{}, builder.fs, ) // all scripts are optional, we trust the image contains scripts if we do...
go
func (builder *Dockerfile) installScripts(scriptsURL string, config *api.Config) []api.InstallResult { scriptInstaller := scripts.NewInstaller( "", scriptsURL, config.ScriptDownloadProxyConfig, nil, api.AuthConfig{}, builder.fs, ) // all scripts are optional, we trust the image contains scripts if we do...
[ "func", "(", "builder", "*", "Dockerfile", ")", "installScripts", "(", "scriptsURL", "string", ",", "config", "*", "api", ".", "Config", ")", "[", "]", "api", ".", "InstallResult", "{", "scriptInstaller", ":=", "scripts", ".", "NewInstaller", "(", "\"", "\...
// installScripts installs scripts at the provided URL to the Dockerfile context
[ "installScripts", "installs", "scripts", "at", "the", "provided", "URL", "to", "the", "Dockerfile", "context" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/build/strategies/dockerfile/dockerfile.go#L384-L397
162,237
openshift/source-to-image
pkg/build/strategies/dockerfile/dockerfile.go
setFailureReason
func (builder *Dockerfile) setFailureReason(reason api.StepFailureReason, message api.StepFailureMessage) { builder.result.BuildInfo.FailureReason = utilstatus.NewFailureReason(reason, message) }
go
func (builder *Dockerfile) setFailureReason(reason api.StepFailureReason, message api.StepFailureMessage) { builder.result.BuildInfo.FailureReason = utilstatus.NewFailureReason(reason, message) }
[ "func", "(", "builder", "*", "Dockerfile", ")", "setFailureReason", "(", "reason", "api", ".", "StepFailureReason", ",", "message", "api", ".", "StepFailureMessage", ")", "{", "builder", ".", "result", ".", "BuildInfo", ".", "FailureReason", "=", "utilstatus", ...
// setFailureReason sets the builder's failure reason with the given reason and message.
[ "setFailureReason", "sets", "the", "builder", "s", "failure", "reason", "with", "the", "given", "reason", "and", "message", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/build/strategies/dockerfile/dockerfile.go#L400-L402
162,238
openshift/source-to-image
pkg/build/strategies/dockerfile/dockerfile.go
getImageScriptsDir
func getImageScriptsDir(config *api.Config) (string, bool) { if strings.HasPrefix(config.ScriptsURL, "image://") { return strings.TrimPrefix(config.ScriptsURL, "image://"), true } if strings.HasPrefix(config.ImageScriptsURL, "image://") { return strings.TrimPrefix(config.ImageScriptsURL, "image://"), false } r...
go
func getImageScriptsDir(config *api.Config) (string, bool) { if strings.HasPrefix(config.ScriptsURL, "image://") { return strings.TrimPrefix(config.ScriptsURL, "image://"), true } if strings.HasPrefix(config.ImageScriptsURL, "image://") { return strings.TrimPrefix(config.ImageScriptsURL, "image://"), false } r...
[ "func", "getImageScriptsDir", "(", "config", "*", "api", ".", "Config", ")", "(", "string", ",", "bool", ")", "{", "if", "strings", ".", "HasPrefix", "(", "config", ".", "ScriptsURL", ",", "\"", "\"", ")", "{", "return", "strings", ".", "TrimPrefix", "...
// getImageScriptsDir returns the directory containing the builder image scripts and a bool // indicating that the directory is expected to contain all s2i scripts
[ "getImageScriptsDir", "returns", "the", "directory", "containing", "the", "builder", "image", "scripts", "and", "a", "bool", "indicating", "that", "the", "directory", "is", "expected", "to", "contain", "all", "s2i", "scripts" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/build/strategies/dockerfile/dockerfile.go#L415-L423
162,239
openshift/source-to-image
pkg/build/strategies/dockerfile/dockerfile.go
scanScripts
func scanScripts(name string) map[string]bool { scriptsMap := make(map[string]bool) items, err := ioutil.ReadDir(name) if os.IsNotExist(err) { glog.Warningf("Unable to access directory %q: %v", name, err) } if err != nil || len(items) == 0 { return scriptsMap } assembleProvided := false runProvided := fals...
go
func scanScripts(name string) map[string]bool { scriptsMap := make(map[string]bool) items, err := ioutil.ReadDir(name) if os.IsNotExist(err) { glog.Warningf("Unable to access directory %q: %v", name, err) } if err != nil || len(items) == 0 { return scriptsMap } assembleProvided := false runProvided := fals...
[ "func", "scanScripts", "(", "name", "string", ")", "map", "[", "string", "]", "bool", "{", "scriptsMap", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "items", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "name", ")", "\n", "...
// scanScripts returns a map of provided s2i scripts
[ "scanScripts", "returns", "a", "map", "of", "provided", "s2i", "scripts" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/build/strategies/dockerfile/dockerfile.go#L426-L456
162,240
openshift/source-to-image
pkg/util/labels.go
GenerateOutputImageLabels
func GenerateOutputImageLabels(info *git.SourceInfo, config *api.Config) map[string]string { labels := map[string]string{} namespace := constants.DefaultNamespace if len(config.LabelNamespace) > 0 { namespace = config.LabelNamespace } labels = GenerateLabelsFromConfig(labels, config, namespace) labels = Genera...
go
func GenerateOutputImageLabels(info *git.SourceInfo, config *api.Config) map[string]string { labels := map[string]string{} namespace := constants.DefaultNamespace if len(config.LabelNamespace) > 0 { namespace = config.LabelNamespace } labels = GenerateLabelsFromConfig(labels, config, namespace) labels = Genera...
[ "func", "GenerateOutputImageLabels", "(", "info", "*", "git", ".", "SourceInfo", ",", "config", "*", "api", ".", "Config", ")", "map", "[", "string", "]", "string", "{", "labels", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "namespace", ...
// GenerateOutputImageLabels generate the labels based on the s2i Config // and source repository informations.
[ "GenerateOutputImageLabels", "generate", "the", "labels", "based", "on", "the", "s2i", "Config", "and", "source", "repository", "informations", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/util/labels.go#L13-L23
162,241
openshift/source-to-image
pkg/util/labels.go
GenerateLabelsFromConfig
func GenerateLabelsFromConfig(labels map[string]string, config *api.Config, namespace string) map[string]string { if len(config.Description) > 0 { labels[constants.KubernetesDescriptionLabel] = config.Description } if len(config.DisplayName) > 0 { labels[constants.KubernetesDisplayNameLabel] = config.DisplayNam...
go
func GenerateLabelsFromConfig(labels map[string]string, config *api.Config, namespace string) map[string]string { if len(config.Description) > 0 { labels[constants.KubernetesDescriptionLabel] = config.Description } if len(config.DisplayName) > 0 { labels[constants.KubernetesDisplayNameLabel] = config.DisplayNam...
[ "func", "GenerateLabelsFromConfig", "(", "labels", "map", "[", "string", "]", "string", ",", "config", "*", "api", ".", "Config", ",", "namespace", "string", ")", "map", "[", "string", "]", "string", "{", "if", "len", "(", "config", ".", "Description", "...
// GenerateLabelsFromConfig generate the labels based on build s2i Config
[ "GenerateLabelsFromConfig", "generate", "the", "labels", "based", "on", "build", "s2i", "Config" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/util/labels.go#L26-L39
162,242
openshift/source-to-image
pkg/util/labels.go
GenerateLabelsFromSourceInfo
func GenerateLabelsFromSourceInfo(labels map[string]string, info *git.SourceInfo, namespace string) map[string]string { if info == nil { glog.V(3).Info("Unable to fetch source information, the output image labels will not be set") return labels } if len(info.AuthorName) > 0 { author := fmt.Sprintf("%s <%s>", ...
go
func GenerateLabelsFromSourceInfo(labels map[string]string, info *git.SourceInfo, namespace string) map[string]string { if info == nil { glog.V(3).Info("Unable to fetch source information, the output image labels will not be set") return labels } if len(info.AuthorName) > 0 { author := fmt.Sprintf("%s <%s>", ...
[ "func", "GenerateLabelsFromSourceInfo", "(", "labels", "map", "[", "string", "]", "string", ",", "info", "*", "git", ".", "SourceInfo", ",", "namespace", "string", ")", "map", "[", "string", "]", "string", "{", "if", "info", "==", "nil", "{", "glog", "."...
// GenerateLabelsFromSourceInfo generate the labels based on the source repository // informations.
[ "GenerateLabelsFromSourceInfo", "generate", "the", "labels", "based", "on", "the", "source", "repository", "informations", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/util/labels.go#L43-L61
162,243
openshift/source-to-image
pkg/tar/tar.go
WriteHeader
func (a ChmodAdapter) WriteHeader(hdr *tar.Header) error { if hdr.FileInfo().Mode()&os.ModeSymlink == 0 { newMode := hdr.Mode &^ 0777 if hdr.FileInfo().IsDir() { newMode |= a.NewDirMode } else if hdr.FileInfo().Mode()&0010 != 0 { // S_IXUSR newMode |= a.NewExecFileMode } else { newMode |= a.NewFileMod...
go
func (a ChmodAdapter) WriteHeader(hdr *tar.Header) error { if hdr.FileInfo().Mode()&os.ModeSymlink == 0 { newMode := hdr.Mode &^ 0777 if hdr.FileInfo().IsDir() { newMode |= a.NewDirMode } else if hdr.FileInfo().Mode()&0010 != 0 { // S_IXUSR newMode |= a.NewExecFileMode } else { newMode |= a.NewFileMod...
[ "func", "(", "a", "ChmodAdapter", ")", "WriteHeader", "(", "hdr", "*", "tar", ".", "Header", ")", "error", "{", "if", "hdr", ".", "FileInfo", "(", ")", ".", "Mode", "(", ")", "&", "os", ".", "ModeSymlink", "==", "0", "{", "newMode", ":=", "hdr", ...
// WriteHeader changes the mode of files and directories inline as a tarfile is // being written
[ "WriteHeader", "changes", "the", "mode", "of", "files", "and", "directories", "inline", "as", "a", "tarfile", "is", "being", "written" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L100-L113
162,244
openshift/source-to-image
pkg/tar/tar.go
WriteHeader
func (a RenameAdapter) WriteHeader(hdr *tar.Header) error { if hdr.Name == a.Old { hdr.Name = a.New } else if strings.HasPrefix(hdr.Name, a.Old+"/") { hdr.Name = a.New + hdr.Name[len(a.Old):] } return a.Writer.WriteHeader(hdr) }
go
func (a RenameAdapter) WriteHeader(hdr *tar.Header) error { if hdr.Name == a.Old { hdr.Name = a.New } else if strings.HasPrefix(hdr.Name, a.Old+"/") { hdr.Name = a.New + hdr.Name[len(a.Old):] } return a.Writer.WriteHeader(hdr) }
[ "func", "(", "a", "RenameAdapter", ")", "WriteHeader", "(", "hdr", "*", "tar", ".", "Header", ")", "error", "{", "if", "hdr", ".", "Name", "==", "a", ".", "Old", "{", "hdr", ".", "Name", "=", "a", ".", "New", "\n", "}", "else", "if", "strings", ...
// WriteHeader renames files and directories inline as a tarfile is being // written
[ "WriteHeader", "renames", "files", "and", "directories", "inline", "as", "a", "tarfile", "is", "being", "written" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L125-L133
162,245
openshift/source-to-image
pkg/tar/tar.go
New
func New(fs fs.FileSystem) Tar { return &stiTar{ FileSystem: fs, exclude: DefaultExclusionPattern, timeout: defaultTimeout, } }
go
func New(fs fs.FileSystem) Tar { return &stiTar{ FileSystem: fs, exclude: DefaultExclusionPattern, timeout: defaultTimeout, } }
[ "func", "New", "(", "fs", "fs", ".", "FileSystem", ")", "Tar", "{", "return", "&", "stiTar", "{", "FileSystem", ":", "fs", ",", "exclude", ":", "DefaultExclusionPattern", ",", "timeout", ":", "defaultTimeout", ",", "}", "\n", "}" ]
// New creates a new Tar
[ "New", "creates", "a", "new", "Tar" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L136-L142
162,246
openshift/source-to-image
pkg/tar/tar.go
NewWithTimeout
func NewWithTimeout(fs fs.FileSystem, timeout time.Duration) Tar { return &stiTar{ FileSystem: fs, exclude: DefaultExclusionPattern, timeout: timeout, } }
go
func NewWithTimeout(fs fs.FileSystem, timeout time.Duration) Tar { return &stiTar{ FileSystem: fs, exclude: DefaultExclusionPattern, timeout: timeout, } }
[ "func", "NewWithTimeout", "(", "fs", "fs", ".", "FileSystem", ",", "timeout", "time", ".", "Duration", ")", "Tar", "{", "return", "&", "stiTar", "{", "FileSystem", ":", "fs", ",", "exclude", ":", "DefaultExclusionPattern", ",", "timeout", ":", "timeout", "...
// NewWithTimeout creates a new Tar with the provided timeout extracting files.
[ "NewWithTimeout", "creates", "a", "new", "Tar", "with", "the", "provided", "timeout", "extracting", "files", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L145-L151
162,247
openshift/source-to-image
pkg/tar/tar.go
NewParanoid
func NewParanoid(fs fs.FileSystem) Tar { return &stiTar{ FileSystem: fs, exclude: DefaultExclusionPattern, timeout: defaultTimeout, disallowOverwrite: true, disallowOutsidePaths: true, disallowSpecialFiles: true, } }
go
func NewParanoid(fs fs.FileSystem) Tar { return &stiTar{ FileSystem: fs, exclude: DefaultExclusionPattern, timeout: defaultTimeout, disallowOverwrite: true, disallowOutsidePaths: true, disallowSpecialFiles: true, } }
[ "func", "NewParanoid", "(", "fs", "fs", ".", "FileSystem", ")", "Tar", "{", "return", "&", "stiTar", "{", "FileSystem", ":", "fs", ",", "exclude", ":", "DefaultExclusionPattern", ",", "timeout", ":", "defaultTimeout", ",", "disallowOverwrite", ":", "true", "...
// NewParanoid creates a new Tar that has restrictions // on what it can do while extracting files.
[ "NewParanoid", "creates", "a", "new", "Tar", "that", "has", "restrictions", "on", "what", "it", "can", "do", "while", "extracting", "files", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L155-L164
162,248
openshift/source-to-image
pkg/tar/tar.go
NewParanoidWithTimeout
func NewParanoidWithTimeout(fs fs.FileSystem, timeout time.Duration) Tar { return &stiTar{ FileSystem: fs, exclude: DefaultExclusionPattern, timeout: timeout, disallowOverwrite: true, disallowOutsidePaths: true, disallowSpecialFiles: true, } }
go
func NewParanoidWithTimeout(fs fs.FileSystem, timeout time.Duration) Tar { return &stiTar{ FileSystem: fs, exclude: DefaultExclusionPattern, timeout: timeout, disallowOverwrite: true, disallowOutsidePaths: true, disallowSpecialFiles: true, } }
[ "func", "NewParanoidWithTimeout", "(", "fs", "fs", ".", "FileSystem", ",", "timeout", "time", ".", "Duration", ")", "Tar", "{", "return", "&", "stiTar", "{", "FileSystem", ":", "fs", ",", "exclude", ":", "DefaultExclusionPattern", ",", "timeout", ":", "timeo...
// NewParanoidWithTimeout creates a new Tar with the provided timeout extracting files. // It has restrictions on what it can do while extracting files.
[ "NewParanoidWithTimeout", "creates", "a", "new", "Tar", "with", "the", "provided", "timeout", "extracting", "files", ".", "It", "has", "restrictions", "on", "what", "it", "can", "do", "while", "extracting", "files", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L168-L177
162,249
openshift/source-to-image
pkg/tar/tar.go
CreateTarFile
func (t *stiTar) CreateTarFile(base, dir string) (string, error) { tarFile, err := ioutil.TempFile(base, "tar") defer tarFile.Close() if err != nil { return "", err } if err = t.CreateTarStream(dir, false, tarFile); err != nil { return "", err } return tarFile.Name(), nil }
go
func (t *stiTar) CreateTarFile(base, dir string) (string, error) { tarFile, err := ioutil.TempFile(base, "tar") defer tarFile.Close() if err != nil { return "", err } if err = t.CreateTarStream(dir, false, tarFile); err != nil { return "", err } return tarFile.Name(), nil }
[ "func", "(", "t", "*", "stiTar", ")", "CreateTarFile", "(", "base", ",", "dir", "string", ")", "(", "string", ",", "error", ")", "{", "tarFile", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "base", ",", "\"", "\"", ")", "\n", "defer", "tarFile...
// CreateTarFile creates a tar file from the given directory // while excluding files that match the given exclusion pattern // It returns the name of the created file
[ "CreateTarFile", "creates", "a", "tar", "file", "from", "the", "given", "directory", "while", "excluding", "files", "that", "match", "the", "given", "exclusion", "pattern", "It", "returns", "the", "name", "of", "the", "created", "file" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L200-L210
162,250
openshift/source-to-image
pkg/tar/tar.go
CreateTarStream
func (t *stiTar) CreateTarStream(dir string, includeDirInPath bool, writer io.Writer) error { tarWriter := tar.NewWriter(writer) defer tarWriter.Close() return t.CreateTarStreamToTarWriter(dir, includeDirInPath, tarWriter, nil) }
go
func (t *stiTar) CreateTarStream(dir string, includeDirInPath bool, writer io.Writer) error { tarWriter := tar.NewWriter(writer) defer tarWriter.Close() return t.CreateTarStreamToTarWriter(dir, includeDirInPath, tarWriter, nil) }
[ "func", "(", "t", "*", "stiTar", ")", "CreateTarStream", "(", "dir", "string", ",", "includeDirInPath", "bool", ",", "writer", "io", ".", "Writer", ")", "error", "{", "tarWriter", ":=", "tar", ".", "NewWriter", "(", "writer", ")", "\n", "defer", "tarWrit...
// CreateTarStream calls CreateTarStreamToTarWriter with a nil logger
[ "CreateTarStream", "calls", "CreateTarStreamToTarWriter", "with", "a", "nil", "logger" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L217-L222
162,251
openshift/source-to-image
pkg/tar/tar.go
CreateTarStreamReader
func (t *stiTar) CreateTarStreamReader(dir string, includeDirInPath bool) io.ReadCloser { r, w := io.Pipe() go func() { w.CloseWithError(t.CreateTarStream(dir, includeDirInPath, w)) }() return r }
go
func (t *stiTar) CreateTarStreamReader(dir string, includeDirInPath bool) io.ReadCloser { r, w := io.Pipe() go func() { w.CloseWithError(t.CreateTarStream(dir, includeDirInPath, w)) }() return r }
[ "func", "(", "t", "*", "stiTar", ")", "CreateTarStreamReader", "(", "dir", "string", ",", "includeDirInPath", "bool", ")", "io", ".", "ReadCloser", "{", "r", ",", "w", ":=", "io", ".", "Pipe", "(", ")", "\n", "go", "func", "(", ")", "{", "w", ".", ...
// CreateTarStreamReader returns an io.ReadCloser from which a tar stream can be // read. The tar stream is created using CreateTarStream.
[ "CreateTarStreamReader", "returns", "an", "io", ".", "ReadCloser", "from", "which", "a", "tar", "stream", "can", "be", "read", ".", "The", "tar", "stream", "is", "created", "using", "CreateTarStream", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L226-L232
162,252
openshift/source-to-image
pkg/tar/tar.go
CreateTarStreamToTarWriter
func (t *stiTar) CreateTarStreamToTarWriter(dir string, includeDirInPath bool, tarWriter Writer, logger io.Writer) error { dir = filepath.Clean(dir) // remove relative paths and extraneous slashes glog.V(5).Infof("Adding %q to tar ...", dir) err := t.Walk(dir, func(path string, info os.FileInfo, err error) error { ...
go
func (t *stiTar) CreateTarStreamToTarWriter(dir string, includeDirInPath bool, tarWriter Writer, logger io.Writer) error { dir = filepath.Clean(dir) // remove relative paths and extraneous slashes glog.V(5).Infof("Adding %q to tar ...", dir) err := t.Walk(dir, func(path string, info os.FileInfo, err error) error { ...
[ "func", "(", "t", "*", "stiTar", ")", "CreateTarStreamToTarWriter", "(", "dir", "string", ",", "includeDirInPath", "bool", ",", "tarWriter", "Writer", ",", "logger", "io", ".", "Writer", ")", "error", "{", "dir", "=", "filepath", ".", "Clean", "(", "dir", ...
// CreateTarStreamToTarWriter creates a tar stream on the given writer from // the given directory while excluding files that match the given // exclusion pattern.
[ "CreateTarStreamToTarWriter", "creates", "a", "tar", "stream", "on", "the", "given", "writer", "from", "the", "given", "directory", "while", "excluding", "files", "that", "match", "the", "given", "exclusion", "pattern", "." ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L237-L297
162,253
openshift/source-to-image
pkg/tar/tar.go
writeTarHeader
func (t *stiTar) writeTarHeader(tarWriter Writer, dir string, path string, info os.FileInfo, includeDirInPath bool, logger io.Writer) error { var ( link string err error ) if info.Mode()&os.ModeSymlink != 0 { link, err = os.Readlink(path) if err != nil { return err } } header, err := tar.FileInfoHead...
go
func (t *stiTar) writeTarHeader(tarWriter Writer, dir string, path string, info os.FileInfo, includeDirInPath bool, logger io.Writer) error { var ( link string err error ) if info.Mode()&os.ModeSymlink != 0 { link, err = os.Readlink(path) if err != nil { return err } } header, err := tar.FileInfoHead...
[ "func", "(", "t", "*", "stiTar", ")", "writeTarHeader", "(", "tarWriter", "Writer", ",", "dir", "string", ",", "path", "string", ",", "info", "os", ".", "FileInfo", ",", "includeDirInPath", "bool", ",", "logger", "io", ".", "Writer", ")", "error", "{", ...
// writeTarHeader writes tar header for given file, returns error if operation fails
[ "writeTarHeader", "writes", "tar", "header", "for", "given", "file", "returns", "error", "if", "operation", "fails" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L300-L339
162,254
openshift/source-to-image
pkg/tar/tar.go
ExtractTarStream
func (t *stiTar) ExtractTarStream(dir string, reader io.Reader) error { tarReader := tar.NewReader(reader) return t.ExtractTarStreamFromTarReader(dir, tarReader, nil) }
go
func (t *stiTar) ExtractTarStream(dir string, reader io.Reader) error { tarReader := tar.NewReader(reader) return t.ExtractTarStreamFromTarReader(dir, tarReader, nil) }
[ "func", "(", "t", "*", "stiTar", ")", "ExtractTarStream", "(", "dir", "string", ",", "reader", "io", ".", "Reader", ")", "error", "{", "tarReader", ":=", "tar", ".", "NewReader", "(", "reader", ")", "\n", "return", "t", ".", "ExtractTarStreamFromTarReader"...
// ExtractTarStream calls ExtractTarStreamFromTarReader with a default reader and nil logger
[ "ExtractTarStream", "calls", "ExtractTarStreamFromTarReader", "with", "a", "default", "reader", "and", "nil", "logger" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L342-L345
162,255
openshift/source-to-image
pkg/tar/tar.go
ExtractTarStreamWithLogging
func (t *stiTar) ExtractTarStreamWithLogging(dir string, reader io.Reader, logger io.Writer) error { tarReader := tar.NewReader(reader) return t.ExtractTarStreamFromTarReader(dir, tarReader, logger) }
go
func (t *stiTar) ExtractTarStreamWithLogging(dir string, reader io.Reader, logger io.Writer) error { tarReader := tar.NewReader(reader) return t.ExtractTarStreamFromTarReader(dir, tarReader, logger) }
[ "func", "(", "t", "*", "stiTar", ")", "ExtractTarStreamWithLogging", "(", "dir", "string", ",", "reader", "io", ".", "Reader", ",", "logger", "io", ".", "Writer", ")", "error", "{", "tarReader", ":=", "tar", ".", "NewReader", "(", "reader", ")", "\n", ...
// ExtractTarStreamWithLogging calls ExtractTarStreamFromTarReader with a default reader
[ "ExtractTarStreamWithLogging", "calls", "ExtractTarStreamFromTarReader", "with", "a", "default", "reader" ]
2ba8a349386aff03c26729096b0225a691355fe9
https://github.com/openshift/source-to-image/blob/2ba8a349386aff03c26729096b0225a691355fe9/pkg/tar/tar.go#L348-L351
162,256
boltdb/bolt
bolt_linux.go
fdatasync
func fdatasync(db *DB) error { return syscall.Fdatasync(int(db.file.Fd())) }
go
func fdatasync(db *DB) error { return syscall.Fdatasync(int(db.file.Fd())) }
[ "func", "fdatasync", "(", "db", "*", "DB", ")", "error", "{", "return", "syscall", ".", "Fdatasync", "(", "int", "(", "db", ".", "file", ".", "Fd", "(", ")", ")", ")", "\n", "}" ]
// fdatasync flushes written data to a file descriptor.
[ "fdatasync", "flushes", "written", "data", "to", "a", "file", "descriptor", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/bolt_linux.go#L8-L10
162,257
boltdb/bolt
freelist.go
newFreelist
func newFreelist() *freelist { return &freelist{ pending: make(map[txid][]pgid), cache: make(map[pgid]bool), } }
go
func newFreelist() *freelist { return &freelist{ pending: make(map[txid][]pgid), cache: make(map[pgid]bool), } }
[ "func", "newFreelist", "(", ")", "*", "freelist", "{", "return", "&", "freelist", "{", "pending", ":", "make", "(", "map", "[", "txid", "]", "[", "]", "pgid", ")", ",", "cache", ":", "make", "(", "map", "[", "pgid", "]", "bool", ")", ",", "}", ...
// newFreelist returns an empty, initialized freelist.
[ "newFreelist", "returns", "an", "empty", "initialized", "freelist", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L18-L23
162,258
boltdb/bolt
freelist.go
size
func (f *freelist) size() int { n := f.count() if n >= 0xFFFF { // The first element will be used to store the count. See freelist.write. n++ } return pageHeaderSize + (int(unsafe.Sizeof(pgid(0))) * n) }
go
func (f *freelist) size() int { n := f.count() if n >= 0xFFFF { // The first element will be used to store the count. See freelist.write. n++ } return pageHeaderSize + (int(unsafe.Sizeof(pgid(0))) * n) }
[ "func", "(", "f", "*", "freelist", ")", "size", "(", ")", "int", "{", "n", ":=", "f", ".", "count", "(", ")", "\n", "if", "n", ">=", "0xFFFF", "{", "// The first element will be used to store the count. See freelist.write.", "n", "++", "\n", "}", "\n", "re...
// size returns the size of the page after serialization.
[ "size", "returns", "the", "size", "of", "the", "page", "after", "serialization", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L26-L33
162,259
boltdb/bolt
freelist.go
pending_count
func (f *freelist) pending_count() int { var count int for _, list := range f.pending { count += len(list) } return count }
go
func (f *freelist) pending_count() int { var count int for _, list := range f.pending { count += len(list) } return count }
[ "func", "(", "f", "*", "freelist", ")", "pending_count", "(", ")", "int", "{", "var", "count", "int", "\n", "for", "_", ",", "list", ":=", "range", "f", ".", "pending", "{", "count", "+=", "len", "(", "list", ")", "\n", "}", "\n", "return", "coun...
// pending_count returns count of pending pages
[ "pending_count", "returns", "count", "of", "pending", "pages" ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L46-L52
162,260
boltdb/bolt
freelist.go
copyall
func (f *freelist) copyall(dst []pgid) { m := make(pgids, 0, f.pending_count()) for _, list := range f.pending { m = append(m, list...) } sort.Sort(m) mergepgids(dst, f.ids, m) }
go
func (f *freelist) copyall(dst []pgid) { m := make(pgids, 0, f.pending_count()) for _, list := range f.pending { m = append(m, list...) } sort.Sort(m) mergepgids(dst, f.ids, m) }
[ "func", "(", "f", "*", "freelist", ")", "copyall", "(", "dst", "[", "]", "pgid", ")", "{", "m", ":=", "make", "(", "pgids", ",", "0", ",", "f", ".", "pending_count", "(", ")", ")", "\n", "for", "_", ",", "list", ":=", "range", "f", ".", "pend...
// copyall copies into dst a list of all free ids and all pending ids in one sorted list. // f.count returns the minimum length required for dst.
[ "copyall", "copies", "into", "dst", "a", "list", "of", "all", "free", "ids", "and", "all", "pending", "ids", "in", "one", "sorted", "list", ".", "f", ".", "count", "returns", "the", "minimum", "length", "required", "for", "dst", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L56-L63
162,261
boltdb/bolt
freelist.go
allocate
func (f *freelist) allocate(n int) pgid { if len(f.ids) == 0 { return 0 } var initial, previd pgid for i, id := range f.ids { if id <= 1 { panic(fmt.Sprintf("invalid page allocation: %d", id)) } // Reset initial page if this is not contiguous. if previd == 0 || id-previd != 1 { initial = id } ...
go
func (f *freelist) allocate(n int) pgid { if len(f.ids) == 0 { return 0 } var initial, previd pgid for i, id := range f.ids { if id <= 1 { panic(fmt.Sprintf("invalid page allocation: %d", id)) } // Reset initial page if this is not contiguous. if previd == 0 || id-previd != 1 { initial = id } ...
[ "func", "(", "f", "*", "freelist", ")", "allocate", "(", "n", "int", ")", "pgid", "{", "if", "len", "(", "f", ".", "ids", ")", "==", "0", "{", "return", "0", "\n", "}", "\n\n", "var", "initial", ",", "previd", "pgid", "\n", "for", "i", ",", "...
// allocate returns the starting page id of a contiguous list of pages of a given size. // If a contiguous block cannot be found then 0 is returned.
[ "allocate", "returns", "the", "starting", "page", "id", "of", "a", "contiguous", "list", "of", "pages", "of", "a", "given", "size", ".", "If", "a", "contiguous", "block", "cannot", "be", "found", "then", "0", "is", "returned", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L67-L107
162,262
boltdb/bolt
freelist.go
free
func (f *freelist) free(txid txid, p *page) { if p.id <= 1 { panic(fmt.Sprintf("cannot free page 0 or 1: %d", p.id)) } // Free page and all its overflow pages. var ids = f.pending[txid] for id := p.id; id <= p.id+pgid(p.overflow); id++ { // Verify that page is not already free. if f.cache[id] { panic(fmt...
go
func (f *freelist) free(txid txid, p *page) { if p.id <= 1 { panic(fmt.Sprintf("cannot free page 0 or 1: %d", p.id)) } // Free page and all its overflow pages. var ids = f.pending[txid] for id := p.id; id <= p.id+pgid(p.overflow); id++ { // Verify that page is not already free. if f.cache[id] { panic(fmt...
[ "func", "(", "f", "*", "freelist", ")", "free", "(", "txid", "txid", ",", "p", "*", "page", ")", "{", "if", "p", ".", "id", "<=", "1", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "id", ")", ")", "\n", "}", "\...
// free releases a page and its overflow for a given transaction id. // If the page is already free then a panic will occur.
[ "free", "releases", "a", "page", "and", "its", "overflow", "for", "a", "given", "transaction", "id", ".", "If", "the", "page", "is", "already", "free", "then", "a", "panic", "will", "occur", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L111-L129
162,263
boltdb/bolt
freelist.go
rollback
func (f *freelist) rollback(txid txid) { // Remove page ids from cache. for _, id := range f.pending[txid] { delete(f.cache, id) } // Remove pages from pending list. delete(f.pending, txid) }
go
func (f *freelist) rollback(txid txid) { // Remove page ids from cache. for _, id := range f.pending[txid] { delete(f.cache, id) } // Remove pages from pending list. delete(f.pending, txid) }
[ "func", "(", "f", "*", "freelist", ")", "rollback", "(", "txid", "txid", ")", "{", "// Remove page ids from cache.", "for", "_", ",", "id", ":=", "range", "f", ".", "pending", "[", "txid", "]", "{", "delete", "(", "f", ".", "cache", ",", "id", ")", ...
// rollback removes the pages from a given pending tx.
[ "rollback", "removes", "the", "pages", "from", "a", "given", "pending", "tx", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L147-L155
162,264
boltdb/bolt
freelist.go
read
func (f *freelist) read(p *page) { // If the page.count is at the max uint16 value (64k) then it's considered // an overflow and the size of the freelist is stored as the first element. idx, count := 0, int(p.count) if count == 0xFFFF { idx = 1 count = int(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[0]) } ...
go
func (f *freelist) read(p *page) { // If the page.count is at the max uint16 value (64k) then it's considered // an overflow and the size of the freelist is stored as the first element. idx, count := 0, int(p.count) if count == 0xFFFF { idx = 1 count = int(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[0]) } ...
[ "func", "(", "f", "*", "freelist", ")", "read", "(", "p", "*", "page", ")", "{", "// If the page.count is at the max uint16 value (64k) then it's considered", "// an overflow and the size of the freelist is stored as the first element.", "idx", ",", "count", ":=", "0", ",", ...
// read initializes the freelist from a freelist page.
[ "read", "initializes", "the", "freelist", "from", "a", "freelist", "page", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L163-L186
162,265
boltdb/bolt
freelist.go
write
func (f *freelist) write(p *page) error { // Combine the old free pgids and pgids waiting on an open transaction. // Update the header flag. p.flags |= freelistPageFlag // The page.count can only hold up to 64k elements so if we overflow that // number then we handle it by putting the size in the first element. ...
go
func (f *freelist) write(p *page) error { // Combine the old free pgids and pgids waiting on an open transaction. // Update the header flag. p.flags |= freelistPageFlag // The page.count can only hold up to 64k elements so if we overflow that // number then we handle it by putting the size in the first element. ...
[ "func", "(", "f", "*", "freelist", ")", "write", "(", "p", "*", "page", ")", "error", "{", "// Combine the old free pgids and pgids waiting on an open transaction.", "// Update the header flag.", "p", ".", "flags", "|=", "freelistPageFlag", "\n\n", "// The page.count can ...
// write writes the page ids onto a freelist page. All free and pending ids are // saved to disk since in the event of a program crash, all pending ids will // become free.
[ "write", "writes", "the", "page", "ids", "onto", "a", "freelist", "page", ".", "All", "free", "and", "pending", "ids", "are", "saved", "to", "disk", "since", "in", "the", "event", "of", "a", "program", "crash", "all", "pending", "ids", "will", "become", ...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L191-L212
162,266
boltdb/bolt
freelist.go
reload
func (f *freelist) reload(p *page) { f.read(p) // Build a cache of only pending pages. pcache := make(map[pgid]bool) for _, pendingIDs := range f.pending { for _, pendingID := range pendingIDs { pcache[pendingID] = true } } // Check each page in the freelist and build a new available freelist // with an...
go
func (f *freelist) reload(p *page) { f.read(p) // Build a cache of only pending pages. pcache := make(map[pgid]bool) for _, pendingIDs := range f.pending { for _, pendingID := range pendingIDs { pcache[pendingID] = true } } // Check each page in the freelist and build a new available freelist // with an...
[ "func", "(", "f", "*", "freelist", ")", "reload", "(", "p", "*", "page", ")", "{", "f", ".", "read", "(", "p", ")", "\n\n", "// Build a cache of only pending pages.", "pcache", ":=", "make", "(", "map", "[", "pgid", "]", "bool", ")", "\n", "for", "_"...
// reload reads the freelist from a page and filters out pending items.
[ "reload", "reads", "the", "freelist", "from", "a", "page", "and", "filters", "out", "pending", "items", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L215-L239
162,267
boltdb/bolt
freelist.go
reindex
func (f *freelist) reindex() { f.cache = make(map[pgid]bool, len(f.ids)) for _, id := range f.ids { f.cache[id] = true } for _, pendingIDs := range f.pending { for _, pendingID := range pendingIDs { f.cache[pendingID] = true } } }
go
func (f *freelist) reindex() { f.cache = make(map[pgid]bool, len(f.ids)) for _, id := range f.ids { f.cache[id] = true } for _, pendingIDs := range f.pending { for _, pendingID := range pendingIDs { f.cache[pendingID] = true } } }
[ "func", "(", "f", "*", "freelist", ")", "reindex", "(", ")", "{", "f", ".", "cache", "=", "make", "(", "map", "[", "pgid", "]", "bool", ",", "len", "(", "f", ".", "ids", ")", ")", "\n", "for", "_", ",", "id", ":=", "range", "f", ".", "ids",...
// reindex rebuilds the free cache based on available and pending free lists.
[ "reindex", "rebuilds", "the", "free", "cache", "based", "on", "available", "and", "pending", "free", "lists", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/freelist.go#L242-L252
162,268
boltdb/bolt
db.go
Open
func Open(path string, mode os.FileMode, options *Options) (*DB, error) { var db = &DB{opened: true} // Set default options if no options are provided. if options == nil { options = DefaultOptions } db.NoGrowSync = options.NoGrowSync db.MmapFlags = options.MmapFlags // Set default values for later DB operati...
go
func Open(path string, mode os.FileMode, options *Options) (*DB, error) { var db = &DB{opened: true} // Set default options if no options are provided. if options == nil { options = DefaultOptions } db.NoGrowSync = options.NoGrowSync db.MmapFlags = options.MmapFlags // Set default values for later DB operati...
[ "func", "Open", "(", "path", "string", ",", "mode", "os", ".", "FileMode", ",", "options", "*", "Options", ")", "(", "*", "DB", ",", "error", ")", "{", "var", "db", "=", "&", "DB", "{", "opened", ":", "true", "}", "\n\n", "// Set default options if n...
// Open creates and opens a database at the given path. // If the file does not exist then it will be created automatically. // Passing in nil options will cause Bolt to open the database with the default options.
[ "Open", "creates", "and", "opens", "a", "database", "at", "the", "given", "path", ".", "If", "the", "file", "does", "not", "exist", "then", "it", "will", "be", "created", "automatically", ".", "Passing", "in", "nil", "options", "will", "cause", "Bolt", "...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L150-L241
162,269
boltdb/bolt
db.go
mmap
func (db *DB) mmap(minsz int) error { db.mmaplock.Lock() defer db.mmaplock.Unlock() info, err := db.file.Stat() if err != nil { return fmt.Errorf("mmap stat error: %s", err) } else if int(info.Size()) < db.pageSize*2 { return fmt.Errorf("file size too small") } // Ensure the size is at least the minimum si...
go
func (db *DB) mmap(minsz int) error { db.mmaplock.Lock() defer db.mmaplock.Unlock() info, err := db.file.Stat() if err != nil { return fmt.Errorf("mmap stat error: %s", err) } else if int(info.Size()) < db.pageSize*2 { return fmt.Errorf("file size too small") } // Ensure the size is at least the minimum si...
[ "func", "(", "db", "*", "DB", ")", "mmap", "(", "minsz", "int", ")", "error", "{", "db", ".", "mmaplock", ".", "Lock", "(", ")", "\n", "defer", "db", ".", "mmaplock", ".", "Unlock", "(", ")", "\n\n", "info", ",", "err", ":=", "db", ".", "file",...
// mmap opens the underlying memory-mapped file and initializes the meta references. // minsz is the minimum size that the new mmap can be.
[ "mmap", "opens", "the", "underlying", "memory", "-", "mapped", "file", "and", "initializes", "the", "meta", "references", ".", "minsz", "is", "the", "minimum", "size", "that", "the", "new", "mmap", "can", "be", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L245-L295
162,270
boltdb/bolt
db.go
munmap
func (db *DB) munmap() error { if err := munmap(db); err != nil { return fmt.Errorf("unmap error: " + err.Error()) } return nil }
go
func (db *DB) munmap() error { if err := munmap(db); err != nil { return fmt.Errorf("unmap error: " + err.Error()) } return nil }
[ "func", "(", "db", "*", "DB", ")", "munmap", "(", ")", "error", "{", "if", "err", ":=", "munmap", "(", "db", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", "+", "err", ".", "Error", "(", ")", ")", "\n", ...
// munmap unmaps the data file from memory.
[ "munmap", "unmaps", "the", "data", "file", "from", "memory", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L298-L303
162,271
boltdb/bolt
db.go
mmapSize
func (db *DB) mmapSize(size int) (int, error) { // Double the size from 32KB until 1GB. for i := uint(15); i <= 30; i++ { if size <= 1<<i { return 1 << i, nil } } // Verify the requested size is not above the maximum allowed. if size > maxMapSize { return 0, fmt.Errorf("mmap too large") } // If larger...
go
func (db *DB) mmapSize(size int) (int, error) { // Double the size from 32KB until 1GB. for i := uint(15); i <= 30; i++ { if size <= 1<<i { return 1 << i, nil } } // Verify the requested size is not above the maximum allowed. if size > maxMapSize { return 0, fmt.Errorf("mmap too large") } // If larger...
[ "func", "(", "db", "*", "DB", ")", "mmapSize", "(", "size", "int", ")", "(", "int", ",", "error", ")", "{", "// Double the size from 32KB until 1GB.", "for", "i", ":=", "uint", "(", "15", ")", ";", "i", "<=", "30", ";", "i", "++", "{", "if", "size"...
// mmapSize determines the appropriate size for the mmap given the current size // of the database. The minimum size is 32KB and doubles until it reaches 1GB. // Returns an error if the new mmap size is greater than the max allowed.
[ "mmapSize", "determines", "the", "appropriate", "size", "for", "the", "mmap", "given", "the", "current", "size", "of", "the", "database", ".", "The", "minimum", "size", "is", "32KB", "and", "doubles", "until", "it", "reaches", "1GB", ".", "Returns", "an", ...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L308-L340
162,272
boltdb/bolt
db.go
init
func (db *DB) init() error { // Set the page size to the OS page size. db.pageSize = os.Getpagesize() // Create two meta pages on a buffer. buf := make([]byte, db.pageSize*4) for i := 0; i < 2; i++ { p := db.pageInBuffer(buf[:], pgid(i)) p.id = pgid(i) p.flags = metaPageFlag // Initialize the meta page. ...
go
func (db *DB) init() error { // Set the page size to the OS page size. db.pageSize = os.Getpagesize() // Create two meta pages on a buffer. buf := make([]byte, db.pageSize*4) for i := 0; i < 2; i++ { p := db.pageInBuffer(buf[:], pgid(i)) p.id = pgid(i) p.flags = metaPageFlag // Initialize the meta page. ...
[ "func", "(", "db", "*", "DB", ")", "init", "(", ")", "error", "{", "// Set the page size to the OS page size.", "db", ".", "pageSize", "=", "os", ".", "Getpagesize", "(", ")", "\n\n", "// Create two meta pages on a buffer.", "buf", ":=", "make", "(", "[", "]",...
// init creates a new database file and initializes its meta pages.
[ "init", "creates", "a", "new", "database", "file", "and", "initializes", "its", "meta", "pages", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L343-L387
162,273
boltdb/bolt
db.go
removeTx
func (db *DB) removeTx(tx *Tx) { // Release the read lock on the mmap. db.mmaplock.RUnlock() // Use the meta lock to restrict access to the DB object. db.metalock.Lock() // Remove the transaction. for i, t := range db.txs { if t == tx { last := len(db.txs) - 1 db.txs[i] = db.txs[last] db.txs[last] = ...
go
func (db *DB) removeTx(tx *Tx) { // Release the read lock on the mmap. db.mmaplock.RUnlock() // Use the meta lock to restrict access to the DB object. db.metalock.Lock() // Remove the transaction. for i, t := range db.txs { if t == tx { last := len(db.txs) - 1 db.txs[i] = db.txs[last] db.txs[last] = ...
[ "func", "(", "db", "*", "DB", ")", "removeTx", "(", "tx", "*", "Tx", ")", "{", "// Release the read lock on the mmap.", "db", ".", "mmaplock", ".", "RUnlock", "(", ")", "\n\n", "// Use the meta lock to restrict access to the DB object.", "db", ".", "metalock", "."...
// removeTx removes a transaction from the database.
[ "removeTx", "removes", "a", "transaction", "from", "the", "database", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L545-L572
162,274
boltdb/bolt
db.go
run
func (b *batch) run() { b.db.batchMu.Lock() b.timer.Stop() // Make sure no new work is added to this batch, but don't break // other batches. if b.db.batch == b { b.db.batch = nil } b.db.batchMu.Unlock() retry: for len(b.calls) > 0 { var failIdx = -1 err := b.db.Update(func(tx *Tx) error { for i, c :=...
go
func (b *batch) run() { b.db.batchMu.Lock() b.timer.Stop() // Make sure no new work is added to this batch, but don't break // other batches. if b.db.batch == b { b.db.batch = nil } b.db.batchMu.Unlock() retry: for len(b.calls) > 0 { var failIdx = -1 err := b.db.Update(func(tx *Tx) error { for i, c :=...
[ "func", "(", "b", "*", "batch", ")", "run", "(", ")", "{", "b", ".", "db", ".", "batchMu", ".", "Lock", "(", ")", "\n", "b", ".", "timer", ".", "Stop", "(", ")", "\n", "// Make sure no new work is added to this batch, but don't break", "// other batches.", ...
// run performs the transactions in the batch and communicates results // back to DB.Batch.
[ "run", "performs", "the", "transactions", "in", "the", "batch", "and", "communicates", "results", "back", "to", "DB", ".", "Batch", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L704-L744
162,275
boltdb/bolt
db.go
Stats
func (db *DB) Stats() Stats { db.statlock.RLock() defer db.statlock.RUnlock() return db.stats }
go
func (db *DB) Stats() Stats { db.statlock.RLock() defer db.statlock.RUnlock() return db.stats }
[ "func", "(", "db", "*", "DB", ")", "Stats", "(", ")", "Stats", "{", "db", ".", "statlock", ".", "RLock", "(", ")", "\n", "defer", "db", ".", "statlock", ".", "RUnlock", "(", ")", "\n", "return", "db", ".", "stats", "\n", "}" ]
// Stats retrieves ongoing performance stats for the database. // This is only updated when a transaction closes.
[ "Stats", "retrieves", "ongoing", "performance", "stats", "for", "the", "database", ".", "This", "is", "only", "updated", "when", "a", "transaction", "closes", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L779-L783
162,276
boltdb/bolt
db.go
Info
func (db *DB) Info() *Info { return &Info{uintptr(unsafe.Pointer(&db.data[0])), db.pageSize} }
go
func (db *DB) Info() *Info { return &Info{uintptr(unsafe.Pointer(&db.data[0])), db.pageSize} }
[ "func", "(", "db", "*", "DB", ")", "Info", "(", ")", "*", "Info", "{", "return", "&", "Info", "{", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "db", ".", "data", "[", "0", "]", ")", ")", ",", "db", ".", "pageSize", "}", "\n", "}" ]
// This is for internal access to the raw data bytes from the C cursor, use // carefully, or not at all.
[ "This", "is", "for", "internal", "access", "to", "the", "raw", "data", "bytes", "from", "the", "C", "cursor", "use", "carefully", "or", "not", "at", "all", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L787-L789
162,277
boltdb/bolt
db.go
page
func (db *DB) page(id pgid) *page { pos := id * pgid(db.pageSize) return (*page)(unsafe.Pointer(&db.data[pos])) }
go
func (db *DB) page(id pgid) *page { pos := id * pgid(db.pageSize) return (*page)(unsafe.Pointer(&db.data[pos])) }
[ "func", "(", "db", "*", "DB", ")", "page", "(", "id", "pgid", ")", "*", "page", "{", "pos", ":=", "id", "*", "pgid", "(", "db", ".", "pageSize", ")", "\n", "return", "(", "*", "page", ")", "(", "unsafe", ".", "Pointer", "(", "&", "db", ".", ...
// page retrieves a page reference from the mmap based on the current page size.
[ "page", "retrieves", "a", "page", "reference", "from", "the", "mmap", "based", "on", "the", "current", "page", "size", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L792-L795
162,278
boltdb/bolt
db.go
pageInBuffer
func (db *DB) pageInBuffer(b []byte, id pgid) *page { return (*page)(unsafe.Pointer(&b[id*pgid(db.pageSize)])) }
go
func (db *DB) pageInBuffer(b []byte, id pgid) *page { return (*page)(unsafe.Pointer(&b[id*pgid(db.pageSize)])) }
[ "func", "(", "db", "*", "DB", ")", "pageInBuffer", "(", "b", "[", "]", "byte", ",", "id", "pgid", ")", "*", "page", "{", "return", "(", "*", "page", ")", "(", "unsafe", ".", "Pointer", "(", "&", "b", "[", "id", "*", "pgid", "(", "db", ".", ...
// pageInBuffer retrieves a page reference from a given byte array based on the current page size.
[ "pageInBuffer", "retrieves", "a", "page", "reference", "from", "a", "given", "byte", "array", "based", "on", "the", "current", "page", "size", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L798-L800
162,279
boltdb/bolt
db.go
meta
func (db *DB) meta() *meta { // We have to return the meta with the highest txid which doesn't fail // validation. Otherwise, we can cause errors when in fact the database is // in a consistent state. metaA is the one with the higher txid. metaA := db.meta0 metaB := db.meta1 if db.meta1.txid > db.meta0.txid { m...
go
func (db *DB) meta() *meta { // We have to return the meta with the highest txid which doesn't fail // validation. Otherwise, we can cause errors when in fact the database is // in a consistent state. metaA is the one with the higher txid. metaA := db.meta0 metaB := db.meta1 if db.meta1.txid > db.meta0.txid { m...
[ "func", "(", "db", "*", "DB", ")", "meta", "(", ")", "*", "meta", "{", "// We have to return the meta with the highest txid which doesn't fail", "// validation. Otherwise, we can cause errors when in fact the database is", "// in a consistent state. metaA is the one with the higher txid....
// meta retrieves the current meta page reference.
[ "meta", "retrieves", "the", "current", "meta", "page", "reference", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L803-L824
162,280
boltdb/bolt
db.go
grow
func (db *DB) grow(sz int) error { // Ignore if the new size is less than available file size. if sz <= db.filesz { return nil } // If the data is smaller than the alloc size then only allocate what's needed. // Once it goes over the allocation size then allocate in chunks. if db.datasz < db.AllocSize { sz =...
go
func (db *DB) grow(sz int) error { // Ignore if the new size is less than available file size. if sz <= db.filesz { return nil } // If the data is smaller than the alloc size then only allocate what's needed. // Once it goes over the allocation size then allocate in chunks. if db.datasz < db.AllocSize { sz =...
[ "func", "(", "db", "*", "DB", ")", "grow", "(", "sz", "int", ")", "error", "{", "// Ignore if the new size is less than available file size.", "if", "sz", "<=", "db", ".", "filesz", "{", "return", "nil", "\n", "}", "\n\n", "// If the data is smaller than the alloc...
// grow grows the size of the database to the given sz.
[ "grow", "grows", "the", "size", "of", "the", "database", "to", "the", "given", "sz", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L859-L888
162,281
boltdb/bolt
db.go
Sub
func (s *Stats) Sub(other *Stats) Stats { if other == nil { return *s } var diff Stats diff.FreePageN = s.FreePageN diff.PendingPageN = s.PendingPageN diff.FreeAlloc = s.FreeAlloc diff.FreelistInuse = s.FreelistInuse diff.TxN = s.TxN - other.TxN diff.TxStats = s.TxStats.Sub(&other.TxStats) return diff }
go
func (s *Stats) Sub(other *Stats) Stats { if other == nil { return *s } var diff Stats diff.FreePageN = s.FreePageN diff.PendingPageN = s.PendingPageN diff.FreeAlloc = s.FreeAlloc diff.FreelistInuse = s.FreelistInuse diff.TxN = s.TxN - other.TxN diff.TxStats = s.TxStats.Sub(&other.TxStats) return diff }
[ "func", "(", "s", "*", "Stats", ")", "Sub", "(", "other", "*", "Stats", ")", "Stats", "{", "if", "other", "==", "nil", "{", "return", "*", "s", "\n", "}", "\n", "var", "diff", "Stats", "\n", "diff", ".", "FreePageN", "=", "s", ".", "FreePageN", ...
// Sub calculates and returns the difference between two sets of database stats. // This is useful when obtaining stats at two different points and time and // you need the performance counters that occurred within that time span.
[ "Sub", "calculates", "and", "returns", "the", "difference", "between", "two", "sets", "of", "database", "stats", ".", "This", "is", "useful", "when", "obtaining", "stats", "at", "two", "different", "points", "and", "time", "and", "you", "need", "the", "perfo...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L947-L959
162,282
boltdb/bolt
db.go
validate
func (m *meta) validate() error { if m.magic != magic { return ErrInvalid } else if m.version != version { return ErrVersionMismatch } else if m.checksum != 0 && m.checksum != m.sum64() { return ErrChecksum } return nil }
go
func (m *meta) validate() error { if m.magic != magic { return ErrInvalid } else if m.version != version { return ErrVersionMismatch } else if m.checksum != 0 && m.checksum != m.sum64() { return ErrChecksum } return nil }
[ "func", "(", "m", "*", "meta", ")", "validate", "(", ")", "error", "{", "if", "m", ".", "magic", "!=", "magic", "{", "return", "ErrInvalid", "\n", "}", "else", "if", "m", ".", "version", "!=", "version", "{", "return", "ErrVersionMismatch", "\n", "}"...
// validate checks the marker bytes and version of the meta page to ensure it matches this binary.
[ "validate", "checks", "the", "marker", "bytes", "and", "version", "of", "the", "meta", "page", "to", "ensure", "it", "matches", "this", "binary", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L983-L992
162,283
boltdb/bolt
db.go
write
func (m *meta) write(p *page) { if m.root.root >= m.pgid { panic(fmt.Sprintf("root bucket pgid (%d) above high water mark (%d)", m.root.root, m.pgid)) } else if m.freelist >= m.pgid { panic(fmt.Sprintf("freelist pgid (%d) above high water mark (%d)", m.freelist, m.pgid)) } // Page id is either going to be 0 or...
go
func (m *meta) write(p *page) { if m.root.root >= m.pgid { panic(fmt.Sprintf("root bucket pgid (%d) above high water mark (%d)", m.root.root, m.pgid)) } else if m.freelist >= m.pgid { panic(fmt.Sprintf("freelist pgid (%d) above high water mark (%d)", m.freelist, m.pgid)) } // Page id is either going to be 0 or...
[ "func", "(", "m", "*", "meta", ")", "write", "(", "p", "*", "page", ")", "{", "if", "m", ".", "root", ".", "root", ">=", "m", ".", "pgid", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "m", ".", "root", ".", "root", ",", ...
// write writes the meta onto a page.
[ "write", "writes", "the", "meta", "onto", "a", "page", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L1000-L1015
162,284
boltdb/bolt
db.go
sum64
func (m *meta) sum64() uint64 { var h = fnv.New64a() _, _ = h.Write((*[unsafe.Offsetof(meta{}.checksum)]byte)(unsafe.Pointer(m))[:]) return h.Sum64() }
go
func (m *meta) sum64() uint64 { var h = fnv.New64a() _, _ = h.Write((*[unsafe.Offsetof(meta{}.checksum)]byte)(unsafe.Pointer(m))[:]) return h.Sum64() }
[ "func", "(", "m", "*", "meta", ")", "sum64", "(", ")", "uint64", "{", "var", "h", "=", "fnv", ".", "New64a", "(", ")", "\n", "_", ",", "_", "=", "h", ".", "Write", "(", "(", "*", "[", "unsafe", ".", "Offsetof", "(", "meta", "{", "}", ".", ...
// generates the checksum for the meta.
[ "generates", "the", "checksum", "for", "the", "meta", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/db.go#L1018-L1022
162,285
boltdb/bolt
tx.go
init
func (tx *Tx) init(db *DB) { tx.db = db tx.pages = nil // Copy the meta page since it can be changed by the writer. tx.meta = &meta{} db.meta().copy(tx.meta) // Copy over the root bucket. tx.root = newBucket(tx) tx.root.bucket = &bucket{} *tx.root.bucket = tx.meta.root // Increment the transaction id and a...
go
func (tx *Tx) init(db *DB) { tx.db = db tx.pages = nil // Copy the meta page since it can be changed by the writer. tx.meta = &meta{} db.meta().copy(tx.meta) // Copy over the root bucket. tx.root = newBucket(tx) tx.root.bucket = &bucket{} *tx.root.bucket = tx.meta.root // Increment the transaction id and a...
[ "func", "(", "tx", "*", "Tx", ")", "init", "(", "db", "*", "DB", ")", "{", "tx", ".", "db", "=", "db", "\n", "tx", ".", "pages", "=", "nil", "\n\n", "// Copy the meta page since it can be changed by the writer.", "tx", ".", "meta", "=", "&", "meta", "{...
// init initializes the transaction.
[ "init", "initializes", "the", "transaction", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L44-L62
162,286
boltdb/bolt
tx.go
Size
func (tx *Tx) Size() int64 { return int64(tx.meta.pgid) * int64(tx.db.pageSize) }
go
func (tx *Tx) Size() int64 { return int64(tx.meta.pgid) * int64(tx.db.pageSize) }
[ "func", "(", "tx", "*", "Tx", ")", "Size", "(", ")", "int64", "{", "return", "int64", "(", "tx", ".", "meta", ".", "pgid", ")", "*", "int64", "(", "tx", ".", "db", ".", "pageSize", ")", "\n", "}" ]
// Size returns current database size in bytes as seen by this transaction.
[ "Size", "returns", "current", "database", "size", "in", "bytes", "as", "seen", "by", "this", "transaction", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L75-L77
162,287
boltdb/bolt
tx.go
Bucket
func (tx *Tx) Bucket(name []byte) *Bucket { return tx.root.Bucket(name) }
go
func (tx *Tx) Bucket(name []byte) *Bucket { return tx.root.Bucket(name) }
[ "func", "(", "tx", "*", "Tx", ")", "Bucket", "(", "name", "[", "]", "byte", ")", "*", "Bucket", "{", "return", "tx", ".", "root", ".", "Bucket", "(", "name", ")", "\n", "}" ]
// Bucket retrieves a bucket by name. // Returns nil if the bucket does not exist. // The bucket instance is only valid for the lifetime of the transaction.
[ "Bucket", "retrieves", "a", "bucket", "by", "name", ".", "Returns", "nil", "if", "the", "bucket", "does", "not", "exist", ".", "The", "bucket", "instance", "is", "only", "valid", "for", "the", "lifetime", "of", "the", "transaction", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L100-L102
162,288
boltdb/bolt
tx.go
CreateBucket
func (tx *Tx) CreateBucket(name []byte) (*Bucket, error) { return tx.root.CreateBucket(name) }
go
func (tx *Tx) CreateBucket(name []byte) (*Bucket, error) { return tx.root.CreateBucket(name) }
[ "func", "(", "tx", "*", "Tx", ")", "CreateBucket", "(", "name", "[", "]", "byte", ")", "(", "*", "Bucket", ",", "error", ")", "{", "return", "tx", ".", "root", ".", "CreateBucket", "(", "name", ")", "\n", "}" ]
// CreateBucket creates a new bucket. // Returns an error if the bucket already exists, if the bucket name is blank, or if the bucket name is too long. // The bucket instance is only valid for the lifetime of the transaction.
[ "CreateBucket", "creates", "a", "new", "bucket", ".", "Returns", "an", "error", "if", "the", "bucket", "already", "exists", "if", "the", "bucket", "name", "is", "blank", "or", "if", "the", "bucket", "name", "is", "too", "long", ".", "The", "bucket", "ins...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L107-L109
162,289
boltdb/bolt
tx.go
CreateBucketIfNotExists
func (tx *Tx) CreateBucketIfNotExists(name []byte) (*Bucket, error) { return tx.root.CreateBucketIfNotExists(name) }
go
func (tx *Tx) CreateBucketIfNotExists(name []byte) (*Bucket, error) { return tx.root.CreateBucketIfNotExists(name) }
[ "func", "(", "tx", "*", "Tx", ")", "CreateBucketIfNotExists", "(", "name", "[", "]", "byte", ")", "(", "*", "Bucket", ",", "error", ")", "{", "return", "tx", ".", "root", ".", "CreateBucketIfNotExists", "(", "name", ")", "\n", "}" ]
// CreateBucketIfNotExists creates a new bucket if it doesn't already exist. // Returns an error if the bucket name is blank, or if the bucket name is too long. // The bucket instance is only valid for the lifetime of the transaction.
[ "CreateBucketIfNotExists", "creates", "a", "new", "bucket", "if", "it", "doesn", "t", "already", "exist", ".", "Returns", "an", "error", "if", "the", "bucket", "name", "is", "blank", "or", "if", "the", "bucket", "name", "is", "too", "long", ".", "The", "...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L114-L116
162,290
boltdb/bolt
tx.go
DeleteBucket
func (tx *Tx) DeleteBucket(name []byte) error { return tx.root.DeleteBucket(name) }
go
func (tx *Tx) DeleteBucket(name []byte) error { return tx.root.DeleteBucket(name) }
[ "func", "(", "tx", "*", "Tx", ")", "DeleteBucket", "(", "name", "[", "]", "byte", ")", "error", "{", "return", "tx", ".", "root", ".", "DeleteBucket", "(", "name", ")", "\n", "}" ]
// DeleteBucket deletes a bucket. // Returns an error if the bucket cannot be found or if the key represents a non-bucket value.
[ "DeleteBucket", "deletes", "a", "bucket", ".", "Returns", "an", "error", "if", "the", "bucket", "cannot", "be", "found", "or", "if", "the", "key", "represents", "a", "non", "-", "bucket", "value", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L120-L122
162,291
boltdb/bolt
tx.go
ForEach
func (tx *Tx) ForEach(fn func(name []byte, b *Bucket) error) error { return tx.root.ForEach(func(k, v []byte) error { if err := fn(k, tx.root.Bucket(k)); err != nil { return err } return nil }) }
go
func (tx *Tx) ForEach(fn func(name []byte, b *Bucket) error) error { return tx.root.ForEach(func(k, v []byte) error { if err := fn(k, tx.root.Bucket(k)); err != nil { return err } return nil }) }
[ "func", "(", "tx", "*", "Tx", ")", "ForEach", "(", "fn", "func", "(", "name", "[", "]", "byte", ",", "b", "*", "Bucket", ")", "error", ")", "error", "{", "return", "tx", ".", "root", ".", "ForEach", "(", "func", "(", "k", ",", "v", "[", "]", ...
// ForEach executes a function for each bucket in the root. // If the provided function returns an error then the iteration is stopped and // the error is returned to the caller.
[ "ForEach", "executes", "a", "function", "for", "each", "bucket", "in", "the", "root", ".", "If", "the", "provided", "function", "returns", "an", "error", "then", "the", "iteration", "is", "stopped", "and", "the", "error", "is", "returned", "to", "the", "ca...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L127-L134
162,292
boltdb/bolt
tx.go
OnCommit
func (tx *Tx) OnCommit(fn func()) { tx.commitHandlers = append(tx.commitHandlers, fn) }
go
func (tx *Tx) OnCommit(fn func()) { tx.commitHandlers = append(tx.commitHandlers, fn) }
[ "func", "(", "tx", "*", "Tx", ")", "OnCommit", "(", "fn", "func", "(", ")", ")", "{", "tx", ".", "commitHandlers", "=", "append", "(", "tx", ".", "commitHandlers", ",", "fn", ")", "\n", "}" ]
// OnCommit adds a handler function to be executed after the transaction successfully commits.
[ "OnCommit", "adds", "a", "handler", "function", "to", "be", "executed", "after", "the", "transaction", "successfully", "commits", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L137-L139
162,293
boltdb/bolt
tx.go
Commit
func (tx *Tx) Commit() error { _assert(!tx.managed, "managed tx commit not allowed") if tx.db == nil { return ErrTxClosed } else if !tx.writable { return ErrTxNotWritable } // TODO(benbjohnson): Use vectorized I/O to write out dirty pages. // Rebalance nodes which have had deletions. var startTime = time.N...
go
func (tx *Tx) Commit() error { _assert(!tx.managed, "managed tx commit not allowed") if tx.db == nil { return ErrTxClosed } else if !tx.writable { return ErrTxNotWritable } // TODO(benbjohnson): Use vectorized I/O to write out dirty pages. // Rebalance nodes which have had deletions. var startTime = time.N...
[ "func", "(", "tx", "*", "Tx", ")", "Commit", "(", ")", "error", "{", "_assert", "(", "!", "tx", ".", "managed", ",", "\"", "\"", ")", "\n", "if", "tx", ".", "db", "==", "nil", "{", "return", "ErrTxClosed", "\n", "}", "else", "if", "!", "tx", ...
// Commit writes all changes to disk and updates the meta page. // Returns an error if a disk write error occurs, or if Commit is // called on a read-only transaction.
[ "Commit", "writes", "all", "changes", "to", "disk", "and", "updates", "the", "meta", "page", ".", "Returns", "an", "error", "if", "a", "disk", "write", "error", "occurs", "or", "if", "Commit", "is", "called", "on", "a", "read", "-", "only", "transaction"...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L144-L236
162,294
boltdb/bolt
tx.go
Rollback
func (tx *Tx) Rollback() error { _assert(!tx.managed, "managed tx rollback not allowed") if tx.db == nil { return ErrTxClosed } tx.rollback() return nil }
go
func (tx *Tx) Rollback() error { _assert(!tx.managed, "managed tx rollback not allowed") if tx.db == nil { return ErrTxClosed } tx.rollback() return nil }
[ "func", "(", "tx", "*", "Tx", ")", "Rollback", "(", ")", "error", "{", "_assert", "(", "!", "tx", ".", "managed", ",", "\"", "\"", ")", "\n", "if", "tx", ".", "db", "==", "nil", "{", "return", "ErrTxClosed", "\n", "}", "\n", "tx", ".", "rollbac...
// Rollback closes the transaction and ignores all previous updates. Read-only // transactions must be rolled back and not committed.
[ "Rollback", "closes", "the", "transaction", "and", "ignores", "all", "previous", "updates", ".", "Read", "-", "only", "transactions", "must", "be", "rolled", "back", "and", "not", "committed", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L240-L247
162,295
boltdb/bolt
tx.go
CopyFile
func (tx *Tx) CopyFile(path string, mode os.FileMode) error { f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode) if err != nil { return err } err = tx.Copy(f) if err != nil { _ = f.Close() return err } return f.Close() }
go
func (tx *Tx) CopyFile(path string, mode os.FileMode) error { f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode) if err != nil { return err } err = tx.Copy(f) if err != nil { _ = f.Close() return err } return f.Close() }
[ "func", "(", "tx", "*", "Tx", ")", "CopyFile", "(", "path", "string", ",", "mode", "os", ".", "FileMode", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "OpenFile", "(", "path", ",", "os", ".", "O_RDWR", "|", "os", ".", "O_CREATE", "|", "...
// CopyFile copies the entire database to file at the given path. // A reader transaction is maintained during the copy so it is safe to continue // using the database while a copy is in progress.
[ "CopyFile", "copies", "the", "entire", "database", "to", "file", "at", "the", "given", "path", ".", "A", "reader", "transaction", "is", "maintained", "during", "the", "copy", "so", "it", "is", "safe", "to", "continue", "using", "the", "database", "while", ...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L355-L367
162,296
boltdb/bolt
tx.go
Check
func (tx *Tx) Check() <-chan error { ch := make(chan error) go tx.check(ch) return ch }
go
func (tx *Tx) Check() <-chan error { ch := make(chan error) go tx.check(ch) return ch }
[ "func", "(", "tx", "*", "Tx", ")", "Check", "(", ")", "<-", "chan", "error", "{", "ch", ":=", "make", "(", "chan", "error", ")", "\n", "go", "tx", ".", "check", "(", "ch", ")", "\n", "return", "ch", "\n", "}" ]
// Check performs several consistency checks on the database for this transaction. // An error is returned if any inconsistency is found. // // It can be safely run concurrently on a writable transaction. However, this // incurs a high cost for large databases and databases with a lot of subbuckets // because of cachin...
[ "Check", "performs", "several", "consistency", "checks", "on", "the", "database", "for", "this", "transaction", ".", "An", "error", "is", "returned", "if", "any", "inconsistency", "is", "found", ".", "It", "can", "be", "safely", "run", "concurrently", "on", ...
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L377-L381
162,297
boltdb/bolt
tx.go
write
func (tx *Tx) write() error { // Sort pages by id. pages := make(pages, 0, len(tx.pages)) for _, p := range tx.pages { pages = append(pages, p) } // Clear out page cache early. tx.pages = make(map[pgid]*page) sort.Sort(pages) // Write pages to disk in order. for _, p := range pages { size := (int(p.overfl...
go
func (tx *Tx) write() error { // Sort pages by id. pages := make(pages, 0, len(tx.pages)) for _, p := range tx.pages { pages = append(pages, p) } // Clear out page cache early. tx.pages = make(map[pgid]*page) sort.Sort(pages) // Write pages to disk in order. for _, p := range pages { size := (int(p.overfl...
[ "func", "(", "tx", "*", "Tx", ")", "write", "(", ")", "error", "{", "// Sort pages by id.", "pages", ":=", "make", "(", "pages", ",", "0", ",", "len", "(", "tx", ".", "pages", ")", ")", "\n", "for", "_", ",", "p", ":=", "range", "tx", ".", "pag...
// write writes any dirty pages to disk.
[ "write", "writes", "any", "dirty", "pages", "to", "disk", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L474-L544
162,298
boltdb/bolt
tx.go
writeMeta
func (tx *Tx) writeMeta() error { // Create a temporary buffer for the meta page. buf := make([]byte, tx.db.pageSize) p := tx.db.pageInBuffer(buf, 0) tx.meta.write(p) // Write the meta page to file. if _, err := tx.db.ops.writeAt(buf, int64(p.id)*int64(tx.db.pageSize)); err != nil { return err } if !tx.db.No...
go
func (tx *Tx) writeMeta() error { // Create a temporary buffer for the meta page. buf := make([]byte, tx.db.pageSize) p := tx.db.pageInBuffer(buf, 0) tx.meta.write(p) // Write the meta page to file. if _, err := tx.db.ops.writeAt(buf, int64(p.id)*int64(tx.db.pageSize)); err != nil { return err } if !tx.db.No...
[ "func", "(", "tx", "*", "Tx", ")", "writeMeta", "(", ")", "error", "{", "// Create a temporary buffer for the meta page.", "buf", ":=", "make", "(", "[", "]", "byte", ",", "tx", ".", "db", ".", "pageSize", ")", "\n", "p", ":=", "tx", ".", "db", ".", ...
// writeMeta writes the meta to the disk.
[ "writeMeta", "writes", "the", "meta", "to", "the", "disk", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L547-L567
162,299
boltdb/bolt
tx.go
page
func (tx *Tx) page(id pgid) *page { // Check the dirty pages first. if tx.pages != nil { if p, ok := tx.pages[id]; ok { return p } } // Otherwise return directly from the mmap. return tx.db.page(id) }
go
func (tx *Tx) page(id pgid) *page { // Check the dirty pages first. if tx.pages != nil { if p, ok := tx.pages[id]; ok { return p } } // Otherwise return directly from the mmap. return tx.db.page(id) }
[ "func", "(", "tx", "*", "Tx", ")", "page", "(", "id", "pgid", ")", "*", "page", "{", "// Check the dirty pages first.", "if", "tx", ".", "pages", "!=", "nil", "{", "if", "p", ",", "ok", ":=", "tx", ".", "pages", "[", "id", "]", ";", "ok", "{", ...
// page returns a reference to the page with a given id. // If page has been written to then a temporary buffered page is returned.
[ "page", "returns", "a", "reference", "to", "the", "page", "with", "a", "given", "id", ".", "If", "page", "has", "been", "written", "to", "then", "a", "temporary", "buffered", "page", "is", "returned", "." ]
fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5
https://github.com/boltdb/bolt/blob/fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5/tx.go#L571-L581