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
partition
stringclasses
1 value
cloudfoundry/bosh-cli
registry/mocks/mocks.go
NewMockServerManager
func NewMockServerManager(ctrl *gomock.Controller) *MockServerManager { mock := &MockServerManager{ctrl: ctrl} mock.recorder = &MockServerManagerMockRecorder{mock} return mock }
go
func NewMockServerManager(ctrl *gomock.Controller) *MockServerManager { mock := &MockServerManager{ctrl: ctrl} mock.recorder = &MockServerManagerMockRecorder{mock} return mock }
[ "func", "NewMockServerManager", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockServerManager", "{", "mock", ":=", "&", "MockServerManager", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockServerManagerMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockServerManager creates a new mock instance
[ "NewMockServerManager", "creates", "a", "new", "mock", "instance" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/registry/mocks/mocks.go#L60-L64
train
cloudfoundry/bosh-cli
registry/mocks/mocks.go
Start
func (mr *MockServerManagerMockRecorder) Start(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockServerManager)(nil).Start), arg0, arg1, arg2, arg3) }
go
func (mr *MockServerManagerMockRecorder) Start(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockServerManager)(nil).Start), arg0, arg1, arg2, arg3) }
[ "func", "(", "mr", "*", "MockServerManagerMockRecorder", ")", "Start", "(", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockServerManager", ")", "(", "nil", ")", ".", "Start", ")", ",", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ")", "\n", "}" ]
// Start indicates an expected call of Start
[ "Start", "indicates", "an", "expected", "call", "of", "Start" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/registry/mocks/mocks.go#L80-L82
train
cloudfoundry/bosh-cli
release/release.go
CleanUp
func (r *release) CleanUp() error { var anyErr error for _, job := range r.Jobs() { err := job.CleanUp() if err != nil { anyErr = err } } for _, pkg := range r.Packages() { err := pkg.CleanUp() if err != nil { anyErr = err } } if r.fs != nil && len(r.extractedPath) > 0 { err := r.fs.RemoveAll(r.extractedPath) if err != nil { anyErr = err } } return anyErr }
go
func (r *release) CleanUp() error { var anyErr error for _, job := range r.Jobs() { err := job.CleanUp() if err != nil { anyErr = err } } for _, pkg := range r.Packages() { err := pkg.CleanUp() if err != nil { anyErr = err } } if r.fs != nil && len(r.extractedPath) > 0 { err := r.fs.RemoveAll(r.extractedPath) if err != nil { anyErr = err } } return anyErr }
[ "func", "(", "r", "*", "release", ")", "CleanUp", "(", ")", "error", "{", "var", "anyErr", "error", "\n\n", "for", "_", ",", "job", ":=", "range", "r", ".", "Jobs", "(", ")", "{", "err", ":=", "job", ".", "CleanUp", "(", ")", "\n", "if", "err", "!=", "nil", "{", "anyErr", "=", "err", "\n", "}", "\n", "}", "\n\n", "for", "_", ",", "pkg", ":=", "range", "r", ".", "Packages", "(", ")", "{", "err", ":=", "pkg", ".", "CleanUp", "(", ")", "\n", "if", "err", "!=", "nil", "{", "anyErr", "=", "err", "\n", "}", "\n", "}", "\n\n", "if", "r", ".", "fs", "!=", "nil", "&&", "len", "(", "r", ".", "extractedPath", ")", ">", "0", "{", "err", ":=", "r", ".", "fs", ".", "RemoveAll", "(", "r", ".", "extractedPath", ")", "\n", "if", "err", "!=", "nil", "{", "anyErr", "=", "err", "\n", "}", "\n", "}", "\n\n", "return", "anyErr", "\n", "}" ]
// CleanUp removes the extracted release.
[ "CleanUp", "removes", "the", "extracted", "release", "." ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/release/release.go#L245-L270
train
cloudfoundry/bosh-cli
installation/job_renderer.go
renderJobTemplates
func (b *jobRenderer) renderJobTemplates( releaseJobs []bireljob.Job, releaseJobProperties map[string]*biproperty.Map, jobProperties biproperty.Map, globalProperties biproperty.Map, deploymentName string, stage biui.Stage, ) ([]RenderedJobRef, error) { renderedJobRefs := make([]RenderedJobRef, 0, len(releaseJobs)) err := stage.Perform("Rendering job templates", func() error { renderedJobList, err := b.jobListRenderer.Render(releaseJobs, releaseJobProperties, jobProperties, globalProperties, deploymentName, "") if err != nil { return err } defer renderedJobList.DeleteSilently() for _, renderedJob := range renderedJobList.All() { renderedJobRef, err := b.compressAndUpload(renderedJob) if err != nil { return err } renderedJobRefs = append(renderedJobRefs, renderedJobRef) } return nil }) return renderedJobRefs, err }
go
func (b *jobRenderer) renderJobTemplates( releaseJobs []bireljob.Job, releaseJobProperties map[string]*biproperty.Map, jobProperties biproperty.Map, globalProperties biproperty.Map, deploymentName string, stage biui.Stage, ) ([]RenderedJobRef, error) { renderedJobRefs := make([]RenderedJobRef, 0, len(releaseJobs)) err := stage.Perform("Rendering job templates", func() error { renderedJobList, err := b.jobListRenderer.Render(releaseJobs, releaseJobProperties, jobProperties, globalProperties, deploymentName, "") if err != nil { return err } defer renderedJobList.DeleteSilently() for _, renderedJob := range renderedJobList.All() { renderedJobRef, err := b.compressAndUpload(renderedJob) if err != nil { return err } renderedJobRefs = append(renderedJobRefs, renderedJobRef) } return nil }) return renderedJobRefs, err }
[ "func", "(", "b", "*", "jobRenderer", ")", "renderJobTemplates", "(", "releaseJobs", "[", "]", "bireljob", ".", "Job", ",", "releaseJobProperties", "map", "[", "string", "]", "*", "biproperty", ".", "Map", ",", "jobProperties", "biproperty", ".", "Map", ",", "globalProperties", "biproperty", ".", "Map", ",", "deploymentName", "string", ",", "stage", "biui", ".", "Stage", ",", ")", "(", "[", "]", "RenderedJobRef", ",", "error", ")", "{", "renderedJobRefs", ":=", "make", "(", "[", "]", "RenderedJobRef", ",", "0", ",", "len", "(", "releaseJobs", ")", ")", "\n", "err", ":=", "stage", ".", "Perform", "(", "\"", "\"", ",", "func", "(", ")", "error", "{", "renderedJobList", ",", "err", ":=", "b", ".", "jobListRenderer", ".", "Render", "(", "releaseJobs", ",", "releaseJobProperties", ",", "jobProperties", ",", "globalProperties", ",", "deploymentName", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "renderedJobList", ".", "DeleteSilently", "(", ")", "\n\n", "for", "_", ",", "renderedJob", ":=", "range", "renderedJobList", ".", "All", "(", ")", "{", "renderedJobRef", ",", "err", ":=", "b", ".", "compressAndUpload", "(", "renderedJob", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "renderedJobRefs", "=", "append", "(", "renderedJobRefs", ",", "renderedJobRef", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "renderedJobRefs", ",", "err", "\n", "}" ]
// renderJobTemplates renders all the release job templates for multiple release jobs specified // by a deployment job and randomly uploads them to blobstore
[ "renderJobTemplates", "renders", "all", "the", "release", "job", "templates", "for", "multiple", "release", "jobs", "specified", "by", "a", "deployment", "job", "and", "randomly", "uploads", "them", "to", "blobstore" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/job_renderer.go#L72-L101
train
cloudfoundry/bosh-cli
state/job/dependency_compiler.go
Compile
func (c *dependencyCompiler) Compile(jobs []bireljob.Job, stage biui.Stage) ([]CompiledPackageRef, error) { compileOrderReleasePackages, err := c.resolveJobCompilationDependencies(jobs) if err != nil { return nil, bosherr.WrapError(err, "Resolving job package dependencies") } compiledPackageRefs, err := c.compilePackages(compileOrderReleasePackages, stage) if err != nil { return nil, bosherr.WrapError(err, "Compiling job package dependencies") } return compiledPackageRefs, nil }
go
func (c *dependencyCompiler) Compile(jobs []bireljob.Job, stage biui.Stage) ([]CompiledPackageRef, error) { compileOrderReleasePackages, err := c.resolveJobCompilationDependencies(jobs) if err != nil { return nil, bosherr.WrapError(err, "Resolving job package dependencies") } compiledPackageRefs, err := c.compilePackages(compileOrderReleasePackages, stage) if err != nil { return nil, bosherr.WrapError(err, "Compiling job package dependencies") } return compiledPackageRefs, nil }
[ "func", "(", "c", "*", "dependencyCompiler", ")", "Compile", "(", "jobs", "[", "]", "bireljob", ".", "Job", ",", "stage", "biui", ".", "Stage", ")", "(", "[", "]", "CompiledPackageRef", ",", "error", ")", "{", "compileOrderReleasePackages", ",", "err", ":=", "c", ".", "resolveJobCompilationDependencies", "(", "jobs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "bosherr", ".", "WrapError", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "compiledPackageRefs", ",", "err", ":=", "c", ".", "compilePackages", "(", "compileOrderReleasePackages", ",", "stage", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "bosherr", ".", "WrapError", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "compiledPackageRefs", ",", "nil", "\n", "}" ]
// Compile resolves and compiles all transitive dependencies of multiple release jobs
[ "Compile", "resolves", "and", "compiles", "all", "transitive", "dependencies", "of", "multiple", "release", "jobs" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/state/job/dependency_compiler.go#L44-L56
train
cloudfoundry/bosh-cli
state/job/dependency_compiler.go
compilePackages
func (c *dependencyCompiler) compilePackages(requiredPackages []birelpkg.Compilable, stage biui.Stage) ([]CompiledPackageRef, error) { packageRefs := make([]CompiledPackageRef, 0, len(requiredPackages)) for _, pkg := range requiredPackages { stepName := fmt.Sprintf("Compiling package '%s/%s'", pkg.Name(), pkg.Fingerprint()) err := stage.Perform(stepName, func() error { compiledPackageRecord, isAlreadyCompiled, err := c.packageCompiler.Compile(pkg) if err != nil { return err } packageRef := CompiledPackageRef{ Name: pkg.Name(), Version: pkg.Fingerprint(), BlobstoreID: compiledPackageRecord.BlobID, SHA1: compiledPackageRecord.BlobSHA1, } packageRefs = append(packageRefs, packageRef) if isAlreadyCompiled { return biui.NewSkipStageError(bosherr.Error(fmt.Sprintf("Package '%s' is already compiled. Skipped compilation", pkg.Name())), "Package already compiled") } return nil }) if err != nil { return nil, err } } return packageRefs, nil }
go
func (c *dependencyCompiler) compilePackages(requiredPackages []birelpkg.Compilable, stage biui.Stage) ([]CompiledPackageRef, error) { packageRefs := make([]CompiledPackageRef, 0, len(requiredPackages)) for _, pkg := range requiredPackages { stepName := fmt.Sprintf("Compiling package '%s/%s'", pkg.Name(), pkg.Fingerprint()) err := stage.Perform(stepName, func() error { compiledPackageRecord, isAlreadyCompiled, err := c.packageCompiler.Compile(pkg) if err != nil { return err } packageRef := CompiledPackageRef{ Name: pkg.Name(), Version: pkg.Fingerprint(), BlobstoreID: compiledPackageRecord.BlobID, SHA1: compiledPackageRecord.BlobSHA1, } packageRefs = append(packageRefs, packageRef) if isAlreadyCompiled { return biui.NewSkipStageError(bosherr.Error(fmt.Sprintf("Package '%s' is already compiled. Skipped compilation", pkg.Name())), "Package already compiled") } return nil }) if err != nil { return nil, err } } return packageRefs, nil }
[ "func", "(", "c", "*", "dependencyCompiler", ")", "compilePackages", "(", "requiredPackages", "[", "]", "birelpkg", ".", "Compilable", ",", "stage", "biui", ".", "Stage", ")", "(", "[", "]", "CompiledPackageRef", ",", "error", ")", "{", "packageRefs", ":=", "make", "(", "[", "]", "CompiledPackageRef", ",", "0", ",", "len", "(", "requiredPackages", ")", ")", "\n\n", "for", "_", ",", "pkg", ":=", "range", "requiredPackages", "{", "stepName", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "pkg", ".", "Name", "(", ")", ",", "pkg", ".", "Fingerprint", "(", ")", ")", "\n\n", "err", ":=", "stage", ".", "Perform", "(", "stepName", ",", "func", "(", ")", "error", "{", "compiledPackageRecord", ",", "isAlreadyCompiled", ",", "err", ":=", "c", ".", "packageCompiler", ".", "Compile", "(", "pkg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "packageRef", ":=", "CompiledPackageRef", "{", "Name", ":", "pkg", ".", "Name", "(", ")", ",", "Version", ":", "pkg", ".", "Fingerprint", "(", ")", ",", "BlobstoreID", ":", "compiledPackageRecord", ".", "BlobID", ",", "SHA1", ":", "compiledPackageRecord", ".", "BlobSHA1", ",", "}", "\n", "packageRefs", "=", "append", "(", "packageRefs", ",", "packageRef", ")", "\n\n", "if", "isAlreadyCompiled", "{", "return", "biui", ".", "NewSkipStageError", "(", "bosherr", ".", "Error", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "pkg", ".", "Name", "(", ")", ")", ")", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "packageRefs", ",", "nil", "\n", "}" ]
// compilePackages compiles the specified packages, in the order specified, uploads them to the Blobstore, and returns the blob references
[ "compilePackages", "compiles", "the", "specified", "packages", "in", "the", "order", "specified", "uploads", "them", "to", "the", "Blobstore", "and", "returns", "the", "blob", "references" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/state/job/dependency_compiler.go#L108-L140
train
cloudfoundry/bosh-cli
uaa/access_token_session.go
TokenFunc
func (s *AccessTokenSession) TokenFunc(retried bool) (string, error) { if !s.token.IsValid() || retried { refreshToken, refreshable := s.token.(RefreshableAccessToken) if !refreshable { return "", errors.New("not a refresh token") } tokenResp, err := s.uaa.RefreshTokenGrant(refreshToken.RefreshValue()) if err != nil { return "", bosherr.WrapError(err, "refreshing token") } s.token = tokenResp if err = s.saveTokenCreds(); err != nil { return "", err } } return s.token.Type() + " " + s.token.Value(), nil }
go
func (s *AccessTokenSession) TokenFunc(retried bool) (string, error) { if !s.token.IsValid() || retried { refreshToken, refreshable := s.token.(RefreshableAccessToken) if !refreshable { return "", errors.New("not a refresh token") } tokenResp, err := s.uaa.RefreshTokenGrant(refreshToken.RefreshValue()) if err != nil { return "", bosherr.WrapError(err, "refreshing token") } s.token = tokenResp if err = s.saveTokenCreds(); err != nil { return "", err } } return s.token.Type() + " " + s.token.Value(), nil }
[ "func", "(", "s", "*", "AccessTokenSession", ")", "TokenFunc", "(", "retried", "bool", ")", "(", "string", ",", "error", ")", "{", "if", "!", "s", ".", "token", ".", "IsValid", "(", ")", "||", "retried", "{", "refreshToken", ",", "refreshable", ":=", "s", ".", "token", ".", "(", "RefreshableAccessToken", ")", "\n", "if", "!", "refreshable", "{", "return", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "tokenResp", ",", "err", ":=", "s", ".", "uaa", ".", "RefreshTokenGrant", "(", "refreshToken", ".", "RefreshValue", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "bosherr", ".", "WrapError", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "s", ".", "token", "=", "tokenResp", "\n", "if", "err", "=", "s", ".", "saveTokenCreds", "(", ")", ";", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "s", ".", "token", ".", "Type", "(", ")", "+", "\"", "\"", "+", "s", ".", "token", ".", "Value", "(", ")", ",", "nil", "\n", "}" ]
// TokenFunc retrieves new access token on first time use // instead of using existing access token optimizing for token // being valid for a longer period of time. Subsequent calls // will reuse access token until it's time for it to be refreshed.
[ "TokenFunc", "retrieves", "new", "access", "token", "on", "first", "time", "use", "instead", "of", "using", "existing", "access", "token", "optimizing", "for", "token", "being", "valid", "for", "a", "longer", "period", "of", "time", ".", "Subsequent", "calls", "will", "reuse", "access", "token", "until", "it", "s", "time", "for", "it", "to", "be", "refreshed", "." ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/uaa/access_token_session.go#L29-L48
train
cloudfoundry/bosh-cli
release/mocks/mocks.go
NewMockExtractor
func NewMockExtractor(ctrl *gomock.Controller) *MockExtractor { mock := &MockExtractor{ctrl: ctrl} mock.recorder = &MockExtractorMockRecorder{mock} return mock }
go
func NewMockExtractor(ctrl *gomock.Controller) *MockExtractor { mock := &MockExtractor{ctrl: ctrl} mock.recorder = &MockExtractorMockRecorder{mock} return mock }
[ "func", "NewMockExtractor", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockExtractor", "{", "mock", ":=", "&", "MockExtractor", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockExtractorMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockExtractor creates a new mock instance
[ "NewMockExtractor", "creates", "a", "new", "mock", "instance" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/release/mocks/mocks.go#L95-L99
train
cloudfoundry/bosh-cli
release/mocks/mocks.go
Extract
func (m *MockExtractor) Extract(arg0 string) (release.Release, error) { ret := m.ctrl.Call(m, "Extract", arg0) ret0, _ := ret[0].(release.Release) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockExtractor) Extract(arg0 string) (release.Release, error) { ret := m.ctrl.Call(m, "Extract", arg0) ret0, _ := ret[0].(release.Release) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockExtractor", ")", "Extract", "(", "arg0", "string", ")", "(", "release", ".", "Release", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "release", ".", "Release", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// Extract mocks base method
[ "Extract", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/release/mocks/mocks.go#L107-L112
train
cloudfoundry/bosh-cli
release/mocks/mocks.go
Extract
func (mr *MockExtractorMockRecorder) Extract(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Extract", reflect.TypeOf((*MockExtractor)(nil).Extract), arg0) }
go
func (mr *MockExtractorMockRecorder) Extract(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Extract", reflect.TypeOf((*MockExtractor)(nil).Extract), arg0) }
[ "func", "(", "mr", "*", "MockExtractorMockRecorder", ")", "Extract", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockExtractor", ")", "(", "nil", ")", ".", "Extract", ")", ",", "arg0", ")", "\n", "}" ]
// Extract indicates an expected call of Extract
[ "Extract", "indicates", "an", "expected", "call", "of", "Extract" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/release/mocks/mocks.go#L115-L117
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
NewMockInstallation
func NewMockInstallation(ctrl *gomock.Controller) *MockInstallation { mock := &MockInstallation{ctrl: ctrl} mock.recorder = &MockInstallationMockRecorder{mock} return mock }
go
func NewMockInstallation(ctrl *gomock.Controller) *MockInstallation { mock := &MockInstallation{ctrl: ctrl} mock.recorder = &MockInstallationMockRecorder{mock} return mock }
[ "func", "NewMockInstallation", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockInstallation", "{", "mock", ":=", "&", "MockInstallation", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockInstallationMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockInstallation creates a new mock instance
[ "NewMockInstallation", "creates", "a", "new", "mock", "instance" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L29-L33
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
Job
func (mr *MockInstallationMockRecorder) Job() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Job", reflect.TypeOf((*MockInstallation)(nil).Job)) }
go
func (mr *MockInstallationMockRecorder) Job() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Job", reflect.TypeOf((*MockInstallation)(nil).Job)) }
[ "func", "(", "mr", "*", "MockInstallationMockRecorder", ")", "Job", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockInstallation", ")", "(", "nil", ")", ".", "Job", ")", ")", "\n", "}" ]
// Job indicates an expected call of Job
[ "Job", "indicates", "an", "expected", "call", "of", "Job" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L48-L50
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
StartRegistry
func (m *MockInstallation) StartRegistry() error { ret := m.ctrl.Call(m, "StartRegistry") ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockInstallation) StartRegistry() error { ret := m.ctrl.Call(m, "StartRegistry") ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockInstallation", ")", "StartRegistry", "(", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// StartRegistry mocks base method
[ "StartRegistry", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L53-L57
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
Target
func (m *MockInstallation) Target() installation.Target { ret := m.ctrl.Call(m, "Target") ret0, _ := ret[0].(installation.Target) return ret0 }
go
func (m *MockInstallation) Target() installation.Target { ret := m.ctrl.Call(m, "Target") ret0, _ := ret[0].(installation.Target) return ret0 }
[ "func", "(", "m", "*", "MockInstallation", ")", "Target", "(", ")", "installation", ".", "Target", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "installation", ".", "Target", ")", "\n", "return", "ret0", "\n", "}" ]
// Target mocks base method
[ "Target", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L77-L81
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
WithRunningRegistry
func (m *MockInstallation) WithRunningRegistry(arg0 logger.Logger, arg1 ui.Stage, arg2 func() error) error { ret := m.ctrl.Call(m, "WithRunningRegistry", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockInstallation) WithRunningRegistry(arg0 logger.Logger, arg1 ui.Stage, arg2 func() error) error { ret := m.ctrl.Call(m, "WithRunningRegistry", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockInstallation", ")", "WithRunningRegistry", "(", "arg0", "logger", ".", "Logger", ",", "arg1", "ui", ".", "Stage", ",", "arg2", "func", "(", ")", "error", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// WithRunningRegistry mocks base method
[ "WithRunningRegistry", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L89-L93
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
WithRunningRegistry
func (mr *MockInstallationMockRecorder) WithRunningRegistry(arg0, arg1, arg2 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithRunningRegistry", reflect.TypeOf((*MockInstallation)(nil).WithRunningRegistry), arg0, arg1, arg2) }
go
func (mr *MockInstallationMockRecorder) WithRunningRegistry(arg0, arg1, arg2 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithRunningRegistry", reflect.TypeOf((*MockInstallation)(nil).WithRunningRegistry), arg0, arg1, arg2) }
[ "func", "(", "mr", "*", "MockInstallationMockRecorder", ")", "WithRunningRegistry", "(", "arg0", ",", "arg1", ",", "arg2", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockInstallation", ")", "(", "nil", ")", ".", "WithRunningRegistry", ")", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "}" ]
// WithRunningRegistry indicates an expected call of WithRunningRegistry
[ "WithRunningRegistry", "indicates", "an", "expected", "call", "of", "WithRunningRegistry" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L96-L98
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
NewMockInstaller
func NewMockInstaller(ctrl *gomock.Controller) *MockInstaller { mock := &MockInstaller{ctrl: ctrl} mock.recorder = &MockInstallerMockRecorder{mock} return mock }
go
func NewMockInstaller(ctrl *gomock.Controller) *MockInstaller { mock := &MockInstaller{ctrl: ctrl} mock.recorder = &MockInstallerMockRecorder{mock} return mock }
[ "func", "NewMockInstaller", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockInstaller", "{", "mock", ":=", "&", "MockInstaller", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockInstallerMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockInstaller creates a new mock instance
[ "NewMockInstaller", "creates", "a", "new", "mock", "instance" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L112-L116
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
Cleanup
func (m *MockInstaller) Cleanup(arg0 installation.Installation) error { ret := m.ctrl.Call(m, "Cleanup", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockInstaller) Cleanup(arg0 installation.Installation) error { ret := m.ctrl.Call(m, "Cleanup", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockInstaller", ")", "Cleanup", "(", "arg0", "installation", ".", "Installation", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// Cleanup mocks base method
[ "Cleanup", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L124-L128
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
Cleanup
func (mr *MockInstallerMockRecorder) Cleanup(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cleanup", reflect.TypeOf((*MockInstaller)(nil).Cleanup), arg0) }
go
func (mr *MockInstallerMockRecorder) Cleanup(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cleanup", reflect.TypeOf((*MockInstaller)(nil).Cleanup), arg0) }
[ "func", "(", "mr", "*", "MockInstallerMockRecorder", ")", "Cleanup", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockInstaller", ")", "(", "nil", ")", ".", "Cleanup", ")", ",", "arg0", ")", "\n", "}" ]
// Cleanup indicates an expected call of Cleanup
[ "Cleanup", "indicates", "an", "expected", "call", "of", "Cleanup" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L131-L133
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
Install
func (m *MockInstaller) Install(arg0 manifest.Manifest, arg1 ui.Stage) (installation.Installation, error) { ret := m.ctrl.Call(m, "Install", arg0, arg1) ret0, _ := ret[0].(installation.Installation) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockInstaller) Install(arg0 manifest.Manifest, arg1 ui.Stage) (installation.Installation, error) { ret := m.ctrl.Call(m, "Install", arg0, arg1) ret0, _ := ret[0].(installation.Installation) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockInstaller", ")", "Install", "(", "arg0", "manifest", ".", "Manifest", ",", "arg1", "ui", ".", "Stage", ")", "(", "installation", ".", "Installation", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "installation", ".", "Installation", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// Install mocks base method
[ "Install", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L136-L141
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
NewMockInstallerFactory
func NewMockInstallerFactory(ctrl *gomock.Controller) *MockInstallerFactory { mock := &MockInstallerFactory{ctrl: ctrl} mock.recorder = &MockInstallerFactoryMockRecorder{mock} return mock }
go
func NewMockInstallerFactory(ctrl *gomock.Controller) *MockInstallerFactory { mock := &MockInstallerFactory{ctrl: ctrl} mock.recorder = &MockInstallerFactoryMockRecorder{mock} return mock }
[ "func", "NewMockInstallerFactory", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockInstallerFactory", "{", "mock", ":=", "&", "MockInstallerFactory", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockInstallerFactoryMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockInstallerFactory creates a new mock instance
[ "NewMockInstallerFactory", "creates", "a", "new", "mock", "instance" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L160-L164
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
NewInstaller
func (m *MockInstallerFactory) NewInstaller(arg0 installation.Target) installation.Installer { ret := m.ctrl.Call(m, "NewInstaller", arg0) ret0, _ := ret[0].(installation.Installer) return ret0 }
go
func (m *MockInstallerFactory) NewInstaller(arg0 installation.Target) installation.Installer { ret := m.ctrl.Call(m, "NewInstaller", arg0) ret0, _ := ret[0].(installation.Installer) return ret0 }
[ "func", "(", "m", "*", "MockInstallerFactory", ")", "NewInstaller", "(", "arg0", "installation", ".", "Target", ")", "installation", ".", "Installer", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "installation", ".", "Installer", ")", "\n", "return", "ret0", "\n", "}" ]
// NewInstaller mocks base method
[ "NewInstaller", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L172-L176
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
NewInstaller
func (mr *MockInstallerFactoryMockRecorder) NewInstaller(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewInstaller", reflect.TypeOf((*MockInstallerFactory)(nil).NewInstaller), arg0) }
go
func (mr *MockInstallerFactoryMockRecorder) NewInstaller(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewInstaller", reflect.TypeOf((*MockInstallerFactory)(nil).NewInstaller), arg0) }
[ "func", "(", "mr", "*", "MockInstallerFactoryMockRecorder", ")", "NewInstaller", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockInstallerFactory", ")", "(", "nil", ")", ".", "NewInstaller", ")", ",", "arg0", ")", "\n", "}" ]
// NewInstaller indicates an expected call of NewInstaller
[ "NewInstaller", "indicates", "an", "expected", "call", "of", "NewInstaller" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L179-L181
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
NewMockUninstaller
func NewMockUninstaller(ctrl *gomock.Controller) *MockUninstaller { mock := &MockUninstaller{ctrl: ctrl} mock.recorder = &MockUninstallerMockRecorder{mock} return mock }
go
func NewMockUninstaller(ctrl *gomock.Controller) *MockUninstaller { mock := &MockUninstaller{ctrl: ctrl} mock.recorder = &MockUninstallerMockRecorder{mock} return mock }
[ "func", "NewMockUninstaller", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockUninstaller", "{", "mock", ":=", "&", "MockUninstaller", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockUninstallerMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockUninstaller creates a new mock instance
[ "NewMockUninstaller", "creates", "a", "new", "mock", "instance" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L195-L199
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
Uninstall
func (m *MockUninstaller) Uninstall(arg0 installation.Target) error { ret := m.ctrl.Call(m, "Uninstall", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockUninstaller) Uninstall(arg0 installation.Target) error { ret := m.ctrl.Call(m, "Uninstall", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockUninstaller", ")", "Uninstall", "(", "arg0", "installation", ".", "Target", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// Uninstall mocks base method
[ "Uninstall", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L207-L211
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
Uninstall
func (mr *MockUninstallerMockRecorder) Uninstall(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Uninstall", reflect.TypeOf((*MockUninstaller)(nil).Uninstall), arg0) }
go
func (mr *MockUninstallerMockRecorder) Uninstall(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Uninstall", reflect.TypeOf((*MockUninstaller)(nil).Uninstall), arg0) }
[ "func", "(", "mr", "*", "MockUninstallerMockRecorder", ")", "Uninstall", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockUninstaller", ")", "(", "nil", ")", ".", "Uninstall", ")", ",", "arg0", ")", "\n", "}" ]
// Uninstall indicates an expected call of Uninstall
[ "Uninstall", "indicates", "an", "expected", "call", "of", "Uninstall" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L214-L216
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
From
func (m *MockJobResolver) From(arg0 manifest.Manifest) ([]job.Job, error) { ret := m.ctrl.Call(m, "From", arg0) ret0, _ := ret[0].([]job.Job) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockJobResolver) From(arg0 manifest.Manifest) ([]job.Job, error) { ret := m.ctrl.Call(m, "From", arg0) ret0, _ := ret[0].([]job.Job) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockJobResolver", ")", "From", "(", "arg0", "manifest", ".", "Manifest", ")", "(", "[", "]", "job", ".", "Job", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "[", "]", "job", ".", "Job", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// From mocks base method
[ "From", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L242-L247
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
From
func (mr *MockJobResolverMockRecorder) From(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "From", reflect.TypeOf((*MockJobResolver)(nil).From), arg0) }
go
func (mr *MockJobResolverMockRecorder) From(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "From", reflect.TypeOf((*MockJobResolver)(nil).From), arg0) }
[ "func", "(", "mr", "*", "MockJobResolverMockRecorder", ")", "From", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockJobResolver", ")", "(", "nil", ")", ".", "From", ")", ",", "arg0", ")", "\n", "}" ]
// From indicates an expected call of From
[ "From", "indicates", "an", "expected", "call", "of", "From" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L250-L252
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
NewMockPackageCompiler
func NewMockPackageCompiler(ctrl *gomock.Controller) *MockPackageCompiler { mock := &MockPackageCompiler{ctrl: ctrl} mock.recorder = &MockPackageCompilerMockRecorder{mock} return mock }
go
func NewMockPackageCompiler(ctrl *gomock.Controller) *MockPackageCompiler { mock := &MockPackageCompiler{ctrl: ctrl} mock.recorder = &MockPackageCompilerMockRecorder{mock} return mock }
[ "func", "NewMockPackageCompiler", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockPackageCompiler", "{", "mock", ":=", "&", "MockPackageCompiler", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockPackageCompilerMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockPackageCompiler creates a new mock instance
[ "NewMockPackageCompiler", "creates", "a", "new", "mock", "instance" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L266-L270
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
For
func (mr *MockPackageCompilerMockRecorder) For(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "For", reflect.TypeOf((*MockPackageCompiler)(nil).For), arg0, arg1) }
go
func (mr *MockPackageCompilerMockRecorder) For(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "For", reflect.TypeOf((*MockPackageCompiler)(nil).For), arg0, arg1) }
[ "func", "(", "mr", "*", "MockPackageCompilerMockRecorder", ")", "For", "(", "arg0", ",", "arg1", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockPackageCompiler", ")", "(", "nil", ")", ".", "For", ")", ",", "arg0", ",", "arg1", ")", "\n", "}" ]
// For indicates an expected call of For
[ "For", "indicates", "an", "expected", "call", "of", "For" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L286-L288
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
RenderAndUploadFrom
func (m *MockJobRenderer) RenderAndUploadFrom(arg0 manifest.Manifest, arg1 []job.Job, arg2 ui.Stage) ([]installation.RenderedJobRef, error) { ret := m.ctrl.Call(m, "RenderAndUploadFrom", arg0, arg1, arg2) ret0, _ := ret[0].([]installation.RenderedJobRef) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockJobRenderer) RenderAndUploadFrom(arg0 manifest.Manifest, arg1 []job.Job, arg2 ui.Stage) ([]installation.RenderedJobRef, error) { ret := m.ctrl.Call(m, "RenderAndUploadFrom", arg0, arg1, arg2) ret0, _ := ret[0].([]installation.RenderedJobRef) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockJobRenderer", ")", "RenderAndUploadFrom", "(", "arg0", "manifest", ".", "Manifest", ",", "arg1", "[", "]", "job", ".", "Job", ",", "arg2", "ui", ".", "Stage", ")", "(", "[", "]", "installation", ".", "RenderedJobRef", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "[", "]", "installation", ".", "RenderedJobRef", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// RenderAndUploadFrom mocks base method
[ "RenderAndUploadFrom", "mocks", "base", "method" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L314-L319
train
cloudfoundry/bosh-cli
installation/mocks/mocks.go
RenderAndUploadFrom
func (mr *MockJobRendererMockRecorder) RenderAndUploadFrom(arg0, arg1, arg2 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RenderAndUploadFrom", reflect.TypeOf((*MockJobRenderer)(nil).RenderAndUploadFrom), arg0, arg1, arg2) }
go
func (mr *MockJobRendererMockRecorder) RenderAndUploadFrom(arg0, arg1, arg2 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RenderAndUploadFrom", reflect.TypeOf((*MockJobRenderer)(nil).RenderAndUploadFrom), arg0, arg1, arg2) }
[ "func", "(", "mr", "*", "MockJobRendererMockRecorder", ")", "RenderAndUploadFrom", "(", "arg0", ",", "arg1", ",", "arg2", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockJobRenderer", ")", "(", "nil", ")", ".", "RenderAndUploadFrom", ")", ",", "arg0", ",", "arg1", ",", "arg2", ")", "\n", "}" ]
// RenderAndUploadFrom indicates an expected call of RenderAndUploadFrom
[ "RenderAndUploadFrom", "indicates", "an", "expected", "call", "of", "RenderAndUploadFrom" ]
0ee5b2abedb27e521dc6e70719023e7b382cab79
https://github.com/cloudfoundry/bosh-cli/blob/0ee5b2abedb27e521dc6e70719023e7b382cab79/installation/mocks/mocks.go#L322-L324
train
CloudyKit/jet
func.go
Get
func (a *Arguments) Get(argumentIndex int) reflect.Value { if argumentIndex < len(a.argVal) { return a.argVal[argumentIndex] } if argumentIndex < len(a.argVal)+len(a.argExpr) { return a.runtime.evalPrimaryExpressionGroup(a.argExpr[argumentIndex-len(a.argVal)]) } return reflect.Value{} }
go
func (a *Arguments) Get(argumentIndex int) reflect.Value { if argumentIndex < len(a.argVal) { return a.argVal[argumentIndex] } if argumentIndex < len(a.argVal)+len(a.argExpr) { return a.runtime.evalPrimaryExpressionGroup(a.argExpr[argumentIndex-len(a.argVal)]) } return reflect.Value{} }
[ "func", "(", "a", "*", "Arguments", ")", "Get", "(", "argumentIndex", "int", ")", "reflect", ".", "Value", "{", "if", "argumentIndex", "<", "len", "(", "a", ".", "argVal", ")", "{", "return", "a", ".", "argVal", "[", "argumentIndex", "]", "\n", "}", "\n", "if", "argumentIndex", "<", "len", "(", "a", ".", "argVal", ")", "+", "len", "(", "a", ".", "argExpr", ")", "{", "return", "a", ".", "runtime", ".", "evalPrimaryExpressionGroup", "(", "a", ".", "argExpr", "[", "argumentIndex", "-", "len", "(", "a", ".", "argVal", ")", "]", ")", "\n", "}", "\n", "return", "reflect", ".", "Value", "{", "}", "\n", "}" ]
// Get gets an argument by index.
[ "Get", "gets", "an", "argument", "by", "index", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/func.go#L30-L38
train
CloudyKit/jet
func.go
Panicf
func (a *Arguments) Panicf(format string, v ...interface{}) { panic(fmt.Errorf(format, v...)) }
go
func (a *Arguments) Panicf(format string, v ...interface{}) { panic(fmt.Errorf(format, v...)) }
[ "func", "(", "a", "*", "Arguments", ")", "Panicf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "panic", "(", "fmt", ".", "Errorf", "(", "format", ",", "v", "...", ")", ")", "\n", "}" ]
// Panicf panics with formatted error message.
[ "Panicf", "panics", "with", "formatted", "error", "message", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/func.go#L41-L43
train
CloudyKit/jet
func.go
RequireNumOfArguments
func (a *Arguments) RequireNumOfArguments(funcname string, min, max int) { num := len(a.argExpr) + len(a.argVal) if min >= 0 && num < min { a.Panicf("unexpected number of arguments in a call to %s", funcname) } else if max >= 0 && num > max { a.Panicf("unexpected number of arguments in a call to %s", funcname) } }
go
func (a *Arguments) RequireNumOfArguments(funcname string, min, max int) { num := len(a.argExpr) + len(a.argVal) if min >= 0 && num < min { a.Panicf("unexpected number of arguments in a call to %s", funcname) } else if max >= 0 && num > max { a.Panicf("unexpected number of arguments in a call to %s", funcname) } }
[ "func", "(", "a", "*", "Arguments", ")", "RequireNumOfArguments", "(", "funcname", "string", ",", "min", ",", "max", "int", ")", "{", "num", ":=", "len", "(", "a", ".", "argExpr", ")", "+", "len", "(", "a", ".", "argVal", ")", "\n", "if", "min", ">=", "0", "&&", "num", "<", "min", "{", "a", ".", "Panicf", "(", "\"", "\"", ",", "funcname", ")", "\n", "}", "else", "if", "max", ">=", "0", "&&", "num", ">", "max", "{", "a", ".", "Panicf", "(", "\"", "\"", ",", "funcname", ")", "\n", "}", "\n", "}" ]
// RequireNumOfArguments panics if the number of arguments is not in the range specified by min and max. // In case there is no minimum pass -1, in case there is no maximum pass -1 respectively.
[ "RequireNumOfArguments", "panics", "if", "the", "number", "of", "arguments", "is", "not", "in", "the", "range", "specified", "by", "min", "and", "max", ".", "In", "case", "there", "is", "no", "minimum", "pass", "-", "1", "in", "case", "there", "is", "no", "maximum", "pass", "-", "1", "respectively", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/func.go#L47-L54
train
CloudyKit/jet
func.go
NumOfArguments
func (a *Arguments) NumOfArguments() int { return len(a.argExpr) + len(a.argVal) }
go
func (a *Arguments) NumOfArguments() int { return len(a.argExpr) + len(a.argVal) }
[ "func", "(", "a", "*", "Arguments", ")", "NumOfArguments", "(", ")", "int", "{", "return", "len", "(", "a", ".", "argExpr", ")", "+", "len", "(", "a", ".", "argVal", ")", "\n", "}" ]
// NumOfArguments returns the number of arguments
[ "NumOfArguments", "returns", "the", "number", "of", "arguments" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/func.go#L57-L59
train
CloudyKit/jet
loaders/multi/multi.go
AddLoaders
func (m *Multi) AddLoaders(loaders ...jet.Loader) { m.loaders = append(m.loaders, loaders...) }
go
func (m *Multi) AddLoaders(loaders ...jet.Loader) { m.loaders = append(m.loaders, loaders...) }
[ "func", "(", "m", "*", "Multi", ")", "AddLoaders", "(", "loaders", "...", "jet", ".", "Loader", ")", "{", "m", ".", "loaders", "=", "append", "(", "m", ".", "loaders", ",", "loaders", "...", ")", "\n", "}" ]
// AddLoaders adds the passed loaders to the list of loaders.
[ "AddLoaders", "adds", "the", "passed", "loaders", "to", "the", "list", "of", "loaders", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/loaders/multi/multi.go#L22-L24
train
CloudyKit/jet
loaders/multi/multi.go
Open
func (m *Multi) Open(name string) (io.ReadCloser, error) { for _, loader := range m.loaders { if f, err := loader.Open(name); err == nil { return f, nil } } return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist} }
go
func (m *Multi) Open(name string) (io.ReadCloser, error) { for _, loader := range m.loaders { if f, err := loader.Open(name); err == nil { return f, nil } } return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist} }
[ "func", "(", "m", "*", "Multi", ")", "Open", "(", "name", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "for", "_", ",", "loader", ":=", "range", "m", ".", "loaders", "{", "if", "f", ",", "err", ":=", "loader", ".", "Open", "(", "name", ")", ";", "err", "==", "nil", "{", "return", "f", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "&", "os", ".", "PathError", "{", "Op", ":", "\"", "\"", ",", "Path", ":", "name", ",", "Err", ":", "os", ".", "ErrNotExist", "}", "\n", "}" ]
// Open will open the file passed by trying all loaders in succession.
[ "Open", "will", "open", "the", "file", "passed", "by", "trying", "all", "loaders", "in", "succession", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/loaders/multi/multi.go#L32-L39
train
CloudyKit/jet
loaders/multi/multi.go
Exists
func (m *Multi) Exists(name string) (string, bool) { for _, loader := range m.loaders { if fileName, ok := loader.Exists(name); ok { return fileName, true } } return "", false }
go
func (m *Multi) Exists(name string) (string, bool) { for _, loader := range m.loaders { if fileName, ok := loader.Exists(name); ok { return fileName, true } } return "", false }
[ "func", "(", "m", "*", "Multi", ")", "Exists", "(", "name", "string", ")", "(", "string", ",", "bool", ")", "{", "for", "_", ",", "loader", ":=", "range", "m", ".", "loaders", "{", "if", "fileName", ",", "ok", ":=", "loader", ".", "Exists", "(", "name", ")", ";", "ok", "{", "return", "fileName", ",", "true", "\n", "}", "\n", "}", "\n", "return", "\"", "\"", ",", "false", "\n", "}" ]
// Exists checks all loaders in succession, returning the full path of the template and // bool true if the template file was found, otherwise it returns an empty string and false.
[ "Exists", "checks", "all", "loaders", "in", "succession", "returning", "the", "full", "path", "of", "the", "template", "and", "bool", "true", "if", "the", "template", "file", "was", "found", "otherwise", "it", "returns", "an", "empty", "string", "and", "false", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/loaders/multi/multi.go#L43-L50
train
CloudyKit/jet
lex.go
lexSpace
func lexSpace(l *lexer) stateFn { for isSpace(l.peek()) { l.next() } l.emit(itemSpace) return lexInsideAction }
go
func lexSpace(l *lexer) stateFn { for isSpace(l.peek()) { l.next() } l.emit(itemSpace) return lexInsideAction }
[ "func", "lexSpace", "(", "l", "*", "lexer", ")", "stateFn", "{", "for", "isSpace", "(", "l", ".", "peek", "(", ")", ")", "{", "l", ".", "next", "(", ")", "\n", "}", "\n", "l", ".", "emit", "(", "itemSpace", ")", "\n", "return", "lexInsideAction", "\n", "}" ]
// lexSpace scans a run of space characters. // One space has already been seen.
[ "lexSpace", "scans", "a", "run", "of", "space", "characters", ".", "One", "space", "has", "already", "been", "seen", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/lex.go#L487-L493
train
CloudyKit/jet
lex.go
lexIdentifier
func lexIdentifier(l *lexer) stateFn { Loop: for { switch r := l.next(); { case isAlphaNumeric(r): // absorb. default: l.backup() word := l.input[l.start:l.pos] if !l.atTerminator() { return l.errorf("bad character %#U", r) } switch { case key[word] > itemKeyword: l.emit(key[word]) case word[0] == '.': l.emit(itemField) case word == "true", word == "false": l.emit(itemBool) default: l.emit(itemIdentifier) } break Loop } } return lexInsideAction }
go
func lexIdentifier(l *lexer) stateFn { Loop: for { switch r := l.next(); { case isAlphaNumeric(r): // absorb. default: l.backup() word := l.input[l.start:l.pos] if !l.atTerminator() { return l.errorf("bad character %#U", r) } switch { case key[word] > itemKeyword: l.emit(key[word]) case word[0] == '.': l.emit(itemField) case word == "true", word == "false": l.emit(itemBool) default: l.emit(itemIdentifier) } break Loop } } return lexInsideAction }
[ "func", "lexIdentifier", "(", "l", "*", "lexer", ")", "stateFn", "{", "Loop", ":", "for", "{", "switch", "r", ":=", "l", ".", "next", "(", ")", ";", "{", "case", "isAlphaNumeric", "(", "r", ")", ":", "// absorb.", "default", ":", "l", ".", "backup", "(", ")", "\n", "word", ":=", "l", ".", "input", "[", "l", ".", "start", ":", "l", ".", "pos", "]", "\n", "if", "!", "l", ".", "atTerminator", "(", ")", "{", "return", "l", ".", "errorf", "(", "\"", "\"", ",", "r", ")", "\n", "}", "\n", "switch", "{", "case", "key", "[", "word", "]", ">", "itemKeyword", ":", "l", ".", "emit", "(", "key", "[", "word", "]", ")", "\n", "case", "word", "[", "0", "]", "==", "'.'", ":", "l", ".", "emit", "(", "itemField", ")", "\n", "case", "word", "==", "\"", "\"", ",", "word", "==", "\"", "\"", ":", "l", ".", "emit", "(", "itemBool", ")", "\n", "default", ":", "l", ".", "emit", "(", "itemIdentifier", ")", "\n", "}", "\n", "break", "Loop", "\n", "}", "\n", "}", "\n", "return", "lexInsideAction", "\n", "}" ]
// lexIdentifier scans an alphanumeric.
[ "lexIdentifier", "scans", "an", "alphanumeric", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/lex.go#L496-L522
train
CloudyKit/jet
lex.go
lexChar
func lexChar(l *lexer) stateFn { Loop: for { switch l.next() { case '\\': if r := l.next(); r != eof && r != '\n' { break } fallthrough case eof, '\n': return l.errorf("unterminated character constant") case '\'': break Loop } } l.emit(itemCharConstant) return lexInsideAction }
go
func lexChar(l *lexer) stateFn { Loop: for { switch l.next() { case '\\': if r := l.next(); r != eof && r != '\n' { break } fallthrough case eof, '\n': return l.errorf("unterminated character constant") case '\'': break Loop } } l.emit(itemCharConstant) return lexInsideAction }
[ "func", "lexChar", "(", "l", "*", "lexer", ")", "stateFn", "{", "Loop", ":", "for", "{", "switch", "l", ".", "next", "(", ")", "{", "case", "'\\\\'", ":", "if", "r", ":=", "l", ".", "next", "(", ")", ";", "r", "!=", "eof", "&&", "r", "!=", "'\\n'", "{", "break", "\n", "}", "\n", "fallthrough", "\n", "case", "eof", ",", "'\\n'", ":", "return", "l", ".", "errorf", "(", "\"", "\"", ")", "\n", "case", "'\\''", ":", "break", "Loop", "\n", "}", "\n", "}", "\n", "l", ".", "emit", "(", "itemCharConstant", ")", "\n", "return", "lexInsideAction", "\n", "}" ]
// lexChar scans a character constant. The initial quote is already // scanned. Syntax checking is done by the parser.
[ "lexChar", "scans", "a", "character", "constant", ".", "The", "initial", "quote", "is", "already", "scanned", ".", "Syntax", "checking", "is", "done", "by", "the", "parser", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/lex.go#L573-L590
train
CloudyKit/jet
lex.go
lexQuote
func lexQuote(l *lexer) stateFn { Loop: for { switch l.next() { case '\\': if r := l.next(); r != eof && r != '\n' { break } fallthrough case eof, '\n': return l.errorf("unterminated quoted string") case '"': break Loop } } l.emit(itemString) return lexInsideAction }
go
func lexQuote(l *lexer) stateFn { Loop: for { switch l.next() { case '\\': if r := l.next(); r != eof && r != '\n' { break } fallthrough case eof, '\n': return l.errorf("unterminated quoted string") case '"': break Loop } } l.emit(itemString) return lexInsideAction }
[ "func", "lexQuote", "(", "l", "*", "lexer", ")", "stateFn", "{", "Loop", ":", "for", "{", "switch", "l", ".", "next", "(", ")", "{", "case", "'\\\\'", ":", "if", "r", ":=", "l", ".", "next", "(", ")", ";", "r", "!=", "eof", "&&", "r", "!=", "'\\n'", "{", "break", "\n", "}", "\n", "fallthrough", "\n", "case", "eof", ",", "'\\n'", ":", "return", "l", ".", "errorf", "(", "\"", "\"", ")", "\n", "case", "'\"'", ":", "break", "Loop", "\n", "}", "\n", "}", "\n", "l", ".", "emit", "(", "itemString", ")", "\n", "return", "lexInsideAction", "\n", "}" ]
// lexQuote scans a quoted string.
[ "lexQuote", "scans", "a", "quoted", "string", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/lex.go#L632-L649
train
CloudyKit/jet
lex.go
lexRawQuote
func lexRawQuote(l *lexer) stateFn { Loop: for { switch l.next() { case eof: return l.errorf("unterminated raw quoted string") case '`': break Loop } } l.emit(itemRawString) return lexInsideAction }
go
func lexRawQuote(l *lexer) stateFn { Loop: for { switch l.next() { case eof: return l.errorf("unterminated raw quoted string") case '`': break Loop } } l.emit(itemRawString) return lexInsideAction }
[ "func", "lexRawQuote", "(", "l", "*", "lexer", ")", "stateFn", "{", "Loop", ":", "for", "{", "switch", "l", ".", "next", "(", ")", "{", "case", "eof", ":", "return", "l", ".", "errorf", "(", "\"", "\"", ")", "\n", "case", "'`'", ":", "break", "Loop", "\n", "}", "\n", "}", "\n", "l", ".", "emit", "(", "itemRawString", ")", "\n", "return", "lexInsideAction", "\n", "}" ]
// lexRawQuote scans a raw quoted string.
[ "lexRawQuote", "scans", "a", "raw", "quoted", "string", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/lex.go#L652-L664
train
CloudyKit/jet
utils/visitor.go
Walk
func Walk(t *jet.Template, v Visitor) { v.Visit(VisitorContext{Visitor: v}, t.Root) }
go
func Walk(t *jet.Template, v Visitor) { v.Visit(VisitorContext{Visitor: v}, t.Root) }
[ "func", "Walk", "(", "t", "*", "jet", ".", "Template", ",", "v", "Visitor", ")", "{", "v", ".", "Visit", "(", "VisitorContext", "{", "Visitor", ":", "v", "}", ",", "t", ".", "Root", ")", "\n", "}" ]
// Walk walks the template ast and calls the Visit method on each node of the tree // if you're not familiar with the Visitor pattern please check the visitor_test.go // for usage examples
[ "Walk", "walks", "the", "template", "ast", "and", "calls", "the", "Visit", "method", "on", "each", "node", "of", "the", "tree", "if", "you", "re", "not", "familiar", "with", "the", "Visitor", "pattern", "please", "check", "the", "visitor_test", ".", "go", "for", "usage", "examples" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/utils/visitor.go#L12-L14
train
CloudyKit/jet
examples/todos/main.go
Render
func (t *tTODO) Render(r *jet.Runtime) { done := "yes" if !t.Done { done = "no" } r.Write([]byte(fmt.Sprintf("TODO: %s (done: %s)", t.Text, done))) }
go
func (t *tTODO) Render(r *jet.Runtime) { done := "yes" if !t.Done { done = "no" } r.Write([]byte(fmt.Sprintf("TODO: %s (done: %s)", t.Text, done))) }
[ "func", "(", "t", "*", "tTODO", ")", "Render", "(", "r", "*", "jet", ".", "Runtime", ")", "{", "done", ":=", "\"", "\"", "\n", "if", "!", "t", ".", "Done", "{", "done", "=", "\"", "\"", "\n", "}", "\n", "r", ".", "Write", "(", "[", "]", "byte", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "t", ".", "Text", ",", "done", ")", ")", ")", "\n", "}" ]
// Render implements jet.Renderer interface
[ "Render", "implements", "jet", ".", "Renderer", "interface" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/examples/todos/main.go#L68-L74
train
CloudyKit/jet
parse.go
parseTemplate
func (t *Template) parseTemplate() (next Node) { t.Root = t.newList(t.peek().pos) // {{ extends|import stringLiteral }} for t.peek().typ != itemEOF { delim := t.next() if delim.typ == itemText && strings.TrimSpace(delim.val) == "" { continue //skips empty text nodes } if delim.typ == itemLeftDelim { token := t.nextNonSpace() if token.typ == itemExtends || token.typ == itemImport { s := t.expectString("extends|import") if token.typ == itemExtends { if t.extends != nil { t.errorf("Unexpected extends clause, only one extends clause is valid per template") } else if len(t.imports) > 0 { t.errorf("Unexpected extends clause, all import clause should come after extends clause") } var err error t.extends, err = t.set.getTemplateWhileParsing(t.Name, s) if err != nil { t.error(err) } } else { tt, err := t.set.getTemplateWhileParsing(t.Name, s) if err != nil { t.error(err) } t.imports = append(t.imports, tt) } t.expect(itemRightDelim, "extends|import") } else { t.backup2(delim) break } } else { t.backup() break } } for t.peek().typ != itemEOF { switch n := t.textOrAction(); n.Type() { case nodeEnd, nodeElse, nodeContent: t.errorf("unexpected %s", n) default: t.Root.append(n) } } return nil }
go
func (t *Template) parseTemplate() (next Node) { t.Root = t.newList(t.peek().pos) // {{ extends|import stringLiteral }} for t.peek().typ != itemEOF { delim := t.next() if delim.typ == itemText && strings.TrimSpace(delim.val) == "" { continue //skips empty text nodes } if delim.typ == itemLeftDelim { token := t.nextNonSpace() if token.typ == itemExtends || token.typ == itemImport { s := t.expectString("extends|import") if token.typ == itemExtends { if t.extends != nil { t.errorf("Unexpected extends clause, only one extends clause is valid per template") } else if len(t.imports) > 0 { t.errorf("Unexpected extends clause, all import clause should come after extends clause") } var err error t.extends, err = t.set.getTemplateWhileParsing(t.Name, s) if err != nil { t.error(err) } } else { tt, err := t.set.getTemplateWhileParsing(t.Name, s) if err != nil { t.error(err) } t.imports = append(t.imports, tt) } t.expect(itemRightDelim, "extends|import") } else { t.backup2(delim) break } } else { t.backup() break } } for t.peek().typ != itemEOF { switch n := t.textOrAction(); n.Type() { case nodeEnd, nodeElse, nodeContent: t.errorf("unexpected %s", n) default: t.Root.append(n) } } return nil }
[ "func", "(", "t", "*", "Template", ")", "parseTemplate", "(", ")", "(", "next", "Node", ")", "{", "t", ".", "Root", "=", "t", ".", "newList", "(", "t", ".", "peek", "(", ")", ".", "pos", ")", "\n", "// {{ extends|import stringLiteral }}", "for", "t", ".", "peek", "(", ")", ".", "typ", "!=", "itemEOF", "{", "delim", ":=", "t", ".", "next", "(", ")", "\n", "if", "delim", ".", "typ", "==", "itemText", "&&", "strings", ".", "TrimSpace", "(", "delim", ".", "val", ")", "==", "\"", "\"", "{", "continue", "//skips empty text nodes", "\n", "}", "\n", "if", "delim", ".", "typ", "==", "itemLeftDelim", "{", "token", ":=", "t", ".", "nextNonSpace", "(", ")", "\n", "if", "token", ".", "typ", "==", "itemExtends", "||", "token", ".", "typ", "==", "itemImport", "{", "s", ":=", "t", ".", "expectString", "(", "\"", "\"", ")", "\n", "if", "token", ".", "typ", "==", "itemExtends", "{", "if", "t", ".", "extends", "!=", "nil", "{", "t", ".", "errorf", "(", "\"", "\"", ")", "\n", "}", "else", "if", "len", "(", "t", ".", "imports", ")", ">", "0", "{", "t", ".", "errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "var", "err", "error", "\n", "t", ".", "extends", ",", "err", "=", "t", ".", "set", ".", "getTemplateWhileParsing", "(", "t", ".", "Name", ",", "s", ")", "\n", "if", "err", "!=", "nil", "{", "t", ".", "error", "(", "err", ")", "\n", "}", "\n", "}", "else", "{", "tt", ",", "err", ":=", "t", ".", "set", ".", "getTemplateWhileParsing", "(", "t", ".", "Name", ",", "s", ")", "\n", "if", "err", "!=", "nil", "{", "t", ".", "error", "(", "err", ")", "\n", "}", "\n", "t", ".", "imports", "=", "append", "(", "t", ".", "imports", ",", "tt", ")", "\n", "}", "\n", "t", ".", "expect", "(", "itemRightDelim", ",", "\"", "\"", ")", "\n", "}", "else", "{", "t", ".", "backup2", "(", "delim", ")", "\n", "break", "\n", "}", "\n", "}", "else", "{", "t", ".", "backup", "(", ")", "\n", "break", "\n", "}", "\n", "}", "\n\n", "for", "t", ".", "peek", "(", ")", ".", "typ", "!=", "itemEOF", "{", "switch", "n", ":=", "t", ".", "textOrAction", "(", ")", ";", "n", ".", "Type", "(", ")", "{", "case", "nodeEnd", ",", "nodeElse", ",", "nodeContent", ":", "t", ".", "errorf", "(", "\"", "\"", ",", "n", ")", "\n", "default", ":", "t", ".", "Root", ".", "append", "(", "n", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// parse is the top-level parser for a template, essentially the same // It runs to EOF.
[ "parse", "is", "the", "top", "-", "level", "parser", "for", "a", "template", "essentially", "the", "same", "It", "runs", "to", "EOF", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/parse.go#L198-L248
train
CloudyKit/jet
node.go
simplifyComplex
func (n *NumberNode) simplifyComplex() { n.IsFloat = imag(n.Complex128) == 0 if n.IsFloat { n.Float64 = real(n.Complex128) n.IsInt = float64(int64(n.Float64)) == n.Float64 if n.IsInt { n.Int64 = int64(n.Float64) } n.IsUint = float64(uint64(n.Float64)) == n.Float64 if n.IsUint { n.Uint64 = uint64(n.Float64) } } }
go
func (n *NumberNode) simplifyComplex() { n.IsFloat = imag(n.Complex128) == 0 if n.IsFloat { n.Float64 = real(n.Complex128) n.IsInt = float64(int64(n.Float64)) == n.Float64 if n.IsInt { n.Int64 = int64(n.Float64) } n.IsUint = float64(uint64(n.Float64)) == n.Float64 if n.IsUint { n.Uint64 = uint64(n.Float64) } } }
[ "func", "(", "n", "*", "NumberNode", ")", "simplifyComplex", "(", ")", "{", "n", ".", "IsFloat", "=", "imag", "(", "n", ".", "Complex128", ")", "==", "0", "\n", "if", "n", ".", "IsFloat", "{", "n", ".", "Float64", "=", "real", "(", "n", ".", "Complex128", ")", "\n", "n", ".", "IsInt", "=", "float64", "(", "int64", "(", "n", ".", "Float64", ")", ")", "==", "n", ".", "Float64", "\n", "if", "n", ".", "IsInt", "{", "n", ".", "Int64", "=", "int64", "(", "n", ".", "Float64", ")", "\n", "}", "\n", "n", ".", "IsUint", "=", "float64", "(", "uint64", "(", "n", ".", "Float64", ")", ")", "==", "n", ".", "Float64", "\n", "if", "n", ".", "IsUint", "{", "n", ".", "Uint64", "=", "uint64", "(", "n", ".", "Float64", ")", "\n", "}", "\n", "}", "\n", "}" ]
// simplifyComplex pulls out any other types that are represented by the complex number. // These all require that the imaginary part be zero.
[ "simplifyComplex", "pulls", "out", "any", "other", "types", "that", "are", "represented", "by", "the", "complex", "number", ".", "These", "all", "require", "that", "the", "imaginary", "part", "be", "zero", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/node.go#L310-L323
train
CloudyKit/jet
loader.go
Open
func (l *OSFileSystemLoader) Open(name string) (io.ReadCloser, error) { return os.Open(name) }
go
func (l *OSFileSystemLoader) Open(name string) (io.ReadCloser, error) { return os.Open(name) }
[ "func", "(", "l", "*", "OSFileSystemLoader", ")", "Open", "(", "name", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "return", "os", ".", "Open", "(", "name", ")", "\n", "}" ]
// Open opens a file from OS file system.
[ "Open", "opens", "a", "file", "from", "OS", "file", "system", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/loader.go#L54-L56
train
CloudyKit/jet
loader.go
AddPath
func (l *OSFileSystemLoader) AddPath(path string) { l.dirs = append(l.dirs, path) }
go
func (l *OSFileSystemLoader) AddPath(path string) { l.dirs = append(l.dirs, path) }
[ "func", "(", "l", "*", "OSFileSystemLoader", ")", "AddPath", "(", "path", "string", ")", "{", "l", ".", "dirs", "=", "append", "(", "l", ".", "dirs", ",", "path", ")", "\n", "}" ]
// AddPath adds the path to the internal list of paths searched when loading templates.
[ "AddPath", "adds", "the", "path", "to", "the", "internal", "list", "of", "paths", "searched", "when", "loading", "templates", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/loader.go#L71-L73
train
CloudyKit/jet
eval.go
YieldBlock
func (st *Runtime) YieldBlock(name string, context interface{}) { block, has := st.getBlock(name) if has == false { panic(fmt.Errorf("Block %q was not found!!", name)) } if context != nil { current := st.context st.context = reflect.ValueOf(context) st.executeList(block.List) st.context = current } st.executeList(block.List) }
go
func (st *Runtime) YieldBlock(name string, context interface{}) { block, has := st.getBlock(name) if has == false { panic(fmt.Errorf("Block %q was not found!!", name)) } if context != nil { current := st.context st.context = reflect.ValueOf(context) st.executeList(block.List) st.context = current } st.executeList(block.List) }
[ "func", "(", "st", "*", "Runtime", ")", "YieldBlock", "(", "name", "string", ",", "context", "interface", "{", "}", ")", "{", "block", ",", "has", ":=", "st", ".", "getBlock", "(", "name", ")", "\n\n", "if", "has", "==", "false", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", ")", "\n", "}", "\n\n", "if", "context", "!=", "nil", "{", "current", ":=", "st", ".", "context", "\n", "st", ".", "context", "=", "reflect", ".", "ValueOf", "(", "context", ")", "\n", "st", ".", "executeList", "(", "block", ".", "List", ")", "\n", "st", ".", "context", "=", "current", "\n", "}", "\n\n", "st", ".", "executeList", "(", "block", ".", "List", ")", "\n", "}" ]
// YieldBlock yields a block in the current context, will panic if the context is not available
[ "YieldBlock", "yields", "a", "block", "in", "the", "current", "context", "will", "panic", "if", "the", "context", "is", "not", "available" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/eval.go#L106-L121
train
CloudyKit/jet
eval.go
YieldTemplate
func (st *Runtime) YieldTemplate(name string, context interface{}) { t, err := st.set.GetTemplate(name) if err != nil { panic(fmt.Errorf("include: template %q was not found", name)) } st.newScope() st.blocks = t.processedBlocks Root := t.Root if t.extends != nil { Root = t.extends.Root } if context != nil { c := st.context st.context = reflect.ValueOf(context) st.executeList(Root) st.context = c } else { st.executeList(Root) } st.releaseScope() }
go
func (st *Runtime) YieldTemplate(name string, context interface{}) { t, err := st.set.GetTemplate(name) if err != nil { panic(fmt.Errorf("include: template %q was not found", name)) } st.newScope() st.blocks = t.processedBlocks Root := t.Root if t.extends != nil { Root = t.extends.Root } if context != nil { c := st.context st.context = reflect.ValueOf(context) st.executeList(Root) st.context = c } else { st.executeList(Root) } st.releaseScope() }
[ "func", "(", "st", "*", "Runtime", ")", "YieldTemplate", "(", "name", "string", ",", "context", "interface", "{", "}", ")", "{", "t", ",", "err", ":=", "st", ".", "set", ".", "GetTemplate", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", ")", "\n", "}", "\n\n", "st", ".", "newScope", "(", ")", "\n", "st", ".", "blocks", "=", "t", ".", "processedBlocks", "\n\n", "Root", ":=", "t", ".", "Root", "\n", "if", "t", ".", "extends", "!=", "nil", "{", "Root", "=", "t", ".", "extends", ".", "Root", "\n", "}", "\n\n", "if", "context", "!=", "nil", "{", "c", ":=", "st", ".", "context", "\n", "st", ".", "context", "=", "reflect", ".", "ValueOf", "(", "context", ")", "\n", "st", ".", "executeList", "(", "Root", ")", "\n", "st", ".", "context", "=", "c", "\n", "}", "else", "{", "st", ".", "executeList", "(", "Root", ")", "\n", "}", "\n\n", "st", ".", "releaseScope", "(", ")", "\n", "}" ]
// YieldTemplate yields a template same as include
[ "YieldTemplate", "yields", "a", "template", "same", "as", "include" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/eval.go#L133-L158
train
CloudyKit/jet
eval.go
Resolve
func (state *Runtime) Resolve(name string) reflect.Value { if name == "." { return state.context } sc := state.scope // try to resolve variables in the current scope vl, ok := sc.variables[name] // if not found walks parent scopes for !ok && sc.parent != nil { sc = sc.parent vl, ok = sc.variables[name] } // if not found check globals if !ok { state.set.gmx.RLock() vl, ok = state.set.globals[name] state.set.gmx.RUnlock() // not found check defaultVariables if !ok { vl, ok = defaultVariables[name] } } return vl }
go
func (state *Runtime) Resolve(name string) reflect.Value { if name == "." { return state.context } sc := state.scope // try to resolve variables in the current scope vl, ok := sc.variables[name] // if not found walks parent scopes for !ok && sc.parent != nil { sc = sc.parent vl, ok = sc.variables[name] } // if not found check globals if !ok { state.set.gmx.RLock() vl, ok = state.set.globals[name] state.set.gmx.RUnlock() // not found check defaultVariables if !ok { vl, ok = defaultVariables[name] } } return vl }
[ "func", "(", "state", "*", "Runtime", ")", "Resolve", "(", "name", "string", ")", "reflect", ".", "Value", "{", "if", "name", "==", "\"", "\"", "{", "return", "state", ".", "context", "\n", "}", "\n\n", "sc", ":=", "state", ".", "scope", "\n", "// try to resolve variables in the current scope", "vl", ",", "ok", ":=", "sc", ".", "variables", "[", "name", "]", "\n", "// if not found walks parent scopes", "for", "!", "ok", "&&", "sc", ".", "parent", "!=", "nil", "{", "sc", "=", "sc", ".", "parent", "\n", "vl", ",", "ok", "=", "sc", ".", "variables", "[", "name", "]", "\n", "}", "\n\n", "// if not found check globals", "if", "!", "ok", "{", "state", ".", "set", ".", "gmx", ".", "RLock", "(", ")", "\n", "vl", ",", "ok", "=", "state", ".", "set", ".", "globals", "[", "name", "]", "\n", "state", ".", "set", ".", "gmx", ".", "RUnlock", "(", ")", "\n", "// not found check defaultVariables", "if", "!", "ok", "{", "vl", ",", "ok", "=", "defaultVariables", "[", "name", "]", "\n", "}", "\n", "}", "\n", "return", "vl", "\n", "}" ]
// Resolve resolves a value from the execution context
[ "Resolve", "resolves", "a", "value", "from", "the", "execution", "context" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/eval.go#L195-L221
train
CloudyKit/jet
loaders/httpfs/loader.go
Open
func (l *httpFileSystemLoader) Open(name string) (io.ReadCloser, error) { if l.fs == nil { return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist} } return l.fs.Open(name) }
go
func (l *httpFileSystemLoader) Open(name string) (io.ReadCloser, error) { if l.fs == nil { return nil, &os.PathError{Op: "open", Path: name, Err: os.ErrNotExist} } return l.fs.Open(name) }
[ "func", "(", "l", "*", "httpFileSystemLoader", ")", "Open", "(", "name", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "if", "l", ".", "fs", "==", "nil", "{", "return", "nil", ",", "&", "os", ".", "PathError", "{", "Op", ":", "\"", "\"", ",", "Path", ":", "name", ",", "Err", ":", "os", ".", "ErrNotExist", "}", "\n", "}", "\n", "return", "l", ".", "fs", ".", "Open", "(", "name", ")", "\n", "}" ]
// Open opens the file via the internal http.FileSystem. It is the callers duty to close the file.
[ "Open", "opens", "the", "file", "via", "the", "internal", "http", ".", "FileSystem", ".", "It", "is", "the", "callers", "duty", "to", "close", "the", "file", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/loaders/httpfs/loader.go#L21-L26
train
CloudyKit/jet
template.go
AddGlobal
func (s *Set) AddGlobal(key string, i interface{}) *Set { s.gmx.Lock() if s.globals == nil { s.globals = make(VarMap) } s.globals[key] = reflect.ValueOf(i) s.gmx.Unlock() return s }
go
func (s *Set) AddGlobal(key string, i interface{}) *Set { s.gmx.Lock() if s.globals == nil { s.globals = make(VarMap) } s.globals[key] = reflect.ValueOf(i) s.gmx.Unlock() return s }
[ "func", "(", "s", "*", "Set", ")", "AddGlobal", "(", "key", "string", ",", "i", "interface", "{", "}", ")", "*", "Set", "{", "s", ".", "gmx", ".", "Lock", "(", ")", "\n", "if", "s", ".", "globals", "==", "nil", "{", "s", ".", "globals", "=", "make", "(", "VarMap", ")", "\n", "}", "\n", "s", ".", "globals", "[", "key", "]", "=", "reflect", ".", "ValueOf", "(", "i", ")", "\n", "s", ".", "gmx", ".", "Unlock", "(", ")", "\n", "return", "s", "\n", "}" ]
// AddGlobal add or set a global variable into the Set
[ "AddGlobal", "add", "or", "set", "a", "global", "variable", "into", "the", "Set" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/template.go#L62-L70
train
CloudyKit/jet
template.go
NewSetLoader
func NewSetLoader(escapee SafeWriter, loader Loader) *Set { return &Set{loader: loader, tmx: &sync.RWMutex{}, gmx: &sync.RWMutex{}, escapee: escapee, templates: make(map[string]*Template), defaultExtensions: append([]string{}, defaultExtensions...)} }
go
func NewSetLoader(escapee SafeWriter, loader Loader) *Set { return &Set{loader: loader, tmx: &sync.RWMutex{}, gmx: &sync.RWMutex{}, escapee: escapee, templates: make(map[string]*Template), defaultExtensions: append([]string{}, defaultExtensions...)} }
[ "func", "NewSetLoader", "(", "escapee", "SafeWriter", ",", "loader", "Loader", ")", "*", "Set", "{", "return", "&", "Set", "{", "loader", ":", "loader", ",", "tmx", ":", "&", "sync", ".", "RWMutex", "{", "}", ",", "gmx", ":", "&", "sync", ".", "RWMutex", "{", "}", ",", "escapee", ":", "escapee", ",", "templates", ":", "make", "(", "map", "[", "string", "]", "*", "Template", ")", ",", "defaultExtensions", ":", "append", "(", "[", "]", "string", "{", "}", ",", "defaultExtensions", "...", ")", "}", "\n", "}" ]
// NewSetLoader creates a new set with custom Loader
[ "NewSetLoader", "creates", "a", "new", "set", "with", "custom", "Loader" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/template.go#L77-L79
train
CloudyKit/jet
template.go
NewSet
func NewSet(escapee SafeWriter, dirs ...string) *Set { return NewSetLoader(escapee, &OSFileSystemLoader{dirs: dirs}) }
go
func NewSet(escapee SafeWriter, dirs ...string) *Set { return NewSetLoader(escapee, &OSFileSystemLoader{dirs: dirs}) }
[ "func", "NewSet", "(", "escapee", "SafeWriter", ",", "dirs", "...", "string", ")", "*", "Set", "{", "return", "NewSetLoader", "(", "escapee", ",", "&", "OSFileSystemLoader", "{", "dirs", ":", "dirs", "}", ")", "\n", "}" ]
// NewSet creates a new set, dirs is a list of directories to be searched for templates
[ "NewSet", "creates", "a", "new", "set", "dirs", "is", "a", "list", "of", "directories", "to", "be", "searched", "for", "templates" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/template.go#L87-L89
train
CloudyKit/jet
template.go
AddPath
func (s *Set) AddPath(path string) { if loader, ok := s.loader.(hasAddPath); ok { loader.AddPath(path) } else { panic(fmt.Sprintf("AddPath() not supported on custom loader of type %T", s.loader)) } }
go
func (s *Set) AddPath(path string) { if loader, ok := s.loader.(hasAddPath); ok { loader.AddPath(path) } else { panic(fmt.Sprintf("AddPath() not supported on custom loader of type %T", s.loader)) } }
[ "func", "(", "s", "*", "Set", ")", "AddPath", "(", "path", "string", ")", "{", "if", "loader", ",", "ok", ":=", "s", ".", "loader", ".", "(", "hasAddPath", ")", ";", "ok", "{", "loader", ".", "AddPath", "(", "path", ")", "\n", "}", "else", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "loader", ")", ")", "\n", "}", "\n", "}" ]
// AddPath add path to the lookup list, when loading a template the Set will // look into the lookup list for the file matching the provided name.
[ "AddPath", "add", "path", "to", "the", "lookup", "list", "when", "loading", "a", "template", "the", "Set", "will", "look", "into", "the", "lookup", "list", "for", "the", "file", "matching", "the", "provided", "name", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/template.go#L98-L104
train
CloudyKit/jet
template.go
AddGopathPath
func (s *Set) AddGopathPath(path string) { if loader, ok := s.loader.(hasAddGopathPath); ok { loader.AddGopathPath(path) } else { panic(fmt.Sprintf("AddGopathPath() not supported on custom loader of type %T", s.loader)) } }
go
func (s *Set) AddGopathPath(path string) { if loader, ok := s.loader.(hasAddGopathPath); ok { loader.AddGopathPath(path) } else { panic(fmt.Sprintf("AddGopathPath() not supported on custom loader of type %T", s.loader)) } }
[ "func", "(", "s", "*", "Set", ")", "AddGopathPath", "(", "path", "string", ")", "{", "if", "loader", ",", "ok", ":=", "s", ".", "loader", ".", "(", "hasAddGopathPath", ")", ";", "ok", "{", "loader", ".", "AddGopathPath", "(", "path", ")", "\n", "}", "else", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "loader", ")", ")", "\n", "}", "\n", "}" ]
// AddGopathPath add path based on GOPATH env to the lookup list, when loading a template the Set will // look into the lookup list for the file matching the provided name.
[ "AddGopathPath", "add", "path", "based", "on", "GOPATH", "env", "to", "the", "lookup", "list", "when", "loading", "a", "template", "the", "Set", "will", "look", "into", "the", "lookup", "list", "for", "the", "file", "matching", "the", "provided", "name", "." ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/template.go#L108-L114
train
CloudyKit/jet
template.go
Parse
func (s *Set) Parse(name, content string) (*Template, error) { sc := *s sc.developmentMode = true sc.tmx.RLock() t, err := sc.parse(name, content) sc.tmx.RUnlock() return t, err }
go
func (s *Set) Parse(name, content string) (*Template, error) { sc := *s sc.developmentMode = true sc.tmx.RLock() t, err := sc.parse(name, content) sc.tmx.RUnlock() return t, err }
[ "func", "(", "s", "*", "Set", ")", "Parse", "(", "name", ",", "content", "string", ")", "(", "*", "Template", ",", "error", ")", "{", "sc", ":=", "*", "s", "\n", "sc", ".", "developmentMode", "=", "true", "\n\n", "sc", ".", "tmx", ".", "RLock", "(", ")", "\n", "t", ",", "err", ":=", "sc", ".", "parse", "(", "name", ",", "content", ")", "\n", "sc", ".", "tmx", ".", "RUnlock", "(", ")", "\n\n", "return", "t", ",", "err", "\n", "}" ]
// Parse parses the template, this method will link the template to the set but not the set to
[ "Parse", "parses", "the", "template", "this", "method", "will", "link", "the", "template", "to", "the", "set", "but", "not", "the", "set", "to" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/template.go#L168-L177
train
CloudyKit/jet
template.go
getTemplate
func (s *Set) getTemplate(name, sibling string) (template *Template, err error) { name = path.Clean(name) if s.developmentMode { s.tmx.RLock() defer s.tmx.RUnlock() if newName, fileName, foundLoaded, foundFile, _ := s.resolveNameSibling(name, sibling); foundFile || foundLoaded { if foundFile { template, err = s.loadFromFile(newName, fileName) } else { template, _ = s.templates[newName] } } else { err = fmt.Errorf("template %s can't be loaded", name) } return } //fast path s.tmx.RLock() newName, fileName, foundLoaded, foundFile, isRelative := s.resolveNameSibling(name, sibling) if foundLoaded { template = s.templates[newName] s.tmx.RUnlock() if !isRelative && name != newName { // creates an alias s.tmx.Lock() if _, found := s.templates[name]; !found { s.templates[name] = template } s.tmx.Unlock() } return } s.tmx.RUnlock() //not found parses and cache s.tmx.Lock() defer s.tmx.Unlock() newName, fileName, foundLoaded, foundFile, isRelative = s.resolveNameSibling(name, sibling) if foundLoaded { template = s.templates[newName] if !isRelative && name != newName { // creates an alias if _, found := s.templates[name]; !found { s.templates[name] = template } } } else if foundFile { template, err = s.loadFromFile(newName, fileName) if !isRelative && name != newName { // creates an alias if _, found := s.templates[name]; !found { s.templates[name] = template } } s.templates[newName] = template } else { err = fmt.Errorf("template %s can't be loaded", name) } return }
go
func (s *Set) getTemplate(name, sibling string) (template *Template, err error) { name = path.Clean(name) if s.developmentMode { s.tmx.RLock() defer s.tmx.RUnlock() if newName, fileName, foundLoaded, foundFile, _ := s.resolveNameSibling(name, sibling); foundFile || foundLoaded { if foundFile { template, err = s.loadFromFile(newName, fileName) } else { template, _ = s.templates[newName] } } else { err = fmt.Errorf("template %s can't be loaded", name) } return } //fast path s.tmx.RLock() newName, fileName, foundLoaded, foundFile, isRelative := s.resolveNameSibling(name, sibling) if foundLoaded { template = s.templates[newName] s.tmx.RUnlock() if !isRelative && name != newName { // creates an alias s.tmx.Lock() if _, found := s.templates[name]; !found { s.templates[name] = template } s.tmx.Unlock() } return } s.tmx.RUnlock() //not found parses and cache s.tmx.Lock() defer s.tmx.Unlock() newName, fileName, foundLoaded, foundFile, isRelative = s.resolveNameSibling(name, sibling) if foundLoaded { template = s.templates[newName] if !isRelative && name != newName { // creates an alias if _, found := s.templates[name]; !found { s.templates[name] = template } } } else if foundFile { template, err = s.loadFromFile(newName, fileName) if !isRelative && name != newName { // creates an alias if _, found := s.templates[name]; !found { s.templates[name] = template } } s.templates[newName] = template } else { err = fmt.Errorf("template %s can't be loaded", name) } return }
[ "func", "(", "s", "*", "Set", ")", "getTemplate", "(", "name", ",", "sibling", "string", ")", "(", "template", "*", "Template", ",", "err", "error", ")", "{", "name", "=", "path", ".", "Clean", "(", "name", ")", "\n\n", "if", "s", ".", "developmentMode", "{", "s", ".", "tmx", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "tmx", ".", "RUnlock", "(", ")", "\n", "if", "newName", ",", "fileName", ",", "foundLoaded", ",", "foundFile", ",", "_", ":=", "s", ".", "resolveNameSibling", "(", "name", ",", "sibling", ")", ";", "foundFile", "||", "foundLoaded", "{", "if", "foundFile", "{", "template", ",", "err", "=", "s", ".", "loadFromFile", "(", "newName", ",", "fileName", ")", "\n", "}", "else", "{", "template", ",", "_", "=", "s", ".", "templates", "[", "newName", "]", "\n", "}", "\n", "}", "else", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "return", "\n", "}", "\n\n", "//fast path", "s", ".", "tmx", ".", "RLock", "(", ")", "\n", "newName", ",", "fileName", ",", "foundLoaded", ",", "foundFile", ",", "isRelative", ":=", "s", ".", "resolveNameSibling", "(", "name", ",", "sibling", ")", "\n\n", "if", "foundLoaded", "{", "template", "=", "s", ".", "templates", "[", "newName", "]", "\n", "s", ".", "tmx", ".", "RUnlock", "(", ")", "\n", "if", "!", "isRelative", "&&", "name", "!=", "newName", "{", "// creates an alias", "s", ".", "tmx", ".", "Lock", "(", ")", "\n", "if", "_", ",", "found", ":=", "s", ".", "templates", "[", "name", "]", ";", "!", "found", "{", "s", ".", "templates", "[", "name", "]", "=", "template", "\n", "}", "\n", "s", ".", "tmx", ".", "Unlock", "(", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "s", ".", "tmx", ".", "RUnlock", "(", ")", "\n\n", "//not found parses and cache", "s", ".", "tmx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "tmx", ".", "Unlock", "(", ")", "\n\n", "newName", ",", "fileName", ",", "foundLoaded", ",", "foundFile", ",", "isRelative", "=", "s", ".", "resolveNameSibling", "(", "name", ",", "sibling", ")", "\n", "if", "foundLoaded", "{", "template", "=", "s", ".", "templates", "[", "newName", "]", "\n", "if", "!", "isRelative", "&&", "name", "!=", "newName", "{", "// creates an alias", "if", "_", ",", "found", ":=", "s", ".", "templates", "[", "name", "]", ";", "!", "found", "{", "s", ".", "templates", "[", "name", "]", "=", "template", "\n", "}", "\n", "}", "\n", "}", "else", "if", "foundFile", "{", "template", ",", "err", "=", "s", ".", "loadFromFile", "(", "newName", ",", "fileName", ")", "\n\n", "if", "!", "isRelative", "&&", "name", "!=", "newName", "{", "// creates an alias", "if", "_", ",", "found", ":=", "s", ".", "templates", "[", "name", "]", ";", "!", "found", "{", "s", ".", "templates", "[", "name", "]", "=", "template", "\n", "}", "\n", "}", "\n\n", "s", ".", "templates", "[", "newName", "]", "=", "template", "\n", "}", "else", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "return", "\n", "}" ]
// getTemplate gets a template already loaded by name
[ "getTemplate", "gets", "a", "template", "already", "loaded", "by", "name" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/template.go#L222-L287
train
CloudyKit/jet
template.go
Execute
func (t *Template) Execute(w io.Writer, variables VarMap, data interface{}) error { return t.ExecuteI18N(nil, w, variables, data) }
go
func (t *Template) Execute(w io.Writer, variables VarMap, data interface{}) error { return t.ExecuteI18N(nil, w, variables, data) }
[ "func", "(", "t", "*", "Template", ")", "Execute", "(", "w", "io", ".", "Writer", ",", "variables", "VarMap", ",", "data", "interface", "{", "}", ")", "error", "{", "return", "t", ".", "ExecuteI18N", "(", "nil", ",", "w", ",", "variables", ",", "data", ")", "\n", "}" ]
// Execute executes the template in the w Writer
[ "Execute", "executes", "the", "template", "in", "the", "w", "Writer" ]
62edd43e4f88c6be452fd5feac77f716f546ebf6
https://github.com/CloudyKit/jet/blob/62edd43e4f88c6be452fd5feac77f716f546ebf6/template.go#L382-L384
train
Microsoft/hcsshim
internal/wclayer/createlayer.go
CreateLayer
func CreateLayer(path, parent string) (err error) { title := "hcsshim::CreateLayer" fields := logrus.Fields{ "parent": parent, "path": path, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() err = createLayer(&stdDriverInfo, path, parent) if err != nil { return hcserror.New(err, title+" - failed", "") } return nil }
go
func CreateLayer(path, parent string) (err error) { title := "hcsshim::CreateLayer" fields := logrus.Fields{ "parent": parent, "path": path, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() err = createLayer(&stdDriverInfo, path, parent) if err != nil { return hcserror.New(err, title+" - failed", "") } return nil }
[ "func", "CreateLayer", "(", "path", ",", "parent", "string", ")", "(", "err", "error", ")", "{", "title", ":=", "\"", "\"", "\n", "fields", ":=", "logrus", ".", "Fields", "{", "\"", "\"", ":", "parent", ",", "\"", "\"", ":", "path", ",", "}", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "fields", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Error", "(", "err", ")", "\n", "}", "else", "{", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "err", "=", "createLayer", "(", "&", "stdDriverInfo", ",", "path", ",", "parent", ")", "\n", "if", "err", "!=", "nil", "{", "return", "hcserror", ".", "New", "(", "err", ",", "title", "+", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// CreateLayer creates a new, empty, read-only layer on the filesystem based on // the parent layer provided.
[ "CreateLayer", "creates", "a", "new", "empty", "read", "-", "only", "layer", "on", "the", "filesystem", "based", "on", "the", "parent", "layer", "provided", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/createlayer.go#L10-L31
train
Microsoft/hcsshim
internal/mergemaps/merge.go
MergeJSON
func MergeJSON(object interface{}, additionalJSON []byte) (interface{}, error) { if len(additionalJSON) == 0 { return object, nil } objectJSON, err := json.Marshal(object) if err != nil { return nil, err } var objectMap, newMap map[string]interface{} err = json.Unmarshal(objectJSON, &objectMap) if err != nil { return nil, err } err = json.Unmarshal(additionalJSON, &newMap) if err != nil { return nil, err } return Merge(newMap, objectMap), nil }
go
func MergeJSON(object interface{}, additionalJSON []byte) (interface{}, error) { if len(additionalJSON) == 0 { return object, nil } objectJSON, err := json.Marshal(object) if err != nil { return nil, err } var objectMap, newMap map[string]interface{} err = json.Unmarshal(objectJSON, &objectMap) if err != nil { return nil, err } err = json.Unmarshal(additionalJSON, &newMap) if err != nil { return nil, err } return Merge(newMap, objectMap), nil }
[ "func", "MergeJSON", "(", "object", "interface", "{", "}", ",", "additionalJSON", "[", "]", "byte", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "len", "(", "additionalJSON", ")", "==", "0", "{", "return", "object", ",", "nil", "\n", "}", "\n", "objectJSON", ",", "err", ":=", "json", ".", "Marshal", "(", "object", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "objectMap", ",", "newMap", "map", "[", "string", "]", "interface", "{", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "objectJSON", ",", "&", "objectMap", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "additionalJSON", ",", "&", "newMap", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "Merge", "(", "newMap", ",", "objectMap", ")", ",", "nil", "\n", "}" ]
// MergeJSON merges the contents of a JSON string into an object representation, // returning a new object suitable for translating to JSON.
[ "MergeJSON", "merges", "the", "contents", "of", "a", "JSON", "string", "into", "an", "object", "representation", "returning", "a", "new", "object", "suitable", "for", "translating", "to", "JSON", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/mergemaps/merge.go#L34-L52
train
Microsoft/hcsshim
hnsnetwork.go
HNSListNetworkRequest
func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) { return hns.HNSListNetworkRequest(method, path, request) }
go
func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) { return hns.HNSListNetworkRequest(method, path, request) }
[ "func", "HNSListNetworkRequest", "(", "method", ",", "path", ",", "request", "string", ")", "(", "[", "]", "HNSNetwork", ",", "error", ")", "{", "return", "hns", ".", "HNSListNetworkRequest", "(", "method", ",", "path", ",", "request", ")", "\n", "}" ]
// HNSListNetworkRequest makes a HNS call to query the list of available networks
[ "HNSListNetworkRequest", "makes", "a", "HNS", "call", "to", "query", "the", "list", "of", "available", "networks" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hnsnetwork.go#L24-L26
train
Microsoft/hcsshim
internal/hcs/errors.go
IsTimeout
func IsTimeout(err error) bool { if err, ok := err.(net.Error); ok && err.Timeout() { return true } err = getInnerError(err) return err == ErrTimeout }
go
func IsTimeout(err error) bool { if err, ok := err.(net.Error); ok && err.Timeout() { return true } err = getInnerError(err) return err == ErrTimeout }
[ "func", "IsTimeout", "(", "err", "error", ")", "bool", "{", "if", "err", ",", "ok", ":=", "err", ".", "(", "net", ".", "Error", ")", ";", "ok", "&&", "err", ".", "Timeout", "(", ")", "{", "return", "true", "\n", "}", "\n", "err", "=", "getInnerError", "(", "err", ")", "\n", "return", "err", "==", "ErrTimeout", "\n", "}" ]
// IsTimeout returns a boolean indicating whether the error is caused by // a timeout waiting for the operation to complete.
[ "IsTimeout", "returns", "a", "boolean", "indicating", "whether", "the", "error", "is", "caused", "by", "a", "timeout", "waiting", "for", "the", "operation", "to", "complete", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hcs/errors.go#L281-L287
train
Microsoft/hcsshim
internal/wclayer/getsharedbaseimages.go
GetSharedBaseImages
func GetSharedBaseImages() (imageData string, err error) { title := "hcsshim::GetSharedBaseImages" logrus.Debug(title) defer func() { if err != nil { logrus.WithError(err).Error(err) } else { logrus.WithField("imageData", imageData).Debug(title + " - succeeded") } }() var buffer *uint16 err = getBaseImages(&buffer) if err != nil { return "", hcserror.New(err, title+" - failed", "") } return interop.ConvertAndFreeCoTaskMemString(buffer), nil }
go
func GetSharedBaseImages() (imageData string, err error) { title := "hcsshim::GetSharedBaseImages" logrus.Debug(title) defer func() { if err != nil { logrus.WithError(err).Error(err) } else { logrus.WithField("imageData", imageData).Debug(title + " - succeeded") } }() var buffer *uint16 err = getBaseImages(&buffer) if err != nil { return "", hcserror.New(err, title+" - failed", "") } return interop.ConvertAndFreeCoTaskMemString(buffer), nil }
[ "func", "GetSharedBaseImages", "(", ")", "(", "imageData", "string", ",", "err", "error", ")", "{", "title", ":=", "\"", "\"", "\n", "logrus", ".", "Debug", "(", "title", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "logrus", ".", "WithError", "(", "err", ")", ".", "Error", "(", "err", ")", "\n", "}", "else", "{", "logrus", ".", "WithField", "(", "\"", "\"", ",", "imageData", ")", ".", "Debug", "(", "title", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "var", "buffer", "*", "uint16", "\n", "err", "=", "getBaseImages", "(", "&", "buffer", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "hcserror", ".", "New", "(", "err", ",", "title", "+", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "interop", ".", "ConvertAndFreeCoTaskMemString", "(", "buffer", ")", ",", "nil", "\n", "}" ]
// GetSharedBaseImages will enumerate the images stored in the common central // image store and return descriptive info about those images for the purpose // of registering them with the graphdriver, graph, and tagstore.
[ "GetSharedBaseImages", "will", "enumerate", "the", "images", "stored", "in", "the", "common", "central", "image", "store", "and", "return", "descriptive", "info", "about", "those", "images", "for", "the", "purpose", "of", "registering", "them", "with", "the", "graphdriver", "graph", "and", "tagstore", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/getsharedbaseimages.go#L12-L29
train
Microsoft/hcsshim
container.go
CreateContainer
func CreateContainer(id string, c *ContainerConfig) (Container, error) { fullConfig, err := mergemaps.MergeJSON(c, createContainerAdditionalJSON) if err != nil { return nil, fmt.Errorf("failed to merge additional JSON '%s': %s", createContainerAdditionalJSON, err) } system, err := hcs.CreateComputeSystem(id, fullConfig) if err != nil { return nil, err } return &container{system: system}, err }
go
func CreateContainer(id string, c *ContainerConfig) (Container, error) { fullConfig, err := mergemaps.MergeJSON(c, createContainerAdditionalJSON) if err != nil { return nil, fmt.Errorf("failed to merge additional JSON '%s': %s", createContainerAdditionalJSON, err) } system, err := hcs.CreateComputeSystem(id, fullConfig) if err != nil { return nil, err } return &container{system: system}, err }
[ "func", "CreateContainer", "(", "id", "string", ",", "c", "*", "ContainerConfig", ")", "(", "Container", ",", "error", ")", "{", "fullConfig", ",", "err", ":=", "mergemaps", ".", "MergeJSON", "(", "c", ",", "createContainerAdditionalJSON", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "createContainerAdditionalJSON", ",", "err", ")", "\n", "}", "\n\n", "system", ",", "err", ":=", "hcs", ".", "CreateComputeSystem", "(", "id", ",", "fullConfig", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "container", "{", "system", ":", "system", "}", ",", "err", "\n", "}" ]
// CreateContainer creates a new container with the given configuration but does not start it.
[ "CreateContainer", "creates", "a", "new", "container", "with", "the", "given", "configuration", "but", "does", "not", "start", "it", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L72-L83
train
Microsoft/hcsshim
container.go
OpenContainer
func OpenContainer(id string) (Container, error) { system, err := hcs.OpenComputeSystem(id) if err != nil { return nil, err } return &container{system: system}, err }
go
func OpenContainer(id string) (Container, error) { system, err := hcs.OpenComputeSystem(id) if err != nil { return nil, err } return &container{system: system}, err }
[ "func", "OpenContainer", "(", "id", "string", ")", "(", "Container", ",", "error", ")", "{", "system", ",", "err", ":=", "hcs", ".", "OpenComputeSystem", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "container", "{", "system", ":", "system", "}", ",", "err", "\n", "}" ]
// OpenContainer opens an existing container by ID.
[ "OpenContainer", "opens", "an", "existing", "container", "by", "ID", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L86-L92
train
Microsoft/hcsshim
container.go
Wait
func (container *container) Wait() error { err := container.system.Wait() if err == nil { err = container.system.ExitError() } return convertSystemError(err, container) }
go
func (container *container) Wait() error { err := container.system.Wait() if err == nil { err = container.system.ExitError() } return convertSystemError(err, container) }
[ "func", "(", "container", "*", "container", ")", "Wait", "(", ")", "error", "{", "err", ":=", "container", ".", "system", ".", "Wait", "(", ")", "\n", "if", "err", "==", "nil", "{", "err", "=", "container", ".", "system", ".", "ExitError", "(", ")", "\n", "}", "\n", "return", "convertSystemError", "(", "err", ",", "container", ")", "\n", "}" ]
// Waits synchronously waits for the container to shutdown or terminate.
[ "Waits", "synchronously", "waits", "for", "the", "container", "to", "shutdown", "or", "terminate", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L123-L129
train
Microsoft/hcsshim
container.go
WaitTimeout
func (container *container) WaitTimeout(timeout time.Duration) error { container.waitOnce.Do(func() { container.waitCh = make(chan struct{}) go func() { container.waitErr = container.Wait() close(container.waitCh) }() }) t := time.NewTimer(timeout) defer t.Stop() select { case <-t.C: return &ContainerError{Container: container, Err: ErrTimeout, Operation: "hcsshim::ComputeSystem::Wait"} case <-container.waitCh: return container.waitErr } }
go
func (container *container) WaitTimeout(timeout time.Duration) error { container.waitOnce.Do(func() { container.waitCh = make(chan struct{}) go func() { container.waitErr = container.Wait() close(container.waitCh) }() }) t := time.NewTimer(timeout) defer t.Stop() select { case <-t.C: return &ContainerError{Container: container, Err: ErrTimeout, Operation: "hcsshim::ComputeSystem::Wait"} case <-container.waitCh: return container.waitErr } }
[ "func", "(", "container", "*", "container", ")", "WaitTimeout", "(", "timeout", "time", ".", "Duration", ")", "error", "{", "container", ".", "waitOnce", ".", "Do", "(", "func", "(", ")", "{", "container", ".", "waitCh", "=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "go", "func", "(", ")", "{", "container", ".", "waitErr", "=", "container", ".", "Wait", "(", ")", "\n", "close", "(", "container", ".", "waitCh", ")", "\n", "}", "(", ")", "\n", "}", ")", "\n", "t", ":=", "time", ".", "NewTimer", "(", "timeout", ")", "\n", "defer", "t", ".", "Stop", "(", ")", "\n", "select", "{", "case", "<-", "t", ".", "C", ":", "return", "&", "ContainerError", "{", "Container", ":", "container", ",", "Err", ":", "ErrTimeout", ",", "Operation", ":", "\"", "\"", "}", "\n", "case", "<-", "container", ".", "waitCh", ":", "return", "container", ".", "waitErr", "\n", "}", "\n", "}" ]
// WaitTimeout synchronously waits for the container to terminate or the duration to elapse. It // returns false if timeout occurs.
[ "WaitTimeout", "synchronously", "waits", "for", "the", "container", "to", "terminate", "or", "the", "duration", "to", "elapse", ".", "It", "returns", "false", "if", "timeout", "occurs", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L133-L149
train
Microsoft/hcsshim
container.go
Statistics
func (container *container) Statistics() (Statistics, error) { properties, err := container.system.Properties(schema1.PropertyTypeStatistics) if err != nil { return Statistics{}, convertSystemError(err, container) } return properties.Statistics, nil }
go
func (container *container) Statistics() (Statistics, error) { properties, err := container.system.Properties(schema1.PropertyTypeStatistics) if err != nil { return Statistics{}, convertSystemError(err, container) } return properties.Statistics, nil }
[ "func", "(", "container", "*", "container", ")", "Statistics", "(", ")", "(", "Statistics", ",", "error", ")", "{", "properties", ",", "err", ":=", "container", ".", "system", ".", "Properties", "(", "schema1", ".", "PropertyTypeStatistics", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Statistics", "{", "}", ",", "convertSystemError", "(", "err", ",", "container", ")", "\n", "}", "\n\n", "return", "properties", ".", "Statistics", ",", "nil", "\n", "}" ]
// Statistics returns statistics for the container. This is a legacy v1 call
[ "Statistics", "returns", "statistics", "for", "the", "container", ".", "This", "is", "a", "legacy", "v1", "call" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L167-L174
train
Microsoft/hcsshim
container.go
ProcessList
func (container *container) ProcessList() ([]ProcessListItem, error) { properties, err := container.system.Properties(schema1.PropertyTypeProcessList) if err != nil { return nil, convertSystemError(err, container) } return properties.ProcessList, nil }
go
func (container *container) ProcessList() ([]ProcessListItem, error) { properties, err := container.system.Properties(schema1.PropertyTypeProcessList) if err != nil { return nil, convertSystemError(err, container) } return properties.ProcessList, nil }
[ "func", "(", "container", "*", "container", ")", "ProcessList", "(", ")", "(", "[", "]", "ProcessListItem", ",", "error", ")", "{", "properties", ",", "err", ":=", "container", ".", "system", ".", "Properties", "(", "schema1", ".", "PropertyTypeProcessList", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "convertSystemError", "(", "err", ",", "container", ")", "\n", "}", "\n\n", "return", "properties", ".", "ProcessList", ",", "nil", "\n", "}" ]
// ProcessList returns an array of ProcessListItems for the container. This is a legacy v1 call
[ "ProcessList", "returns", "an", "array", "of", "ProcessListItems", "for", "the", "container", ".", "This", "is", "a", "legacy", "v1", "call" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L177-L184
train
Microsoft/hcsshim
container.go
MappedVirtualDisks
func (container *container) MappedVirtualDisks() (map[int]MappedVirtualDiskController, error) { properties, err := container.system.Properties(schema1.PropertyTypeMappedVirtualDisk) if err != nil { return nil, convertSystemError(err, container) } return properties.MappedVirtualDiskControllers, nil }
go
func (container *container) MappedVirtualDisks() (map[int]MappedVirtualDiskController, error) { properties, err := container.system.Properties(schema1.PropertyTypeMappedVirtualDisk) if err != nil { return nil, convertSystemError(err, container) } return properties.MappedVirtualDiskControllers, nil }
[ "func", "(", "container", "*", "container", ")", "MappedVirtualDisks", "(", ")", "(", "map", "[", "int", "]", "MappedVirtualDiskController", ",", "error", ")", "{", "properties", ",", "err", ":=", "container", ".", "system", ".", "Properties", "(", "schema1", ".", "PropertyTypeMappedVirtualDisk", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "convertSystemError", "(", "err", ",", "container", ")", "\n", "}", "\n\n", "return", "properties", ".", "MappedVirtualDiskControllers", ",", "nil", "\n", "}" ]
// This is a legacy v1 call
[ "This", "is", "a", "legacy", "v1", "call" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L187-L194
train
Microsoft/hcsshim
container.go
CreateProcess
func (container *container) CreateProcess(c *ProcessConfig) (Process, error) { p, err := container.system.CreateProcess(c) if err != nil { return nil, convertSystemError(err, container) } return &process{p: p}, nil }
go
func (container *container) CreateProcess(c *ProcessConfig) (Process, error) { p, err := container.system.CreateProcess(c) if err != nil { return nil, convertSystemError(err, container) } return &process{p: p}, nil }
[ "func", "(", "container", "*", "container", ")", "CreateProcess", "(", "c", "*", "ProcessConfig", ")", "(", "Process", ",", "error", ")", "{", "p", ",", "err", ":=", "container", ".", "system", ".", "CreateProcess", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "convertSystemError", "(", "err", ",", "container", ")", "\n", "}", "\n", "return", "&", "process", "{", "p", ":", "p", "}", ",", "nil", "\n", "}" ]
// CreateProcess launches a new process within the container.
[ "CreateProcess", "launches", "a", "new", "process", "within", "the", "container", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L197-L203
train
Microsoft/hcsshim
container.go
OpenProcess
func (container *container) OpenProcess(pid int) (Process, error) { p, err := container.system.OpenProcess(pid) if err != nil { return nil, convertSystemError(err, container) } return &process{p: p}, nil }
go
func (container *container) OpenProcess(pid int) (Process, error) { p, err := container.system.OpenProcess(pid) if err != nil { return nil, convertSystemError(err, container) } return &process{p: p}, nil }
[ "func", "(", "container", "*", "container", ")", "OpenProcess", "(", "pid", "int", ")", "(", "Process", ",", "error", ")", "{", "p", ",", "err", ":=", "container", ".", "system", ".", "OpenProcess", "(", "pid", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "convertSystemError", "(", "err", ",", "container", ")", "\n", "}", "\n", "return", "&", "process", "{", "p", ":", "p", "}", ",", "nil", "\n", "}" ]
// OpenProcess gets an interface to an existing process within the container.
[ "OpenProcess", "gets", "an", "interface", "to", "an", "existing", "process", "within", "the", "container", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L206-L212
train
Microsoft/hcsshim
container.go
Modify
func (container *container) Modify(config *ResourceModificationRequestResponse) error { return convertSystemError(container.system.Modify(config), container) }
go
func (container *container) Modify(config *ResourceModificationRequestResponse) error { return convertSystemError(container.system.Modify(config), container) }
[ "func", "(", "container", "*", "container", ")", "Modify", "(", "config", "*", "ResourceModificationRequestResponse", ")", "error", "{", "return", "convertSystemError", "(", "container", ".", "system", ".", "Modify", "(", "config", ")", ",", "container", ")", "\n", "}" ]
// Modify the System
[ "Modify", "the", "System" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/container.go#L220-L222
train
Microsoft/hcsshim
internal/wclayer/nametoguid.go
NameToGuid
func NameToGuid(name string) (id guid.GUID, err error) { title := "hcsshim::NameToGuid" fields := logrus.Fields{ "name": name, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() err = nameToGuid(name, &id) if err != nil { err = hcserror.New(err, title+" - failed", "") return } fields["guid"] = id.String() return }
go
func NameToGuid(name string) (id guid.GUID, err error) { title := "hcsshim::NameToGuid" fields := logrus.Fields{ "name": name, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() err = nameToGuid(name, &id) if err != nil { err = hcserror.New(err, title+" - failed", "") return } fields["guid"] = id.String() return }
[ "func", "NameToGuid", "(", "name", "string", ")", "(", "id", "guid", ".", "GUID", ",", "err", "error", ")", "{", "title", ":=", "\"", "\"", "\n", "fields", ":=", "logrus", ".", "Fields", "{", "\"", "\"", ":", "name", ",", "}", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "fields", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Error", "(", "err", ")", "\n", "}", "else", "{", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "err", "=", "nameToGuid", "(", "name", ",", "&", "id", ")", "\n", "if", "err", "!=", "nil", "{", "err", "=", "hcserror", ".", "New", "(", "err", ",", "title", "+", "\"", "\"", ",", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "fields", "[", "\"", "\"", "]", "=", "id", ".", "String", "(", ")", "\n", "return", "\n", "}" ]
// NameToGuid converts the given string into a GUID using the algorithm in the // Host Compute Service, ensuring GUIDs generated with the same string are common // across all clients.
[ "NameToGuid", "converts", "the", "given", "string", "into", "a", "GUID", "using", "the", "algorithm", "in", "the", "Host", "Compute", "Service", "ensuring", "GUIDs", "generated", "with", "the", "same", "string", "are", "common", "across", "all", "clients", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/nametoguid.go#L12-L34
train
Microsoft/hcsshim
internal/copyfile/copyfile.go
CopyFile
func CopyFile(srcFile, destFile string, overwrite bool) error { var bFailIfExists uint32 = 1 if overwrite { bFailIfExists = 0 } lpExistingFileName, err := syscall.UTF16PtrFromString(srcFile) if err != nil { return err } lpNewFileName, err := syscall.UTF16PtrFromString(destFile) if err != nil { return err } r1, _, err := syscall.Syscall( procCopyFileW.Addr(), 3, uintptr(unsafe.Pointer(lpExistingFileName)), uintptr(unsafe.Pointer(lpNewFileName)), uintptr(bFailIfExists)) if r1 == 0 { return fmt.Errorf("failed CopyFileW Win32 call from '%s' to '%s': %s", srcFile, destFile, err) } return nil }
go
func CopyFile(srcFile, destFile string, overwrite bool) error { var bFailIfExists uint32 = 1 if overwrite { bFailIfExists = 0 } lpExistingFileName, err := syscall.UTF16PtrFromString(srcFile) if err != nil { return err } lpNewFileName, err := syscall.UTF16PtrFromString(destFile) if err != nil { return err } r1, _, err := syscall.Syscall( procCopyFileW.Addr(), 3, uintptr(unsafe.Pointer(lpExistingFileName)), uintptr(unsafe.Pointer(lpNewFileName)), uintptr(bFailIfExists)) if r1 == 0 { return fmt.Errorf("failed CopyFileW Win32 call from '%s' to '%s': %s", srcFile, destFile, err) } return nil }
[ "func", "CopyFile", "(", "srcFile", ",", "destFile", "string", ",", "overwrite", "bool", ")", "error", "{", "var", "bFailIfExists", "uint32", "=", "1", "\n", "if", "overwrite", "{", "bFailIfExists", "=", "0", "\n", "}", "\n\n", "lpExistingFileName", ",", "err", ":=", "syscall", ".", "UTF16PtrFromString", "(", "srcFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "lpNewFileName", ",", "err", ":=", "syscall", ".", "UTF16PtrFromString", "(", "destFile", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "r1", ",", "_", ",", "err", ":=", "syscall", ".", "Syscall", "(", "procCopyFileW", ".", "Addr", "(", ")", ",", "3", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "lpExistingFileName", ")", ")", ",", "uintptr", "(", "unsafe", ".", "Pointer", "(", "lpNewFileName", ")", ")", ",", "uintptr", "(", "bFailIfExists", ")", ")", "\n", "if", "r1", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "srcFile", ",", "destFile", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// CopyFile is a utility for copying a file - used for the LCOW scratch cache. // Uses CopyFileW win32 API for performance.
[ "CopyFile", "is", "a", "utility", "for", "copying", "a", "file", "-", "used", "for", "the", "LCOW", "scratch", "cache", ".", "Uses", "CopyFileW", "win32", "API", "for", "performance", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/copyfile/copyfile.go#L16-L40
train
Microsoft/hcsshim
internal/wclayer/exportlayer.go
NewLayerReader
func NewLayerReader(path string, parentLayerPaths []string) (LayerReader, error) { exportPath, err := ioutil.TempDir("", "hcs") if err != nil { return nil, err } err = ExportLayer(path, exportPath, parentLayerPaths) if err != nil { os.RemoveAll(exportPath) return nil, err } return &legacyLayerReaderWrapper{newLegacyLayerReader(exportPath)}, nil }
go
func NewLayerReader(path string, parentLayerPaths []string) (LayerReader, error) { exportPath, err := ioutil.TempDir("", "hcs") if err != nil { return nil, err } err = ExportLayer(path, exportPath, parentLayerPaths) if err != nil { os.RemoveAll(exportPath) return nil, err } return &legacyLayerReaderWrapper{newLegacyLayerReader(exportPath)}, nil }
[ "func", "NewLayerReader", "(", "path", "string", ",", "parentLayerPaths", "[", "]", "string", ")", "(", "LayerReader", ",", "error", ")", "{", "exportPath", ",", "err", ":=", "ioutil", ".", "TempDir", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "err", "=", "ExportLayer", "(", "path", ",", "exportPath", ",", "parentLayerPaths", ")", "\n", "if", "err", "!=", "nil", "{", "os", ".", "RemoveAll", "(", "exportPath", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "legacyLayerReaderWrapper", "{", "newLegacyLayerReader", "(", "exportPath", ")", "}", ",", "nil", "\n", "}" ]
// NewLayerReader returns a new layer reader for reading the contents of an on-disk layer. // The caller must have taken the SeBackupPrivilege privilege // to call this and any methods on the resulting LayerReader.
[ "NewLayerReader", "returns", "a", "new", "layer", "reader", "for", "reading", "the", "contents", "of", "an", "on", "-", "disk", "layer", ".", "The", "caller", "must", "have", "taken", "the", "SeBackupPrivilege", "privilege", "to", "call", "this", "and", "any", "methods", "on", "the", "resulting", "LayerReader", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/exportlayer.go#L55-L66
train
Microsoft/hcsshim
cmd/containerd-shim-runhcs-v1/exec_hcs.go
waitForContainerExit
func (he *hcsExec) waitForContainerExit() { cexit := make(chan struct{}) go func() { he.c.Wait() close(cexit) }() select { case <-cexit: // Container exited first. We need to force the process into the exited // state and cleanup any resources he.sl.Lock() switch he.state { case shimExecStateCreated: he.exitFromCreatedL(1) case shimExecStateRunning: // Kill the process to unblock `he.waitForExit`. he.p.Kill() } he.sl.Unlock() case <-he.processDone: // Process exited first. This is the normal case do nothing because // `he.waitForExit` will release any waiters. } }
go
func (he *hcsExec) waitForContainerExit() { cexit := make(chan struct{}) go func() { he.c.Wait() close(cexit) }() select { case <-cexit: // Container exited first. We need to force the process into the exited // state and cleanup any resources he.sl.Lock() switch he.state { case shimExecStateCreated: he.exitFromCreatedL(1) case shimExecStateRunning: // Kill the process to unblock `he.waitForExit`. he.p.Kill() } he.sl.Unlock() case <-he.processDone: // Process exited first. This is the normal case do nothing because // `he.waitForExit` will release any waiters. } }
[ "func", "(", "he", "*", "hcsExec", ")", "waitForContainerExit", "(", ")", "{", "cexit", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "go", "func", "(", ")", "{", "he", ".", "c", ".", "Wait", "(", ")", "\n", "close", "(", "cexit", ")", "\n", "}", "(", ")", "\n", "select", "{", "case", "<-", "cexit", ":", "// Container exited first. We need to force the process into the exited", "// state and cleanup any resources", "he", ".", "sl", ".", "Lock", "(", ")", "\n", "switch", "he", ".", "state", "{", "case", "shimExecStateCreated", ":", "he", ".", "exitFromCreatedL", "(", "1", ")", "\n", "case", "shimExecStateRunning", ":", "// Kill the process to unblock `he.waitForExit`.", "he", ".", "p", ".", "Kill", "(", ")", "\n", "}", "\n", "he", ".", "sl", ".", "Unlock", "(", ")", "\n", "case", "<-", "he", ".", "processDone", ":", "// Process exited first. This is the normal case do nothing because", "// `he.waitForExit` will release any waiters.", "}", "\n", "}" ]
// waitForContainerExit waits for `he.c` to exit. Depending on the exec's state // will forcibly transition this exec to the exited state and unblock any // waiters. // // This MUST be called via a goroutine at exec create.
[ "waitForContainerExit", "waits", "for", "he", ".", "c", "to", "exit", ".", "Depending", "on", "the", "exec", "s", "state", "will", "forcibly", "transition", "this", "exec", "to", "the", "exited", "state", "and", "unblock", "any", "waiters", ".", "This", "MUST", "be", "called", "via", "a", "goroutine", "at", "exec", "create", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/cmd/containerd-shim-runhcs-v1/exec_hcs.go#L633-L656
train
Microsoft/hcsshim
cmd/containerd-shim-runhcs-v1/exec_hcs.go
escapeArgs
func escapeArgs(args []string) string { escapedArgs := make([]string, len(args)) for i, a := range args { escapedArgs[i] = windows.EscapeArg(a) } return strings.Join(escapedArgs, " ") }
go
func escapeArgs(args []string) string { escapedArgs := make([]string, len(args)) for i, a := range args { escapedArgs[i] = windows.EscapeArg(a) } return strings.Join(escapedArgs, " ") }
[ "func", "escapeArgs", "(", "args", "[", "]", "string", ")", "string", "{", "escapedArgs", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "args", ")", ")", "\n", "for", "i", ",", "a", ":=", "range", "args", "{", "escapedArgs", "[", "i", "]", "=", "windows", ".", "EscapeArg", "(", "a", ")", "\n", "}", "\n", "return", "strings", ".", "Join", "(", "escapedArgs", ",", "\"", "\"", ")", "\n", "}" ]
// escapeArgs makes a Windows-style escaped command line from a set of arguments
[ "escapeArgs", "makes", "a", "Windows", "-", "style", "escaped", "command", "line", "from", "a", "set", "of", "arguments" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/cmd/containerd-shim-runhcs-v1/exec_hcs.go#L659-L665
train
Microsoft/hcsshim
cmd/containerd-shim-runhcs-v1/serve.go
createEvent
func createEvent(event string) (windows.Handle, error) { ev, _ := windows.UTF16PtrFromString(event) sd, err := winio.SddlToSecurityDescriptor("D:P(A;;GA;;;BA)(A;;GA;;;SY)") if err != nil { return 0, errors.Wrapf(err, "failed to get security descriptor for event '%s'", event) } var sa windows.SecurityAttributes sa.Length = uint32(unsafe.Sizeof(sa)) sa.InheritHandle = 1 sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0])) h, err := windows.CreateEvent(&sa, 0, 0, ev) if h == 0 || err != nil { return 0, errors.Wrapf(err, "failed to create event '%s'", event) } return h, nil }
go
func createEvent(event string) (windows.Handle, error) { ev, _ := windows.UTF16PtrFromString(event) sd, err := winio.SddlToSecurityDescriptor("D:P(A;;GA;;;BA)(A;;GA;;;SY)") if err != nil { return 0, errors.Wrapf(err, "failed to get security descriptor for event '%s'", event) } var sa windows.SecurityAttributes sa.Length = uint32(unsafe.Sizeof(sa)) sa.InheritHandle = 1 sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0])) h, err := windows.CreateEvent(&sa, 0, 0, ev) if h == 0 || err != nil { return 0, errors.Wrapf(err, "failed to create event '%s'", event) } return h, nil }
[ "func", "createEvent", "(", "event", "string", ")", "(", "windows", ".", "Handle", ",", "error", ")", "{", "ev", ",", "_", ":=", "windows", ".", "UTF16PtrFromString", "(", "event", ")", "\n", "sd", ",", "err", ":=", "winio", ".", "SddlToSecurityDescriptor", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "event", ")", "\n", "}", "\n", "var", "sa", "windows", ".", "SecurityAttributes", "\n", "sa", ".", "Length", "=", "uint32", "(", "unsafe", ".", "Sizeof", "(", "sa", ")", ")", "\n", "sa", ".", "InheritHandle", "=", "1", "\n", "sa", ".", "SecurityDescriptor", "=", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "sd", "[", "0", "]", ")", ")", "\n", "h", ",", "err", ":=", "windows", ".", "CreateEvent", "(", "&", "sa", ",", "0", ",", "0", ",", "ev", ")", "\n", "if", "h", "==", "0", "||", "err", "!=", "nil", "{", "return", "0", ",", "errors", ".", "Wrapf", "(", "err", ",", "\"", "\"", ",", "event", ")", "\n", "}", "\n", "return", "h", ",", "nil", "\n", "}" ]
// createEvent creates a Windows event ACL'd to builtin administrator // and local system. Can use docker-signal to signal the event.
[ "createEvent", "creates", "a", "Windows", "event", "ACL", "d", "to", "builtin", "administrator", "and", "local", "system", ".", "Can", "use", "docker", "-", "signal", "to", "signal", "the", "event", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/cmd/containerd-shim-runhcs-v1/serve.go#L167-L182
train
Microsoft/hcsshim
cmd/containerd-shim-runhcs-v1/serve.go
setupDebuggerEvent
func setupDebuggerEvent() { if os.Getenv("CONTAINERD_SHIM_RUNHCS_V1_WAIT_DEBUGGER") == "" { return } event := "Global\\debugger-" + fmt.Sprint(os.Getpid()) handle, err := createEvent(event) if err != nil { return } logrus.Infof("Halting until %s is signalled", event) windows.WaitForSingleObject(handle, windows.INFINITE) return }
go
func setupDebuggerEvent() { if os.Getenv("CONTAINERD_SHIM_RUNHCS_V1_WAIT_DEBUGGER") == "" { return } event := "Global\\debugger-" + fmt.Sprint(os.Getpid()) handle, err := createEvent(event) if err != nil { return } logrus.Infof("Halting until %s is signalled", event) windows.WaitForSingleObject(handle, windows.INFINITE) return }
[ "func", "setupDebuggerEvent", "(", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "==", "\"", "\"", "{", "return", "\n", "}", "\n", "event", ":=", "\"", "\\\\", "\"", "+", "fmt", ".", "Sprint", "(", "os", ".", "Getpid", "(", ")", ")", "\n", "handle", ",", "err", ":=", "createEvent", "(", "event", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "logrus", ".", "Infof", "(", "\"", "\"", ",", "event", ")", "\n", "windows", ".", "WaitForSingleObject", "(", "handle", ",", "windows", ".", "INFINITE", ")", "\n", "return", "\n", "}" ]
// setupDebuggerEvent listens for an event to allow a debugger such as delve // to attach for advanced debugging. It's called when handling a ContainerCreate
[ "setupDebuggerEvent", "listens", "for", "an", "event", "to", "allow", "a", "debugger", "such", "as", "delve", "to", "attach", "for", "advanced", "debugging", ".", "It", "s", "called", "when", "handling", "a", "ContainerCreate" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/cmd/containerd-shim-runhcs-v1/serve.go#L186-L198
train
Microsoft/hcsshim
cmd/containerd-shim-runhcs-v1/serve.go
setupDumpStacks
func setupDumpStacks() { event := "Global\\stackdump-" + fmt.Sprint(os.Getpid()) handle, err := createEvent(event) if err != nil { return } go func() { for { windows.WaitForSingleObject(handle, windows.INFINITE) dumpStacks(true) } }() return }
go
func setupDumpStacks() { event := "Global\\stackdump-" + fmt.Sprint(os.Getpid()) handle, err := createEvent(event) if err != nil { return } go func() { for { windows.WaitForSingleObject(handle, windows.INFINITE) dumpStacks(true) } }() return }
[ "func", "setupDumpStacks", "(", ")", "{", "event", ":=", "\"", "\\\\", "\"", "+", "fmt", ".", "Sprint", "(", "os", ".", "Getpid", "(", ")", ")", "\n", "handle", ",", "err", ":=", "createEvent", "(", "event", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "go", "func", "(", ")", "{", "for", "{", "windows", ".", "WaitForSingleObject", "(", "handle", ",", "windows", ".", "INFINITE", ")", "\n", "dumpStacks", "(", "true", ")", "\n", "}", "\n", "}", "(", ")", "\n", "return", "\n", "}" ]
// setupDumpStacks listens for an event which when signalled dumps the // stacks from this process to the log output.
[ "setupDumpStacks", "listens", "for", "an", "event", "which", "when", "signalled", "dumps", "the", "stacks", "from", "this", "process", "to", "the", "log", "output", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/cmd/containerd-shim-runhcs-v1/serve.go#L202-L215
train
Microsoft/hcsshim
internal/runhcs/vm.go
IssueVMRequest
func IssueVMRequest(pipepath string, req *VMRequest) error { pipe, err := winio.DialPipe(pipepath, nil) if err != nil { return err } defer pipe.Close() if err := json.NewEncoder(pipe).Encode(req); err != nil { return err } if err := GetErrorFromPipe(pipe, nil); err != nil { return err } return nil }
go
func IssueVMRequest(pipepath string, req *VMRequest) error { pipe, err := winio.DialPipe(pipepath, nil) if err != nil { return err } defer pipe.Close() if err := json.NewEncoder(pipe).Encode(req); err != nil { return err } if err := GetErrorFromPipe(pipe, nil); err != nil { return err } return nil }
[ "func", "IssueVMRequest", "(", "pipepath", "string", ",", "req", "*", "VMRequest", ")", "error", "{", "pipe", ",", "err", ":=", "winio", ".", "DialPipe", "(", "pipepath", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "pipe", ".", "Close", "(", ")", "\n", "if", "err", ":=", "json", ".", "NewEncoder", "(", "pipe", ")", ".", "Encode", "(", "req", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=", "GetErrorFromPipe", "(", "pipe", ",", "nil", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// IssueVMRequest issues a request to a shim at the given pipe.
[ "IssueVMRequest", "issues", "a", "request", "to", "a", "shim", "at", "the", "given", "pipe", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/runhcs/vm.go#L30-L43
train
Microsoft/hcsshim
internal/copywithtimeout/copywithtimeout.go
Copy
func Copy(dst io.Writer, src io.Reader, size int64, context string, timeout time.Duration) (int64, error) { logrus.WithFields(logrus.Fields{ "stdval": context, "size": size, "timeout": timeout, }).Debug("hcsshim::copywithtimeout - Begin") type resultType struct { err error bytes int64 } done := make(chan resultType, 1) go func() { result := resultType{} if logrus.GetLevel() < logrus.DebugLevel || logDataByteCount == 0 { result.bytes, result.err = io.Copy(dst, src) } else { // In advanced debug mode where we log (hexdump format) what is copied // up to the number of bytes defined by environment variable // HCSSHIM_LOG_DATA_BYTE_COUNT var buf bytes.Buffer tee := io.TeeReader(src, &buf) result.bytes, result.err = io.Copy(dst, tee) if result.err == nil { size := result.bytes if size > logDataByteCount { size = logDataByteCount } if size > 0 { bytes := make([]byte, size) if _, err := buf.Read(bytes); err == nil { logrus.Debugf("hcsshim::copyWithTimeout - Read bytes\n%s", hex.Dump(bytes)) } } } } done <- result }() var result resultType timedout := time.After(timeout) select { case <-timedout: return 0, fmt.Errorf("hcsshim::copyWithTimeout: timed out (%s)", context) case result = <-done: if result.err != nil && result.err != io.EOF { // See https://github.com/golang/go/blob/f3f29d1dea525f48995c1693c609f5e67c046893/src/os/exec/exec_windows.go for a clue as to why we are doing this :) if se, ok := result.err.(syscall.Errno); ok { const ( errNoData = syscall.Errno(232) errBrokenPipe = syscall.Errno(109) ) if se == errNoData || se == errBrokenPipe { logrus.WithFields(logrus.Fields{ "stdval": context, logrus.ErrorKey: se, }).Debug("hcsshim::copywithtimeout - End") return result.bytes, nil } } return 0, fmt.Errorf("hcsshim::copyWithTimeout: error reading: '%s' after %d bytes (%s)", result.err, result.bytes, context) } } logrus.WithFields(logrus.Fields{ "stdval": context, "copied-bytes": result.bytes, }).Debug("hcsshim::copywithtimeout - Completed Successfully") return result.bytes, nil }
go
func Copy(dst io.Writer, src io.Reader, size int64, context string, timeout time.Duration) (int64, error) { logrus.WithFields(logrus.Fields{ "stdval": context, "size": size, "timeout": timeout, }).Debug("hcsshim::copywithtimeout - Begin") type resultType struct { err error bytes int64 } done := make(chan resultType, 1) go func() { result := resultType{} if logrus.GetLevel() < logrus.DebugLevel || logDataByteCount == 0 { result.bytes, result.err = io.Copy(dst, src) } else { // In advanced debug mode where we log (hexdump format) what is copied // up to the number of bytes defined by environment variable // HCSSHIM_LOG_DATA_BYTE_COUNT var buf bytes.Buffer tee := io.TeeReader(src, &buf) result.bytes, result.err = io.Copy(dst, tee) if result.err == nil { size := result.bytes if size > logDataByteCount { size = logDataByteCount } if size > 0 { bytes := make([]byte, size) if _, err := buf.Read(bytes); err == nil { logrus.Debugf("hcsshim::copyWithTimeout - Read bytes\n%s", hex.Dump(bytes)) } } } } done <- result }() var result resultType timedout := time.After(timeout) select { case <-timedout: return 0, fmt.Errorf("hcsshim::copyWithTimeout: timed out (%s)", context) case result = <-done: if result.err != nil && result.err != io.EOF { // See https://github.com/golang/go/blob/f3f29d1dea525f48995c1693c609f5e67c046893/src/os/exec/exec_windows.go for a clue as to why we are doing this :) if se, ok := result.err.(syscall.Errno); ok { const ( errNoData = syscall.Errno(232) errBrokenPipe = syscall.Errno(109) ) if se == errNoData || se == errBrokenPipe { logrus.WithFields(logrus.Fields{ "stdval": context, logrus.ErrorKey: se, }).Debug("hcsshim::copywithtimeout - End") return result.bytes, nil } } return 0, fmt.Errorf("hcsshim::copyWithTimeout: error reading: '%s' after %d bytes (%s)", result.err, result.bytes, context) } } logrus.WithFields(logrus.Fields{ "stdval": context, "copied-bytes": result.bytes, }).Debug("hcsshim::copywithtimeout - Completed Successfully") return result.bytes, nil }
[ "func", "Copy", "(", "dst", "io", ".", "Writer", ",", "src", "io", ".", "Reader", ",", "size", "int64", ",", "context", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "int64", ",", "error", ")", "{", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "context", ",", "\"", "\"", ":", "size", ",", "\"", "\"", ":", "timeout", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "type", "resultType", "struct", "{", "err", "error", "\n", "bytes", "int64", "\n", "}", "\n\n", "done", ":=", "make", "(", "chan", "resultType", ",", "1", ")", "\n", "go", "func", "(", ")", "{", "result", ":=", "resultType", "{", "}", "\n", "if", "logrus", ".", "GetLevel", "(", ")", "<", "logrus", ".", "DebugLevel", "||", "logDataByteCount", "==", "0", "{", "result", ".", "bytes", ",", "result", ".", "err", "=", "io", ".", "Copy", "(", "dst", ",", "src", ")", "\n", "}", "else", "{", "// In advanced debug mode where we log (hexdump format) what is copied", "// up to the number of bytes defined by environment variable", "// HCSSHIM_LOG_DATA_BYTE_COUNT", "var", "buf", "bytes", ".", "Buffer", "\n", "tee", ":=", "io", ".", "TeeReader", "(", "src", ",", "&", "buf", ")", "\n", "result", ".", "bytes", ",", "result", ".", "err", "=", "io", ".", "Copy", "(", "dst", ",", "tee", ")", "\n", "if", "result", ".", "err", "==", "nil", "{", "size", ":=", "result", ".", "bytes", "\n", "if", "size", ">", "logDataByteCount", "{", "size", "=", "logDataByteCount", "\n", "}", "\n", "if", "size", ">", "0", "{", "bytes", ":=", "make", "(", "[", "]", "byte", ",", "size", ")", "\n", "if", "_", ",", "err", ":=", "buf", ".", "Read", "(", "bytes", ")", ";", "err", "==", "nil", "{", "logrus", ".", "Debugf", "(", "\"", "\\n", "\"", ",", "hex", ".", "Dump", "(", "bytes", ")", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "done", "<-", "result", "\n", "}", "(", ")", "\n\n", "var", "result", "resultType", "\n", "timedout", ":=", "time", ".", "After", "(", "timeout", ")", "\n\n", "select", "{", "case", "<-", "timedout", ":", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "context", ")", "\n", "case", "result", "=", "<-", "done", ":", "if", "result", ".", "err", "!=", "nil", "&&", "result", ".", "err", "!=", "io", ".", "EOF", "{", "// See https://github.com/golang/go/blob/f3f29d1dea525f48995c1693c609f5e67c046893/src/os/exec/exec_windows.go for a clue as to why we are doing this :)", "if", "se", ",", "ok", ":=", "result", ".", "err", ".", "(", "syscall", ".", "Errno", ")", ";", "ok", "{", "const", "(", "errNoData", "=", "syscall", ".", "Errno", "(", "232", ")", "\n", "errBrokenPipe", "=", "syscall", ".", "Errno", "(", "109", ")", "\n", ")", "\n", "if", "se", "==", "errNoData", "||", "se", "==", "errBrokenPipe", "{", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "context", ",", "logrus", ".", "ErrorKey", ":", "se", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "result", ".", "bytes", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "result", ".", "err", ",", "result", ".", "bytes", ",", "context", ")", "\n", "}", "\n", "}", "\n", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "context", ",", "\"", "\"", ":", "result", ".", "bytes", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "result", ".", "bytes", ",", "nil", "\n", "}" ]
// Copy is a wrapper for io.Copy using a timeout duration
[ "Copy", "is", "a", "wrapper", "for", "io", ".", "Copy", "using", "a", "timeout", "duration" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/copywithtimeout/copywithtimeout.go#L33-L103
train
Microsoft/hcsshim
internal/uvm/vsmb.go
findVSMBShare
func (uvm *UtilityVM) findVSMBShare(hostPath string) (*vsmbShare, error) { share, ok := uvm.vsmbShares[hostPath] if !ok { return nil, ErrNotAttached } logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, "name": share.name, "refCount": share.refCount, }).Debug("uvm::findVSMBShare") return share, nil }
go
func (uvm *UtilityVM) findVSMBShare(hostPath string) (*vsmbShare, error) { share, ok := uvm.vsmbShares[hostPath] if !ok { return nil, ErrNotAttached } logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, "name": share.name, "refCount": share.refCount, }).Debug("uvm::findVSMBShare") return share, nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "findVSMBShare", "(", "hostPath", "string", ")", "(", "*", "vsmbShare", ",", "error", ")", "{", "share", ",", "ok", ":=", "uvm", ".", "vsmbShares", "[", "hostPath", "]", "\n", "if", "!", "ok", "{", "return", "nil", ",", "ErrNotAttached", "\n", "}", "\n", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "hostPath", ",", "\"", "\"", ":", "share", ".", "name", ",", "\"", "\"", ":", "share", ".", "refCount", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "share", ",", "nil", "\n", "}" ]
// findVSMBShare finds a share by `hostPath`. If not found returns `ErrNotAttached`.
[ "findVSMBShare", "finds", "a", "share", "by", "hostPath", ".", "If", "not", "found", "returns", "ErrNotAttached", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/vsmb.go#L14-L26
train
Microsoft/hcsshim
internal/uvm/vsmb.go
AddVSMB
func (uvm *UtilityVM) AddVSMB(hostPath string, guestRequest interface{}, options *hcsschema.VirtualSmbShareOptions) (err error) { op := "uvm::AddVSMB" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, }) log.Debugf(op+" - GuestRequest: %+v, Options: %+v - Begin Operation", guestRequest, options) defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "windows" { return errNotSupported } uvm.m.Lock() defer uvm.m.Unlock() share, err := uvm.findVSMBShare(hostPath) if err == ErrNotAttached { uvm.vsmbCounter++ shareName := "s" + strconv.FormatUint(uvm.vsmbCounter, 16) modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Add, Settings: hcsschema.VirtualSmbShare{ Name: shareName, Options: options, Path: hostPath, }, ResourcePath: "VirtualMachine/Devices/VirtualSmb/Shares", } if err := uvm.Modify(modification); err != nil { return err } share = &vsmbShare{ name: shareName, guestRequest: guestRequest, } uvm.vsmbShares[hostPath] = share } share.refCount++ return nil }
go
func (uvm *UtilityVM) AddVSMB(hostPath string, guestRequest interface{}, options *hcsschema.VirtualSmbShareOptions) (err error) { op := "uvm::AddVSMB" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, }) log.Debugf(op+" - GuestRequest: %+v, Options: %+v - Begin Operation", guestRequest, options) defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "windows" { return errNotSupported } uvm.m.Lock() defer uvm.m.Unlock() share, err := uvm.findVSMBShare(hostPath) if err == ErrNotAttached { uvm.vsmbCounter++ shareName := "s" + strconv.FormatUint(uvm.vsmbCounter, 16) modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Add, Settings: hcsschema.VirtualSmbShare{ Name: shareName, Options: options, Path: hostPath, }, ResourcePath: "VirtualMachine/Devices/VirtualSmb/Shares", } if err := uvm.Modify(modification); err != nil { return err } share = &vsmbShare{ name: shareName, guestRequest: guestRequest, } uvm.vsmbShares[hostPath] = share } share.refCount++ return nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "AddVSMB", "(", "hostPath", "string", ",", "guestRequest", "interface", "{", "}", ",", "options", "*", "hcsschema", ".", "VirtualSmbShareOptions", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "hostPath", ",", "}", ")", "\n", "log", ".", "Debugf", "(", "op", "+", "\"", "\"", ",", "guestRequest", ",", "options", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "if", "uvm", ".", "operatingSystem", "!=", "\"", "\"", "{", "return", "errNotSupported", "\n", "}", "\n\n", "uvm", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "uvm", ".", "m", ".", "Unlock", "(", ")", "\n", "share", ",", "err", ":=", "uvm", ".", "findVSMBShare", "(", "hostPath", ")", "\n", "if", "err", "==", "ErrNotAttached", "{", "uvm", ".", "vsmbCounter", "++", "\n", "shareName", ":=", "\"", "\"", "+", "strconv", ".", "FormatUint", "(", "uvm", ".", "vsmbCounter", ",", "16", ")", "\n\n", "modification", ":=", "&", "hcsschema", ".", "ModifySettingRequest", "{", "RequestType", ":", "requesttype", ".", "Add", ",", "Settings", ":", "hcsschema", ".", "VirtualSmbShare", "{", "Name", ":", "shareName", ",", "Options", ":", "options", ",", "Path", ":", "hostPath", ",", "}", ",", "ResourcePath", ":", "\"", "\"", ",", "}", "\n\n", "if", "err", ":=", "uvm", ".", "Modify", "(", "modification", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "share", "=", "&", "vsmbShare", "{", "name", ":", "shareName", ",", "guestRequest", ":", "guestRequest", ",", "}", "\n", "uvm", ".", "vsmbShares", "[", "hostPath", "]", "=", "share", "\n", "}", "\n", "share", ".", "refCount", "++", "\n", "return", "nil", "\n", "}" ]
// AddVSMB adds a VSMB share to a Windows utility VM. Each VSMB share is ref-counted and // only added if it isn't already. This is used for read-only layers, mapped directories // to a container, and for mapped pipes.
[ "AddVSMB", "adds", "a", "VSMB", "share", "to", "a", "Windows", "utility", "VM", ".", "Each", "VSMB", "share", "is", "ref", "-", "counted", "and", "only", "added", "if", "it", "isn", "t", "already", ".", "This", "is", "used", "for", "read", "-", "only", "layers", "mapped", "directories", "to", "a", "container", "and", "for", "mapped", "pipes", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/vsmb.go#L35-L83
train
Microsoft/hcsshim
internal/uvm/vsmb.go
RemoveVSMB
func (uvm *UtilityVM) RemoveVSMB(hostPath string) (err error) { op := "uvm::RemoveVSMB" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "windows" { return errNotSupported } uvm.m.Lock() defer uvm.m.Unlock() share, err := uvm.findVSMBShare(hostPath) if err != nil { return fmt.Errorf("%s is not present as a VSMB share in %s, cannot remove", hostPath, uvm.id) } share.refCount-- if share.refCount > 0 { return nil } modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Remove, Settings: hcsschema.VirtualSmbShare{Name: share.name}, ResourcePath: "VirtualMachine/Devices/VirtualSmb/Shares", } if err := uvm.Modify(modification); err != nil { return fmt.Errorf("failed to remove vsmb share %s from %s: %+v: %s", hostPath, uvm.id, modification, err) } delete(uvm.vsmbShares, hostPath) return nil }
go
func (uvm *UtilityVM) RemoveVSMB(hostPath string) (err error) { op := "uvm::RemoveVSMB" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if uvm.operatingSystem != "windows" { return errNotSupported } uvm.m.Lock() defer uvm.m.Unlock() share, err := uvm.findVSMBShare(hostPath) if err != nil { return fmt.Errorf("%s is not present as a VSMB share in %s, cannot remove", hostPath, uvm.id) } share.refCount-- if share.refCount > 0 { return nil } modification := &hcsschema.ModifySettingRequest{ RequestType: requesttype.Remove, Settings: hcsschema.VirtualSmbShare{Name: share.name}, ResourcePath: "VirtualMachine/Devices/VirtualSmb/Shares", } if err := uvm.Modify(modification); err != nil { return fmt.Errorf("failed to remove vsmb share %s from %s: %+v: %s", hostPath, uvm.id, modification, err) } delete(uvm.vsmbShares, hostPath) return nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "RemoveVSMB", "(", "hostPath", "string", ")", "(", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "hostPath", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "if", "uvm", ".", "operatingSystem", "!=", "\"", "\"", "{", "return", "errNotSupported", "\n", "}", "\n\n", "uvm", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "uvm", ".", "m", ".", "Unlock", "(", ")", "\n", "share", ",", "err", ":=", "uvm", ".", "findVSMBShare", "(", "hostPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "hostPath", ",", "uvm", ".", "id", ")", "\n", "}", "\n\n", "share", ".", "refCount", "--", "\n", "if", "share", ".", "refCount", ">", "0", "{", "return", "nil", "\n", "}", "\n\n", "modification", ":=", "&", "hcsschema", ".", "ModifySettingRequest", "{", "RequestType", ":", "requesttype", ".", "Remove", ",", "Settings", ":", "hcsschema", ".", "VirtualSmbShare", "{", "Name", ":", "share", ".", "name", "}", ",", "ResourcePath", ":", "\"", "\"", ",", "}", "\n", "if", "err", ":=", "uvm", ".", "Modify", "(", "modification", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "hostPath", ",", "uvm", ".", "id", ",", "modification", ",", "err", ")", "\n", "}", "\n\n", "delete", "(", "uvm", ".", "vsmbShares", ",", "hostPath", ")", "\n", "return", "nil", "\n", "}" ]
// RemoveVSMB removes a VSMB share from a utility VM. Each VSMB share is ref-counted // and only actually removed when the ref-count drops to zero.
[ "RemoveVSMB", "removes", "a", "VSMB", "share", "from", "a", "utility", "VM", ".", "Each", "VSMB", "share", "is", "ref", "-", "counted", "and", "only", "actually", "removed", "when", "the", "ref", "-", "count", "drops", "to", "zero", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/vsmb.go#L87-L130
train
Microsoft/hcsshim
internal/uvm/vsmb.go
GetVSMBUvmPath
func (uvm *UtilityVM) GetVSMBUvmPath(hostPath string) (_ string, err error) { op := "uvm::GetVSMBUvmPath" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if hostPath == "" { return "", fmt.Errorf("no hostPath passed to GetVSMBUvmPath") } uvm.m.Lock() defer uvm.m.Unlock() share, err := uvm.findVSMBShare(hostPath) if err != nil { return "", err } path := share.GuestPath() return path, nil }
go
func (uvm *UtilityVM) GetVSMBUvmPath(hostPath string) (_ string, err error) { op := "uvm::GetVSMBUvmPath" log := logrus.WithFields(logrus.Fields{ logfields.UVMID: uvm.id, "host-path": hostPath, }) log.Debug(op + " - Begin Operation") defer func() { if err != nil { log.Data[logrus.ErrorKey] = err log.Error(op + " - End Operation - Error") } else { log.Debug(op + " - End Operation - Success") } }() if hostPath == "" { return "", fmt.Errorf("no hostPath passed to GetVSMBUvmPath") } uvm.m.Lock() defer uvm.m.Unlock() share, err := uvm.findVSMBShare(hostPath) if err != nil { return "", err } path := share.GuestPath() return path, nil }
[ "func", "(", "uvm", "*", "UtilityVM", ")", "GetVSMBUvmPath", "(", "hostPath", "string", ")", "(", "_", "string", ",", "err", "error", ")", "{", "op", ":=", "\"", "\"", "\n", "log", ":=", "logrus", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "UVMID", ":", "uvm", ".", "id", ",", "\"", "\"", ":", "hostPath", ",", "}", ")", "\n", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "log", ".", "Data", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "log", ".", "Error", "(", "op", "+", "\"", "\"", ")", "\n", "}", "else", "{", "log", ".", "Debug", "(", "op", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "if", "hostPath", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "uvm", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "uvm", ".", "m", ".", "Unlock", "(", ")", "\n", "share", ",", "err", ":=", "uvm", ".", "findVSMBShare", "(", "hostPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "path", ":=", "share", ".", "GuestPath", "(", ")", "\n", "return", "path", ",", "nil", "\n", "}" ]
// GetVSMBUvmPath returns the guest path of a VSMB mount.
[ "GetVSMBUvmPath", "returns", "the", "guest", "path", "of", "a", "VSMB", "mount", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/uvm/vsmb.go#L133-L160
train
Microsoft/hcsshim
internal/wclayer/layerexists.go
LayerExists
func LayerExists(path string) (_ bool, err error) { title := "hcsshim::LayerExists" fields := logrus.Fields{ "path": path, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() // Call the procedure itself. var exists uint32 err = layerExists(&stdDriverInfo, path, &exists) if err != nil { return false, hcserror.New(err, title+" - failed", "") } fields["layer-exists"] = exists != 0 return exists != 0, nil }
go
func LayerExists(path string) (_ bool, err error) { title := "hcsshim::LayerExists" fields := logrus.Fields{ "path": path, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() // Call the procedure itself. var exists uint32 err = layerExists(&stdDriverInfo, path, &exists) if err != nil { return false, hcserror.New(err, title+" - failed", "") } fields["layer-exists"] = exists != 0 return exists != 0, nil }
[ "func", "LayerExists", "(", "path", "string", ")", "(", "_", "bool", ",", "err", "error", ")", "{", "title", ":=", "\"", "\"", "\n", "fields", ":=", "logrus", ".", "Fields", "{", "\"", "\"", ":", "path", ",", "}", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "fields", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Error", "(", "err", ")", "\n", "}", "else", "{", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "// Call the procedure itself.", "var", "exists", "uint32", "\n", "err", "=", "layerExists", "(", "&", "stdDriverInfo", ",", "path", ",", "&", "exists", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "hcserror", ".", "New", "(", "err", ",", "title", "+", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "fields", "[", "\"", "\"", "]", "=", "exists", "!=", "0", "\n", "return", "exists", "!=", "0", ",", "nil", "\n", "}" ]
// LayerExists will return true if a layer with the given id exists and is known // to the system.
[ "LayerExists", "will", "return", "true", "if", "a", "layer", "with", "the", "given", "id", "exists", "and", "is", "known", "to", "the", "system", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/layerexists.go#L10-L33
train
Microsoft/hcsshim
internal/wclayer/getlayermountpath.go
GetLayerMountPath
func GetLayerMountPath(path string) (_ string, err error) { title := "hcsshim::GetLayerMountPath" fields := logrus.Fields{ "path": path, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() var mountPathLength uintptr mountPathLength = 0 // Call the procedure itself. logrus.WithFields(fields).Debug("Calling proc (1)") err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, nil) if err != nil { return "", hcserror.New(err, title+" - failed", "(first call)") } // Allocate a mount path of the returned length. if mountPathLength == 0 { return "", nil } mountPathp := make([]uint16, mountPathLength) mountPathp[0] = 0 // Call the procedure again logrus.WithFields(fields).Debug("Calling proc (2)") err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, &mountPathp[0]) if err != nil { return "", hcserror.New(err, title+" - failed", "(second call)") } mountPath := syscall.UTF16ToString(mountPathp[0:]) fields["mountPath"] = mountPath return mountPath, nil }
go
func GetLayerMountPath(path string) (_ string, err error) { title := "hcsshim::GetLayerMountPath" fields := logrus.Fields{ "path": path, } logrus.WithFields(fields).Debug(title) defer func() { if err != nil { fields[logrus.ErrorKey] = err logrus.WithFields(fields).Error(err) } else { logrus.WithFields(fields).Debug(title + " - succeeded") } }() var mountPathLength uintptr mountPathLength = 0 // Call the procedure itself. logrus.WithFields(fields).Debug("Calling proc (1)") err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, nil) if err != nil { return "", hcserror.New(err, title+" - failed", "(first call)") } // Allocate a mount path of the returned length. if mountPathLength == 0 { return "", nil } mountPathp := make([]uint16, mountPathLength) mountPathp[0] = 0 // Call the procedure again logrus.WithFields(fields).Debug("Calling proc (2)") err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, &mountPathp[0]) if err != nil { return "", hcserror.New(err, title+" - failed", "(second call)") } mountPath := syscall.UTF16ToString(mountPathp[0:]) fields["mountPath"] = mountPath return mountPath, nil }
[ "func", "GetLayerMountPath", "(", "path", "string", ")", "(", "_", "string", ",", "err", "error", ")", "{", "title", ":=", "\"", "\"", "\n", "fields", ":=", "logrus", ".", "Fields", "{", "\"", "\"", ":", "path", ",", "}", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", ")", "\n", "defer", "func", "(", ")", "{", "if", "err", "!=", "nil", "{", "fields", "[", "logrus", ".", "ErrorKey", "]", "=", "err", "\n", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Error", "(", "err", ")", "\n", "}", "else", "{", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "title", "+", "\"", "\"", ")", "\n", "}", "\n", "}", "(", ")", "\n\n", "var", "mountPathLength", "uintptr", "\n", "mountPathLength", "=", "0", "\n\n", "// Call the procedure itself.", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "err", "=", "getLayerMountPath", "(", "&", "stdDriverInfo", ",", "path", ",", "&", "mountPathLength", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "hcserror", ".", "New", "(", "err", ",", "title", "+", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// Allocate a mount path of the returned length.", "if", "mountPathLength", "==", "0", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n", "mountPathp", ":=", "make", "(", "[", "]", "uint16", ",", "mountPathLength", ")", "\n", "mountPathp", "[", "0", "]", "=", "0", "\n\n", "// Call the procedure again", "logrus", ".", "WithFields", "(", "fields", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "err", "=", "getLayerMountPath", "(", "&", "stdDriverInfo", ",", "path", ",", "&", "mountPathLength", ",", "&", "mountPathp", "[", "0", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "hcserror", ".", "New", "(", "err", ",", "title", "+", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n\n", "mountPath", ":=", "syscall", ".", "UTF16ToString", "(", "mountPathp", "[", "0", ":", "]", ")", "\n", "fields", "[", "\"", "\"", "]", "=", "mountPath", "\n", "return", "mountPath", ",", "nil", "\n", "}" ]
// GetLayerMountPath will look for a mounted layer with the given path and return // the path at which that layer can be accessed. This path may be a volume path // if the layer is a mounted read-write layer, otherwise it is expected to be the // folder path at which the layer is stored.
[ "GetLayerMountPath", "will", "look", "for", "a", "mounted", "layer", "with", "the", "given", "path", "and", "return", "the", "path", "at", "which", "that", "layer", "can", "be", "accessed", ".", "This", "path", "may", "be", "a", "volume", "path", "if", "the", "layer", "is", "a", "mounted", "read", "-", "write", "layer", "otherwise", "it", "is", "expected", "to", "be", "the", "folder", "path", "at", "which", "the", "layer", "is", "stored", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/wclayer/getlayermountpath.go#L14-L56
train
Microsoft/hcsshim
hnsendpoint.go
HotAttachEndpoint
func HotAttachEndpoint(containerID string, endpointID string) error { endpoint, err := GetHNSEndpointByID(endpointID) isAttached, err := endpoint.IsAttached(containerID) if isAttached { return err } return modifyNetworkEndpoint(containerID, endpointID, Add) }
go
func HotAttachEndpoint(containerID string, endpointID string) error { endpoint, err := GetHNSEndpointByID(endpointID) isAttached, err := endpoint.IsAttached(containerID) if isAttached { return err } return modifyNetworkEndpoint(containerID, endpointID, Add) }
[ "func", "HotAttachEndpoint", "(", "containerID", "string", ",", "endpointID", "string", ")", "error", "{", "endpoint", ",", "err", ":=", "GetHNSEndpointByID", "(", "endpointID", ")", "\n", "isAttached", ",", "err", ":=", "endpoint", ".", "IsAttached", "(", "containerID", ")", "\n", "if", "isAttached", "{", "return", "err", "\n", "}", "\n", "return", "modifyNetworkEndpoint", "(", "containerID", ",", "endpointID", ",", "Add", ")", "\n", "}" ]
// HotAttachEndpoint makes a HCS Call to attach the endpoint to the container
[ "HotAttachEndpoint", "makes", "a", "HCS", "Call", "to", "attach", "the", "endpoint", "to", "the", "container" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hnsendpoint.go#L41-L48
train
Microsoft/hcsshim
hnsendpoint.go
HotDetachEndpoint
func HotDetachEndpoint(containerID string, endpointID string) error { endpoint, err := GetHNSEndpointByID(endpointID) isAttached, err := endpoint.IsAttached(containerID) if !isAttached { return err } return modifyNetworkEndpoint(containerID, endpointID, Remove) }
go
func HotDetachEndpoint(containerID string, endpointID string) error { endpoint, err := GetHNSEndpointByID(endpointID) isAttached, err := endpoint.IsAttached(containerID) if !isAttached { return err } return modifyNetworkEndpoint(containerID, endpointID, Remove) }
[ "func", "HotDetachEndpoint", "(", "containerID", "string", ",", "endpointID", "string", ")", "error", "{", "endpoint", ",", "err", ":=", "GetHNSEndpointByID", "(", "endpointID", ")", "\n", "isAttached", ",", "err", ":=", "endpoint", ".", "IsAttached", "(", "containerID", ")", "\n", "if", "!", "isAttached", "{", "return", "err", "\n", "}", "\n", "return", "modifyNetworkEndpoint", "(", "containerID", ",", "endpointID", ",", "Remove", ")", "\n", "}" ]
// HotDetachEndpoint makes a HCS Call to detach the endpoint from the container
[ "HotDetachEndpoint", "makes", "a", "HCS", "Call", "to", "detach", "the", "endpoint", "from", "the", "container" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hnsendpoint.go#L51-L58
train
Microsoft/hcsshim
hnsendpoint.go
modifyContainer
func modifyContainer(id string, request *ResourceModificationRequestResponse) error { container, err := OpenContainer(id) if err != nil { if IsNotExist(err) { return ErrComputeSystemDoesNotExist } return getInnerError(err) } defer container.Close() err = container.Modify(request) if err != nil { if IsNotSupported(err) { return ErrPlatformNotSupported } return getInnerError(err) } return nil }
go
func modifyContainer(id string, request *ResourceModificationRequestResponse) error { container, err := OpenContainer(id) if err != nil { if IsNotExist(err) { return ErrComputeSystemDoesNotExist } return getInnerError(err) } defer container.Close() err = container.Modify(request) if err != nil { if IsNotSupported(err) { return ErrPlatformNotSupported } return getInnerError(err) } return nil }
[ "func", "modifyContainer", "(", "id", "string", ",", "request", "*", "ResourceModificationRequestResponse", ")", "error", "{", "container", ",", "err", ":=", "OpenContainer", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "if", "IsNotExist", "(", "err", ")", "{", "return", "ErrComputeSystemDoesNotExist", "\n", "}", "\n", "return", "getInnerError", "(", "err", ")", "\n", "}", "\n", "defer", "container", ".", "Close", "(", ")", "\n", "err", "=", "container", ".", "Modify", "(", "request", ")", "\n", "if", "err", "!=", "nil", "{", "if", "IsNotSupported", "(", "err", ")", "{", "return", "ErrPlatformNotSupported", "\n", "}", "\n", "return", "getInnerError", "(", "err", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// ModifyContainer corresponding to the container id, by sending a request
[ "ModifyContainer", "corresponding", "to", "the", "container", "id", "by", "sending", "a", "request" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/hnsendpoint.go#L61-L79
train
Microsoft/hcsshim
internal/ospath/join.go
Join
func Join(os string, elem ...string) string { if os == "windows" { return filepath.Join(elem...) } return path.Join(elem...) }
go
func Join(os string, elem ...string) string { if os == "windows" { return filepath.Join(elem...) } return path.Join(elem...) }
[ "func", "Join", "(", "os", "string", ",", "elem", "...", "string", ")", "string", "{", "if", "os", "==", "\"", "\"", "{", "return", "filepath", ".", "Join", "(", "elem", "...", ")", "\n", "}", "\n", "return", "path", ".", "Join", "(", "elem", "...", ")", "\n", "}" ]
// Join joins paths using the target OS's path separator.
[ "Join", "joins", "paths", "using", "the", "target", "OS", "s", "path", "separator", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/ospath/join.go#L9-L14
train
Microsoft/hcsshim
internal/hns/hnspolicylist.go
HNSListPolicyListRequest
func HNSListPolicyListRequest() ([]PolicyList, error) { var plist []PolicyList err := hnsCall("GET", "/policylists/", "", &plist) if err != nil { return nil, err } return plist, nil }
go
func HNSListPolicyListRequest() ([]PolicyList, error) { var plist []PolicyList err := hnsCall("GET", "/policylists/", "", &plist) if err != nil { return nil, err } return plist, nil }
[ "func", "HNSListPolicyListRequest", "(", ")", "(", "[", "]", "PolicyList", ",", "error", ")", "{", "var", "plist", "[", "]", "PolicyList", "\n", "err", ":=", "hnsCall", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "&", "plist", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "plist", ",", "nil", "\n", "}" ]
// HNSListPolicyListRequest gets all the policy list
[ "HNSListPolicyListRequest", "gets", "all", "the", "policy", "list" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnspolicylist.go#L53-L61
train
Microsoft/hcsshim
internal/hns/hnspolicylist.go
Create
func (policylist *PolicyList) Create() (*PolicyList, error) { operation := "Create" title := "hcsshim::PolicyList::" + operation logrus.Debugf(title+" id=%s", policylist.ID) jsonString, err := json.Marshal(policylist) if err != nil { return nil, err } return PolicyListRequest("POST", "", string(jsonString)) }
go
func (policylist *PolicyList) Create() (*PolicyList, error) { operation := "Create" title := "hcsshim::PolicyList::" + operation logrus.Debugf(title+" id=%s", policylist.ID) jsonString, err := json.Marshal(policylist) if err != nil { return nil, err } return PolicyListRequest("POST", "", string(jsonString)) }
[ "func", "(", "policylist", "*", "PolicyList", ")", "Create", "(", ")", "(", "*", "PolicyList", ",", "error", ")", "{", "operation", ":=", "\"", "\"", "\n", "title", ":=", "\"", "\"", "+", "operation", "\n", "logrus", ".", "Debugf", "(", "title", "+", "\"", "\"", ",", "policylist", ".", "ID", ")", "\n", "jsonString", ",", "err", ":=", "json", ".", "Marshal", "(", "policylist", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "PolicyListRequest", "(", "\"", "\"", ",", "\"", "\"", ",", "string", "(", "jsonString", ")", ")", "\n", "}" ]
// Create PolicyList by sending PolicyListRequest to HNS.
[ "Create", "PolicyList", "by", "sending", "PolicyListRequest", "to", "HNS", "." ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnspolicylist.go#L80-L89
train
Microsoft/hcsshim
internal/hns/hnspolicylist.go
Delete
func (policylist *PolicyList) Delete() (*PolicyList, error) { operation := "Delete" title := "hcsshim::PolicyList::" + operation logrus.Debugf(title+" id=%s", policylist.ID) return PolicyListRequest("DELETE", policylist.ID, "") }
go
func (policylist *PolicyList) Delete() (*PolicyList, error) { operation := "Delete" title := "hcsshim::PolicyList::" + operation logrus.Debugf(title+" id=%s", policylist.ID) return PolicyListRequest("DELETE", policylist.ID, "") }
[ "func", "(", "policylist", "*", "PolicyList", ")", "Delete", "(", ")", "(", "*", "PolicyList", ",", "error", ")", "{", "operation", ":=", "\"", "\"", "\n", "title", ":=", "\"", "\"", "+", "operation", "\n", "logrus", ".", "Debugf", "(", "title", "+", "\"", "\"", ",", "policylist", ".", "ID", ")", "\n\n", "return", "PolicyListRequest", "(", "\"", "\"", ",", "policylist", ".", "ID", ",", "\"", "\"", ")", "\n", "}" ]
// Delete deletes PolicyList
[ "Delete", "deletes", "PolicyList" ]
5a7443890943600c562e1f2390ab3fef8c56a45f
https://github.com/Microsoft/hcsshim/blob/5a7443890943600c562e1f2390ab3fef8c56a45f/internal/hns/hnspolicylist.go#L92-L98
train