_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3 values | text stringlengths 52 85.5k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q7200 | ImageCreate | train | func (m *MockImageAPIClient) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) {
ret := m.ctrl.Call(m, "ImageCreate", ctx, parentReference, options)
ret0, _ := ret[0].(io.ReadCloser)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7201 | ImageHistory | train | func (m *MockImageAPIClient) ImageHistory(ctx context.Context, image string) ([]imagepkg.HistoryResponseItem, error) {
ret := m.ctrl.Call(m, "ImageHistory", ctx, image)
ret0, _ := ret[0].([]imagepkg.HistoryResponseItem)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7202 | ImageList | train | func (m *MockImageAPIClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) {
ret := m.ctrl.Call(m, "ImageList", ctx, options)
ret0, _ := ret[0].([]types.ImageSummary)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7203 | ImageLoad | train | func (m *MockImageAPIClient) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) {
ret := m.ctrl.Call(m, "ImageLoad", ctx, input, quiet)
ret0, _ := ret[0].(types.ImageLoadResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7204 | ImageRemove | train | func (m *MockImageAPIClient) ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) {
ret := m.ctrl.Call(m, "ImageRemove", ctx, image, options)
ret0, _ := ret[0].([]types.ImageDeleteResponseItem)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7205 | ImageSearch | train | func (m *MockImageAPIClient) ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error) {
ret := m.ctrl.Call(m, "ImageSearch", ctx, term, options)
ret0, _ := ret[0].([]registry.SearchResult)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7206 | ImageSearch | train | func (mr *MockImageAPIClientMockRecorder) ImageSearch(ctx, term, options interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImageSearch", reflect.TypeOf((*MockImageAPIClient)(nil).ImageSearch), ctx, term, options)
} | go | {
"resource": ""
} |
q7207 | ImageSave | train | func (mr *MockImageAPIClientMockRecorder) ImageSave(ctx, images interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImageSave", reflect.TypeOf((*MockImageAPIClient)(nil).ImageSave), ctx, images)
} | go | {
"resource": ""
} |
q7208 | ImagesPrune | train | func (mr *MockImageAPIClientMockRecorder) ImagesPrune(ctx, pruneFilter interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImagesPrune", reflect.TypeOf((*MockImageAPIClient)(nil).ImagesPrune), ctx, pruneFilter)
} | go | {
"resource": ""
} |
q7209 | NewMockNetworkAPIClient | train | func NewMockNetworkAPIClient(ctrl *gomock.Controller) *MockNetworkAPIClient {
mock := &MockNetworkAPIClient{ctrl: ctrl}
mock.recorder = &MockNetworkAPIClientMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7210 | NetworkConnect | train | func (mr *MockNetworkAPIClientMockRecorder) NetworkConnect(ctx, networkID, container, config interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkConnect", reflect.TypeOf((*MockNetworkAPIClient)(nil).NetworkConnect), ctx, networkID, container, config)
} | go | {
"resource": ""
} |
q7211 | NetworkCreate | train | func (mr *MockNetworkAPIClientMockRecorder) NetworkCreate(ctx, name, options interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkCreate", reflect.TypeOf((*MockNetworkAPIClient)(nil).NetworkCreate), ctx, name, options)
} | go | {
"resource": ""
} |
q7212 | NetworkInspect | train | func (m *MockNetworkAPIClient) NetworkInspect(ctx context.Context, networkID string, verbose bool) (types.NetworkResource, error) {
ret := m.ctrl.Call(m, "NetworkInspect", ctx, networkID, verbose)
ret0, _ := ret[0].(types.NetworkResource)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7213 | NetworkInspect | train | func (mr *MockNetworkAPIClientMockRecorder) NetworkInspect(ctx, networkID, verbose interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkInspect", reflect.TypeOf((*MockNetworkAPIClient)(nil).NetworkInspect), ctx, networkID, verbose)
} | go | {
"resource": ""
} |
q7214 | NetworksPrune | train | func (mr *MockNetworkAPIClientMockRecorder) NetworksPrune(ctx, pruneFilter interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworksPrune", reflect.TypeOf((*MockNetworkAPIClient)(nil).NetworksPrune), ctx, pruneFilter)
} | go | {
"resource": ""
} |
q7215 | NewMockNodeAPIClient | train | func NewMockNodeAPIClient(ctrl *gomock.Controller) *MockNodeAPIClient {
mock := &MockNodeAPIClient{ctrl: ctrl}
mock.recorder = &MockNodeAPIClientMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7216 | NodeRemove | train | func (m *MockNodeAPIClient) NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error {
ret := m.ctrl.Call(m, "NodeRemove", ctx, nodeID, options)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7217 | NodeRemove | train | func (mr *MockNodeAPIClientMockRecorder) NodeRemove(ctx, nodeID, options interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NodeRemove", reflect.TypeOf((*MockNodeAPIClient)(nil).NodeRemove), ctx, nodeID, options)
} | go | {
"resource": ""
} |
q7218 | NodeUpdate | train | func (m *MockNodeAPIClient) NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error {
ret := m.ctrl.Call(m, "NodeUpdate", ctx, nodeID, version, node)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7219 | NewMockPluginAPIClient | train | func NewMockPluginAPIClient(ctrl *gomock.Controller) *MockPluginAPIClient {
mock := &MockPluginAPIClient{ctrl: ctrl}
mock.recorder = &MockPluginAPIClientMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7220 | PluginList | train | func (mr *MockPluginAPIClientMockRecorder) PluginList(ctx, filter interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PluginList", reflect.TypeOf((*MockPluginAPIClient)(nil).PluginList), ctx, filter)
} | go | {
"resource": ""
} |
q7221 | PluginRemove | train | func (m *MockPluginAPIClient) PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error {
ret := m.ctrl.Call(m, "PluginRemove", ctx, name, options)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7222 | PluginRemove | train | func (mr *MockPluginAPIClientMockRecorder) PluginRemove(ctx, name, options interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PluginRemove", reflect.TypeOf((*MockPluginAPIClient)(nil).PluginRemove), ctx, name, options)
} | go | {
"resource": ""
} |
q7223 | PluginEnable | train | func (m *MockPluginAPIClient) PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error {
ret := m.ctrl.Call(m, "PluginEnable", ctx, name, options)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7224 | PluginDisable | train | func (m *MockPluginAPIClient) PluginDisable(ctx context.Context, name string, options types.PluginDisableOptions) error {
ret := m.ctrl.Call(m, "PluginDisable", ctx, name, options)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7225 | PluginPush | train | func (m *MockPluginAPIClient) PluginPush(ctx context.Context, name, registryAuth string) (io.ReadCloser, error) {
ret := m.ctrl.Call(m, "PluginPush", ctx, name, registryAuth)
ret0, _ := ret[0].(io.ReadCloser)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7226 | PluginSet | train | func (m *MockPluginAPIClient) PluginSet(ctx context.Context, name string, args []string) error {
ret := m.ctrl.Call(m, "PluginSet", ctx, name, args)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7227 | PluginCreate | train | func (m *MockPluginAPIClient) PluginCreate(ctx context.Context, createContext io.Reader, options types.PluginCreateOptions) error {
ret := m.ctrl.Call(m, "PluginCreate", ctx, createContext, options)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7228 | PluginCreate | train | func (mr *MockPluginAPIClientMockRecorder) PluginCreate(ctx, createContext, options interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PluginCreate", reflect.TypeOf((*MockPluginAPIClient)(nil).PluginCreate), ctx, createContext, options)
} | go | {
"resource": ""
} |
q7229 | NewMockServiceAPIClient | train | func NewMockServiceAPIClient(ctrl *gomock.Controller) *MockServiceAPIClient {
mock := &MockServiceAPIClient{ctrl: ctrl}
mock.recorder = &MockServiceAPIClientMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7230 | ServiceCreate | train | func (m *MockServiceAPIClient) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) {
ret := m.ctrl.Call(m, "ServiceCreate", ctx, service, options)
ret0, _ := ret[0].(types.ServiceCreateResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7231 | ServiceInspectWithRaw | train | func (m *MockServiceAPIClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) {
ret := m.ctrl.Call(m, "ServiceInspectWithRaw", ctx, serviceID, options)
ret0, _ := ret[0].(swarm.Service)
ret1, _ := ret[1].([]byte)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
} | go | {
"resource": ""
} |
q7232 | ServiceList | train | func (mr *MockServiceAPIClientMockRecorder) ServiceList(ctx, options interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ServiceList", reflect.TypeOf((*MockServiceAPIClient)(nil).ServiceList), ctx, options)
} | go | {
"resource": ""
} |
q7233 | ServiceUpdate | train | func (m *MockServiceAPIClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) {
ret := m.ctrl.Call(m, "ServiceUpdate", ctx, serviceID, version, service, options)
ret0, _ := ret[0].(types.ServiceUpdateResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7234 | ServiceLogs | train | func (m *MockServiceAPIClient) ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error) {
ret := m.ctrl.Call(m, "ServiceLogs", ctx, serviceID, options)
ret0, _ := ret[0].(io.ReadCloser)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7235 | TaskList | train | func (m *MockServiceAPIClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
ret := m.ctrl.Call(m, "TaskList", ctx, options)
ret0, _ := ret[0].([]swarm.Task)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7236 | NewMockSwarmAPIClient | train | func NewMockSwarmAPIClient(ctrl *gomock.Controller) *MockSwarmAPIClient {
mock := &MockSwarmAPIClient{ctrl: ctrl}
mock.recorder = &MockSwarmAPIClientMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7237 | SwarmInit | train | func (m *MockSwarmAPIClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
ret := m.ctrl.Call(m, "SwarmInit", ctx, req)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7238 | SwarmInit | train | func (mr *MockSwarmAPIClientMockRecorder) SwarmInit(ctx, req interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SwarmInit", reflect.TypeOf((*MockSwarmAPIClient)(nil).SwarmInit), ctx, req)
} | go | {
"resource": ""
} |
q7239 | SwarmLeave | train | func (m *MockSwarmAPIClient) SwarmLeave(ctx context.Context, force bool) error {
ret := m.ctrl.Call(m, "SwarmLeave", ctx, force)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7240 | NewMockSystemAPIClient | train | func NewMockSystemAPIClient(ctrl *gomock.Controller) *MockSystemAPIClient {
mock := &MockSystemAPIClient{ctrl: ctrl}
mock.recorder = &MockSystemAPIClientMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7241 | Events | train | func (mr *MockSystemAPIClientMockRecorder) Events(ctx, options interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Events", reflect.TypeOf((*MockSystemAPIClient)(nil).Events), ctx, options)
} | go | {
"resource": ""
} |
q7242 | NewMockVolumeAPIClient | train | func NewMockVolumeAPIClient(ctrl *gomock.Controller) *MockVolumeAPIClient {
mock := &MockVolumeAPIClient{ctrl: ctrl}
mock.recorder = &MockVolumeAPIClientMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7243 | VolumeCreate | train | func (mr *MockVolumeAPIClientMockRecorder) VolumeCreate(ctx, options interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VolumeCreate", reflect.TypeOf((*MockVolumeAPIClient)(nil).VolumeCreate), ctx, options)
} | go | {
"resource": ""
} |
q7244 | VolumeInspectWithRaw | train | func (m *MockVolumeAPIClient) VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error) {
ret := m.ctrl.Call(m, "VolumeInspectWithRaw", ctx, volumeID)
ret0, _ := ret[0].(types.Volume)
ret1, _ := ret[1].([]byte)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
} | go | {
"resource": ""
} |
q7245 | VolumeInspectWithRaw | train | func (mr *MockVolumeAPIClientMockRecorder) VolumeInspectWithRaw(ctx, volumeID interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VolumeInspectWithRaw", reflect.TypeOf((*MockVolumeAPIClient)(nil).VolumeInspectWithRaw), ctx, volumeID)
} | go | {
"resource": ""
} |
q7246 | VolumeList | train | func (m *MockVolumeAPIClient) VolumeList(ctx context.Context, filter filters.Args) (volume.VolumesListOKBody, error) {
ret := m.ctrl.Call(m, "VolumeList", ctx, filter)
ret0, _ := ret[0].(volume.VolumesListOKBody)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7247 | VolumeList | train | func (mr *MockVolumeAPIClientMockRecorder) VolumeList(ctx, filter interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VolumeList", reflect.TypeOf((*MockVolumeAPIClient)(nil).VolumeList), ctx, filter)
} | go | {
"resource": ""
} |
q7248 | VolumesPrune | train | func (mr *MockVolumeAPIClientMockRecorder) VolumesPrune(ctx, pruneFilter interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VolumesPrune", reflect.TypeOf((*MockVolumeAPIClient)(nil).VolumesPrune), ctx, pruneFilter)
} | go | {
"resource": ""
} |
q7249 | NewMockSecretAPIClient | train | func NewMockSecretAPIClient(ctrl *gomock.Controller) *MockSecretAPIClient {
mock := &MockSecretAPIClient{ctrl: ctrl}
mock.recorder = &MockSecretAPIClientMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7250 | SecretList | train | func (m *MockSecretAPIClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
ret := m.ctrl.Call(m, "SecretList", ctx, options)
ret0, _ := ret[0].([]swarm.Secret)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7251 | SecretList | train | func (mr *MockSecretAPIClientMockRecorder) SecretList(ctx, options interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SecretList", reflect.TypeOf((*MockSecretAPIClient)(nil).SecretList), ctx, options)
} | go | {
"resource": ""
} |
q7252 | SecretCreate | train | func (m *MockSecretAPIClient) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error) {
ret := m.ctrl.Call(m, "SecretCreate", ctx, secret)
ret0, _ := ret[0].(types.SecretCreateResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q7253 | SecretCreate | train | func (mr *MockSecretAPIClientMockRecorder) SecretCreate(ctx, secret interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SecretCreate", reflect.TypeOf((*MockSecretAPIClient)(nil).SecretCreate), ctx, secret)
} | go | {
"resource": ""
} |
q7254 | SecretRemove | train | func (mr *MockSecretAPIClientMockRecorder) SecretRemove(ctx, id interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SecretRemove", reflect.TypeOf((*MockSecretAPIClient)(nil).SecretRemove), ctx, id)
} | go | {
"resource": ""
} |
q7255 | SecretInspectWithRaw | train | func (m *MockSecretAPIClient) SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error) {
ret := m.ctrl.Call(m, "SecretInspectWithRaw", ctx, name)
ret0, _ := ret[0].(swarm.Secret)
ret1, _ := ret[1].([]byte)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
} | go | {
"resource": ""
} |
q7256 | SecretInspectWithRaw | train | func (mr *MockSecretAPIClientMockRecorder) SecretInspectWithRaw(ctx, name interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SecretInspectWithRaw", reflect.TypeOf((*MockSecretAPIClient)(nil).SecretInspectWithRaw), ctx, name)
} | go | {
"resource": ""
} |
q7257 | SecretUpdate | train | func (m *MockSecretAPIClient) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error {
ret := m.ctrl.Call(m, "SecretUpdate", ctx, id, version, secret)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7258 | New | train | func New(ctx context.Context, p *env.RemoteParameters, c chan *policy.RuntimeError, r rpcwrapper.RPCClient) ProcessManager {
m := &RemoteMonitor{
remoteEnforcerTempBuildPath: remoteEnforcerTempBuildPath,
remoteEnforcerBuildName: remoteEnforcerBuildName,
netNSPath: netNSPath,
activeProcesses: cache.NewCache(processMonitorCacheName),
childExitStatus: make(chan exitStatus, 100),
logToConsole: p.LogToConsole,
logWithID: p.LogWithID,
logLevel: p.LogLevel,
logFormat: p.LogFormat,
compressedTags: p.CompressedTags,
runtimeErrorChannel: c,
rpc: r,
}
go m.collectChildExitStatus(ctx)
return m
} | go | {
"resource": ""
} |
q7259 | KillRemoteEnforcer | train | func (p *RemoteMonitor) KillRemoteEnforcer(contextID string, force bool) error {
p.Lock()
s, err := p.activeProcesses.Get(contextID)
if err != nil {
p.Unlock()
return fmt.Errorf("unable to find process for context: %s", contextID)
}
p.activeProcesses.Remove(contextID) // nolint errcheck
p.Unlock()
procInfo, ok := s.(*processInfo)
if !ok {
return fmt.Errorf("internal error - invalid type for process")
}
procInfo.Lock()
defer procInfo.Unlock()
if procInfo.process == nil {
return fmt.Errorf("cannot find process for context: %s", contextID)
}
req := &rpcwrapper.Request{
Payload: procInfo.process.Pid,
}
resp := &rpcwrapper.Response{}
c := make(chan error, 1)
go func() {
c <- p.rpc.RemoteCall(contextID, remoteenforcer.EnforcerExit, req, resp)
}()
select {
case err := <-c:
if err != nil && force {
zap.L().Error("Failed to stop gracefully - forcing kill",
zap.Error(err))
procInfo.process.Kill() // nolint
}
case <-time.After(5 * time.Second):
if force {
zap.L().Error("Time out on terminating remote enforcer - forcing kill")
procInfo.process.Kill() // nolint
}
}
p.rpc.DestroyRPCClient(contextID)
return nil
} | go | {
"resource": ""
} |
q7260 | collectChildExitStatus | train | func (p *RemoteMonitor) collectChildExitStatus(ctx context.Context) {
defer func() {
if r := recover(); r != nil {
zap.L().Error("Policy engine has possibly closed the channel")
return
}
}()
for {
select {
case <-ctx.Done():
return
case es := <-p.childExitStatus:
if err := p.activeProcesses.Remove(es.contextID); err != nil {
continue
}
p.rpc.DestroyRPCClient(es.contextID)
if p.runtimeErrorChannel != nil {
if es.exitStatus != nil {
zap.L().Error("Remote enforcer exited with an error",
zap.String("nativeContextID", es.contextID),
zap.Int("pid", es.process),
zap.Error(es.exitStatus),
)
} else {
zap.L().Warn("Remote enforcer exited",
zap.String("nativeContextID", es.contextID),
zap.Int("pid", es.process),
)
}
p.runtimeErrorChannel <- &policy.RuntimeError{
ContextID: es.contextID,
Error: fmt.Errorf("remote enforcer terminated: %s", es.exitStatus),
}
}
}
}
} | go | {
"resource": ""
} |
q7261 | pollStdOutAndErr | train | func (p *RemoteMonitor) pollStdOutAndErr(
cmd *exec.Cmd,
contextID string,
) (err error) {
stdout, err := cmd.StdoutPipe()
if err != nil {
return err
}
stderr, err := cmd.StderrPipe()
if err != nil {
return err
}
// Stdout/err processing
go processIOReader(stdout, contextID)
go processIOReader(stderr, contextID)
return nil
} | go | {
"resource": ""
} |
q7262 | getLaunchProcessCmd | train | func (p *RemoteMonitor) getLaunchProcessCmd(remoteEnforcerBuildPath, remoteEnforcerName, arg string) *exec.Cmd {
cmdName := filepath.Join(remoteEnforcerBuildPath, remoteEnforcerName)
cmdArgs := []string{arg}
zap.L().Debug("Enforcer executed",
zap.String("command", cmdName),
zap.Strings("args", cmdArgs),
)
return execCommand(cmdName, cmdArgs...)
} | go | {
"resource": ""
} |
q7263 | getLaunchProcessEnvVars | train | func (p *RemoteMonitor) getLaunchProcessEnvVars(
procMountPoint string,
contextID string,
randomkeystring string,
statsServerSecret string,
refPid int,
refNSPath string,
) []string {
newEnvVars := []string{
constants.EnvMountPoint + "=" + procMountPoint,
constants.EnvContextSocket + "=" + contextID2SocketPath(contextID),
constants.EnvStatsChannel + "=" + constants.StatsChannel,
constants.EnvDebugChannel + "=" + constants.DebugChannel,
constants.EnvRPCClientSecret + "=" + randomkeystring,
constants.EnvStatsSecret + "=" + statsServerSecret,
constants.EnvContainerPID + "=" + strconv.Itoa(refPid),
constants.EnvLogLevel + "=" + p.logLevel,
constants.EnvLogFormat + "=" + p.logFormat,
}
if p.compressedTags != claimsheader.CompressionTypeNone {
newEnvVars = append(newEnvVars, constants.EnvCompressedTags+"="+string(p.compressedTags))
}
if p.logToConsole {
newEnvVars = append(newEnvVars, constants.EnvLogToConsole+"="+constants.EnvLogToConsoleEnable)
}
if p.logWithID {
newEnvVars = append(newEnvVars, constants.EnvLogID+"="+contextID)
}
// If the PURuntime Specified a NSPath, then it is added as a new env var also.
if refNSPath != "" {
newEnvVars = append(newEnvVars, constants.EnvNSPath+"="+refNSPath)
}
return newEnvVars
} | go | {
"resource": ""
} |
q7264 | contextID2SocketPath | train | func contextID2SocketPath(contextID string) string {
if contextID == "" {
panic("contextID is empty")
}
return filepath.Join("/var/run/", strings.Replace(contextID, "/", "_", -1)+".sock")
} | go | {
"resource": ""
} |
q7265 | processIOReader | train | func processIOReader(fd io.Reader, contextID string) {
reader := bufio.NewReader(fd)
for {
str, err := reader.ReadString('\n')
if err != nil {
return
}
fmt.Print("[" + contextID + "]:" + str)
}
} | go | {
"resource": ""
} |
q7266 | New | train | func New(start, size int) Allocator {
a := &allocator{
allocate: make(chan int, size),
}
for i := start; i < (start + size); i++ {
a.allocate <- i
}
return a
} | go | {
"resource": ""
} |
q7267 | Release | train | func (p *allocator) Release(item string) {
// Do not release when the channel is full. These can happen when we resync
// stopped containers.
if len(p.allocate) == cap(p.allocate) {
return
}
intItem, err := strconv.Atoi(item)
if err != nil {
return
}
p.allocate <- intItem
} | go | {
"resource": ""
} |
q7268 | ReleaseInt | train | func (p *allocator) ReleaseInt(item int) {
if len(p.allocate) == cap(p.allocate) || item == 0 {
return
}
p.allocate <- item
} | go | {
"resource": ""
} |
q7269 | Resync | train | func (l *LinuxMonitor) Resync(ctx context.Context) error {
return l.proc.Resync(ctx, nil)
} | go | {
"resource": ""
} |
q7270 | Count | train | func (c *collectorImpl) Count() int {
c.Lock()
defer c.Unlock()
return len(c.Flows)
} | go | {
"resource": ""
} |
q7271 | GetAllRecords | train | func (c *collectorImpl) GetAllRecords() map[string]*collector.FlowRecord {
c.Lock()
defer c.Unlock()
if len(c.Flows) == 0 {
return nil
}
retval := c.Flows
c.Flows = make(map[string]*collector.FlowRecord)
return retval
} | go | {
"resource": ""
} |
q7272 | GetUserRecords | train | func (c *collectorImpl) GetUserRecords() map[string]*collector.UserRecord {
c.Lock()
defer c.Unlock()
if len(c.Users) == 0 {
return nil
}
retval := c.Users
c.Users = map[string]*collector.UserRecord{}
return retval
} | go | {
"resource": ""
} |
q7273 | FlushUserCache | train | func (c *collectorImpl) FlushUserCache() {
c.Lock()
defer c.Unlock()
c.ProcessedUsers = map[string]bool{}
} | go | {
"resource": ""
} |
q7274 | GetAllDataPathPacketRecords | train | func (c *collectorImpl) GetAllDataPathPacketRecords() []*collector.PacketReport {
c.Lock()
defer c.Unlock()
record := c.DatapathPacketReports
c.DatapathPacketReports = []*collector.PacketReport{}
return record
} | go | {
"resource": ""
} |
q7275 | Add | train | func (r *cacheRegistry) Add(c *Cache) {
r.Lock()
defer r.Unlock()
r.items[c.name] = c
} | go | {
"resource": ""
} |
q7276 | ToString | train | func (r *cacheRegistry) ToString() string {
r.Lock()
defer r.Unlock()
buffer := fmt.Sprintf("Cache Registry: %d\n", len(r.items))
buffer += fmt.Sprintf(" %32s : %s\n\n", "Cache Name", "max/curr")
for k, c := range r.items {
buffer += fmt.Sprintf(" %32s : %s\n", k, c.ToString())
}
return buffer
} | go | {
"resource": ""
} |
q7277 | NewCacheWithExpiration | train | func NewCacheWithExpiration(name string, lifetime time.Duration) *Cache {
return NewCacheWithExpirationNotifier(name, lifetime, nil)
} | go | {
"resource": ""
} |
q7278 | NewCacheWithExpirationNotifier | train | func NewCacheWithExpirationNotifier(name string, lifetime time.Duration, expirer ExpirationNotifier) *Cache {
c := &Cache{
name: name,
data: make(map[interface{}]entry),
lifetime: lifetime,
expirer: expirer,
}
c.max = len(c.data)
registry.Add(c)
return c
} | go | {
"resource": ""
} |
q7279 | ToString | train | func (c *Cache) ToString() string {
c.Lock()
defer c.Unlock()
return fmt.Sprintf("%d/%d", c.max, len(c.data))
} | go | {
"resource": ""
} |
q7280 | GetReset | train | func (c *Cache) GetReset(u interface{}, duration time.Duration) (interface{}, error) {
c.Lock()
defer c.Unlock()
if line, ok := c.data[u]; ok {
if c.lifetime != -1 && line.timer != nil {
if duration > 0 {
line.timer.Reset(duration)
} else {
line.timer.Reset(c.lifetime)
}
}
return line.value, nil
}
return nil, errors.New("cannot read item: not found")
} | go | {
"resource": ""
} |
q7281 | Update | train | func (c *Cache) Update(u interface{}, value interface{}) (err error) {
var timer *time.Timer
if c.lifetime != -1 {
timer = time.AfterFunc(c.lifetime, func() {
if err := c.removeNotify(u, true); err != nil {
zap.L().Warn("Failed to remove item", zap.String("key", fmt.Sprintf("%v", u)))
}
})
}
t := time.Now()
c.Lock()
defer c.Unlock()
if _, ok := c.data[u]; ok {
if c.data[u].timer != nil {
c.data[u].timer.Stop()
}
c.data[u] = entry{
value: value,
timestamp: t,
timer: timer,
expirer: c.expirer,
}
return nil
}
return errors.New("cannot update item: not found")
} | go | {
"resource": ""
} |
q7282 | AddOrUpdate | train | func (c *Cache) AddOrUpdate(u interface{}, value interface{}) (updated bool) {
var timer *time.Timer
if c.lifetime != -1 {
timer = time.AfterFunc(c.lifetime, func() {
if err := c.removeNotify(u, true); err != nil {
zap.L().Warn("Failed to remove item", zap.String("key", fmt.Sprintf("%v", u)))
}
})
}
t := time.Now()
c.Lock()
defer c.Unlock()
if _, updated = c.data[u]; updated {
if c.data[u].timer != nil {
c.data[u].timer.Stop()
}
}
c.data[u] = entry{
value: value,
timestamp: t,
timer: timer,
expirer: c.expirer,
}
if len(c.data) > c.max {
c.max = len(c.data)
}
return updated
} | go | {
"resource": ""
} |
q7283 | SetTimeOut | train | func (c *Cache) SetTimeOut(u interface{}, timeout time.Duration) (err error) {
c.Lock()
defer c.Unlock()
if _, ok := c.data[u]; !ok {
return errors.New("item is already deleted")
}
c.data[u].timer.Reset(timeout)
return nil
} | go | {
"resource": ""
} |
q7284 | Get | train | func (c *Cache) Get(u interface{}) (i interface{}, err error) {
c.Lock()
defer c.Unlock()
if _, ok := c.data[u]; !ok {
return nil, errors.New("not found")
}
return c.data[u].value, nil
} | go | {
"resource": ""
} |
q7285 | KeyList | train | func (c *Cache) KeyList() []interface{} {
c.Lock()
defer c.Unlock()
list := []interface{}{}
for k := range c.data {
list = append(list, k)
}
return list
} | go | {
"resource": ""
} |
q7286 | removeNotify | train | func (c *Cache) removeNotify(u interface{}, notify bool) (err error) {
c.Lock()
defer c.Unlock()
val, ok := c.data[u]
if !ok {
return errors.New("not found")
}
if val.timer != nil {
val.timer.Stop()
}
if notify && val.expirer != nil {
val.expirer(c, u, val.value)
}
delete(c.data, u)
return nil
} | go | {
"resource": ""
} |
q7287 | Remove | train | func (c *Cache) Remove(u interface{}) (err error) {
return c.removeNotify(u, false)
} | go | {
"resource": ""
} |
q7288 | RemoveWithDelay | train | func (c *Cache) RemoveWithDelay(u interface{}, duration time.Duration) error {
if duration == -1 {
return c.Remove(u)
}
c.Lock()
defer c.Unlock()
e, ok := c.data[u]
if !ok {
return errors.New("cannot remove item with delay: not found")
}
timer := time.AfterFunc(duration, func() {
if err := c.Remove(u); err != nil {
zap.L().Warn("Failed to remove item with delay", zap.String("key", fmt.Sprintf("%v", u)), zap.String("delay", duration.String()))
}
})
t := time.Now()
if c.data[u].timer != nil {
c.data[u].timer.Stop()
}
c.data[u] = entry{
value: e.value,
timestamp: t,
timer: timer,
expirer: c.expirer,
}
return nil
} | go | {
"resource": ""
} |
q7289 | SizeOf | train | func (c *Cache) SizeOf() int {
c.Lock()
defer c.Unlock()
return len(c.data)
} | go | {
"resource": ""
} |
q7290 | LockedModify | train | func (c *Cache) LockedModify(u interface{}, add func(a, b interface{}) interface{}, increment interface{}) (interface{}, error) {
var timer *time.Timer
if c.lifetime != -1 {
timer = time.AfterFunc(c.lifetime, func() {
if err := c.removeNotify(u, true); err != nil {
zap.L().Warn("Failed to remove item", zap.String("key", fmt.Sprintf("%v", u)))
}
})
}
t := time.Now()
c.Lock()
defer c.Unlock()
e, ok := c.data[u]
if !ok {
return nil, errors.New("not found")
}
if e.timer != nil {
e.timer.Stop()
}
e.value = add(e.value, increment)
e.timer = timer
e.timestamp = t
e.expirer = c.expirer
c.data[u] = e
return e.value, nil
} | go | {
"resource": ""
} |
q7291 | NewMockTriremeController | train | func NewMockTriremeController(ctrl *gomock.Controller) *MockTriremeController {
mock := &MockTriremeController{ctrl: ctrl}
mock.recorder = &MockTriremeControllerMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7292 | UpdateSecrets | train | func (m *MockTriremeController) UpdateSecrets(secrets secrets.Secrets) error {
ret := m.ctrl.Call(m, "UpdateSecrets", secrets)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7293 | NewMockDebugInfo | train | func NewMockDebugInfo(ctrl *gomock.Controller) *MockDebugInfo {
mock := &MockDebugInfo{ctrl: ctrl}
mock.recorder = &MockDebugInfoMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q7294 | EnableDatapathPacketTracing | train | func (m *MockDebugInfo) EnableDatapathPacketTracing(contextID string, direction packettracing.TracingDirection, interval time.Duration, putype common.PUType) error {
ret := m.ctrl.Call(m, "EnableDatapathPacketTracing", contextID, direction, interval, putype)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q7295 | NewVerifierFromFile | train | func NewVerifierFromFile(jwtcertPath string, redirectURI string, redirectOnFail, redirectOnNoToken bool) (*PKIJWTVerifier, error) {
jwtCertPEM, err := ioutil.ReadFile(jwtcertPath)
if err != nil {
return nil, fmt.Errorf("failed to read JWT signing certificates or public keys from file: %s", err)
}
return NewVerifierFromPEM(jwtCertPEM, redirectURI, redirectOnFail, redirectOnNoToken)
} | go | {
"resource": ""
} |
q7296 | NewVerifierFromPEM | train | func NewVerifierFromPEM(jwtCertPEM []byte, redirectURI string, redirectOnFail, redirectOnNoToken bool) (*PKIJWTVerifier, error) {
keys, err := parsePublicKeysFromPEM(jwtCertPEM)
// pay attention to the return format of parsePublicKeysFromPEM
// when checking for an error here
if keys == nil && err != nil {
return nil, fmt.Errorf("failed to read JWT signing certificates or public keys from PEM: %s", err)
}
return &PKIJWTVerifier{
JWTCertPEM: jwtCertPEM,
keys: keys,
RedirectURL: redirectURI,
}, nil
} | go | {
"resource": ""
} |
q7297 | NewVerifier | train | func NewVerifier(v *PKIJWTVerifier) (*PKIJWTVerifier, error) {
if len(v.JWTCertPEM) == 0 {
return v, nil
}
keys, err := parsePublicKeysFromPEM(v.JWTCertPEM)
// pay attention to the return format of parsePublicKeysFromPEM
// when checking for an error here
if keys == nil && err != nil {
return nil, fmt.Errorf("failed to parse JWT signing certificates or public keys from PEM: %s", err)
}
v.keys = keys
return v, nil
} | go | {
"resource": ""
} |
q7298 | Validate | train | func (j *PKIJWTVerifier) Validate(ctx context.Context, tokenString string) ([]string, bool, string, error) {
if len(tokenString) == 0 {
return []string{}, false, tokenString, fmt.Errorf("Empty token")
}
if len(j.keys) == 0 {
return []string{}, false, tokenString, fmt.Errorf("No public keys loaded into verifier")
}
// iterate over all public keys that we have and try to validate the token
// the first one to succeed will be used
var errs []error
for _, key := range j.keys {
claims := &jwt.MapClaims{}
token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) {
switch token.Method.(type) {
case *jwt.SigningMethodECDSA:
if isECDSAPublicKey(key) {
return key, nil
}
case *jwt.SigningMethodRSA:
if isRSAPublicKey(key) {
return key, nil
}
default:
return nil, fmt.Errorf("unsupported signing method '%T'", token.Method)
}
return nil, fmt.Errorf("signing method '%T' and public key type '%T' mismatch", token.Method, key)
})
// cover all error cases after parsing/verifying
if err != nil {
errs = append(errs, err)
continue
}
if token == nil {
errs = append(errs, fmt.Errorf("no token was parsed"))
continue
}
if !token.Valid {
errs = append(errs, fmt.Errorf("token failed to verify against public key"))
continue
}
// return successful on match/verification with the first key
attributes := []string{}
for k, v := range *claims {
attributes = append(attributes, common.FlattenClaim(k, v)...)
}
return attributes, false, tokenString, nil
}
// generate a detailed error
var detailedError string
for i, err := range errs {
detailedError += err.Error()
if i+1 < len(errs) {
detailedError += "; "
}
}
return []string{}, false, tokenString, fmt.Errorf("Invalid token - errors: [%s]", detailedError)
} | go | {
"resource": ""
} |
q7299 | Callback | train | func (j *PKIJWTVerifier) Callback(r *http.Request) (string, string, int, error) {
return "", "", 0, nil
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.