_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q32600 | New | train | func New(c *Config) (*Node, error) {
if err := os.MkdirAll(c.StateDir, 0700); err != nil {
return nil, err
}
stateFile := filepath.Join(c.StateDir, stateFilename)
dt, err := ioutil.ReadFile(stateFile)
var p []api.Peer
if err != nil && !os.IsNotExist(err) {
return nil, err
}
if err == nil {
if err := json.... | go | {
"resource": ""
} |
q32601 | BindRemote | train | func (n *Node) BindRemote(ctx context.Context, listenAddr string, advertiseAddr string) error {
n.RLock()
defer n.RUnlock()
if n.manager == nil {
return errors.New("manager is not running")
}
return n.manager.BindRemote(ctx, manager.RemoteAddrs{
ListenAddr: listenAddr,
AdvertiseAddr: advertiseAddr,
})
... | go | {
"resource": ""
} |
q32602 | Start | train | func (n *Node) Start(ctx context.Context) error {
err := errNodeStarted
n.startOnce.Do(func() {
close(n.started)
go n.run(ctx)
err = nil // clear error above, only once.
})
return err
} | go | {
"resource": ""
} |
q32603 | configVXLANUDPPort | train | func configVXLANUDPPort(ctx context.Context, vxlanUDPPort uint32) {
if err := overlayutils.ConfigVXLANUDPPort(vxlanUDPPort); err != nil {
log.G(ctx).WithError(err).Error("failed to configure VXLAN UDP port")
return
}
logrus.Infof("initialized VXLAN UDP port to %d ", vxlanUDPPort)
} | go | {
"resource": ""
} |
q32604 | Stop | train | func (n *Node) Stop(ctx context.Context) error {
select {
case <-n.started:
default:
return errNodeNotStarted
}
// ask agent to clean up assignments
n.Lock()
if n.agent != nil {
if err := n.agent.Leave(ctx); err != nil {
log.G(ctx).WithError(err).Error("agent failed to clean up assignments")
}
}
n.Unl... | go | {
"resource": ""
} |
q32605 | Err | train | func (n *Node) Err(ctx context.Context) error {
select {
case <-n.closed:
return n.err
case <-ctx.Done():
return ctx.Err()
}
} | go | {
"resource": ""
} |
q32606 | runAgent | train | func (n *Node) runAgent(ctx context.Context, db *bolt.DB, securityConfig *ca.SecurityConfig, ready chan<- struct{}) error {
// First, get a channel for knowing when a remote peer has been selected.
// The value returned from the remotesCh is ignored, we just need to know
// when the peer is selected
remotesCh := n.... | go | {
"resource": ""
} |
q32607 | ListenControlSocket | train | func (n *Node) ListenControlSocket(ctx context.Context) <-chan *grpc.ClientConn {
c := make(chan *grpc.ClientConn, 1)
n.RLock()
conn := n.conn
c <- conn
done := make(chan struct{})
go func() {
select {
case <-ctx.Done():
n.connCond.Broadcast()
case <-done:
}
}()
go func() {
defer close(c)
defer c... | go | {
"resource": ""
} |
q32608 | NodeID | train | func (n *Node) NodeID() string {
n.RLock()
defer n.RUnlock()
return n.nodeID
} | go | {
"resource": ""
} |
q32609 | Manager | train | func (n *Node) Manager() *manager.Manager {
n.RLock()
defer n.RUnlock()
return n.manager
} | go | {
"resource": ""
} |
q32610 | Agent | train | func (n *Node) Agent() *agent.Agent {
n.RLock()
defer n.RUnlock()
return n.agent
} | go | {
"resource": ""
} |
q32611 | Remotes | train | func (n *Node) Remotes() []api.Peer {
weights := n.remotes.Weights()
remotes := make([]api.Peer, 0, len(weights))
for p := range weights {
remotes = append(remotes, p)
}
return remotes
} | go | {
"resource": ""
} |
q32612 | isMandatoryFIPSClusterID | train | func isMandatoryFIPSClusterID(securityConfig *ca.SecurityConfig) bool {
return strings.HasPrefix(securityConfig.ClientTLSCreds.Organization(), "FIPS.")
} | go | {
"resource": ""
} |
q32613 | isMandatoryFIPSClusterJoinToken | train | func isMandatoryFIPSClusterJoinToken(joinToken string) bool {
if parsed, err := ca.ParseJoinToken(joinToken); err == nil {
return parsed.FIPS
}
return false
} | go | {
"resource": ""
} |
q32614 | superviseManager | train | func (n *Node) superviseManager(ctx context.Context, securityConfig *ca.SecurityConfig, rootPaths ca.CertPaths, ready chan struct{}, renewer *ca.TLSRenewer) error {
// superviseManager is a loop, because we can come in and out of being a
// manager, and need to appropriately handle that without disrupting the
// nod... | go | {
"resource": ""
} |
q32615 | DowngradeKey | train | func (n *Node) DowngradeKey() error {
paths := ca.NewConfigPaths(filepath.Join(n.config.StateDir, certDirectory))
krw := ca.NewKeyReadWriter(paths.Node, n.config.UnlockKey, nil)
return krw.DowngradeKey()
} | go | {
"resource": ""
} |
q32616 | WaitSelect | train | func (s *persistentRemotes) WaitSelect(ctx context.Context) <-chan api.Peer {
c := make(chan api.Peer, 1)
s.RLock()
done := make(chan struct{})
go func() {
select {
case <-ctx.Done():
s.c.Broadcast()
case <-done:
}
}()
go func() {
defer s.RUnlock()
defer close(c)
defer close(done)
for {
if c... | go | {
"resource": ""
} |
q32617 | SessionClosed | train | func (fs *firstSessionErrorTracker) SessionClosed() error {
fs.mu.Lock()
defer fs.mu.Unlock()
// if we've successfully established at least 1 session, never return
// errors
if fs.pastFirstSession {
return nil
}
// get the GRPC status from the error, because we only care about GRPC
// errors
grpcStatus, ok... | go | {
"resource": ""
} |
q32618 | Apply | train | func Apply(store *MemoryStore, item events.Event) (err error) {
return store.Update(func(tx Tx) error {
switch v := item.(type) {
case api.EventCreateTask:
return CreateTask(tx, v.Task)
case api.EventUpdateTask:
return UpdateTask(tx, v.Task)
case api.EventDeleteTask:
return DeleteTask(tx, v.Task.ID)
... | go | {
"resource": ""
} |
q32619 | getPortConfigKey | train | func getPortConfigKey(p *api.PortConfig) api.PortConfig {
return api.PortConfig{
Name: p.Name,
Protocol: p.Protocol,
TargetPort: p.TargetPort,
}
} | go | {
"resource": ""
} |
q32620 | newRoleManager | train | func newRoleManager(store *store.MemoryStore, raftNode *raft.Node) *roleManager {
ctx, cancel := context.WithCancel(context.Background())
return &roleManager{
ctx: ctx,
cancel: cancel,
store: store,
raft: raftNode,
doneChan: make... | go | {
"resource": ""
} |
q32621 | getTicker | train | func (rm *roleManager) getTicker(interval time.Duration) clock.Ticker {
if rm.clocksource == nil {
return clock.NewClock().NewTicker(interval)
}
return rm.clocksource.NewTicker(interval)
} | go | {
"resource": ""
} |
q32622 | removeMember | train | func (rm *roleManager) removeMember(ctx context.Context, member *membership.Member) {
// Quorum safeguard - quorum should have been checked before a node was allowed to be demoted, but if in the
// intervening time some other node disconnected, removing this node would result in a loss of cluster quorum.
// We leave... | go | {
"resource": ""
} |
q32623 | reconcileRole | train | func (rm *roleManager) reconcileRole(ctx context.Context, node *api.Node) {
if node.Role == node.Spec.DesiredRole {
// Nothing to do.
delete(rm.pendingReconciliation, node.ID)
return
}
// Promotion can proceed right away.
if node.Spec.DesiredRole == api.NodeRoleManager && node.Role == api.NodeRoleWorker {
... | go | {
"resource": ""
} |
q32624 | NewPipeline | train | func NewPipeline() *Pipeline {
p := &Pipeline{}
for _, f := range defaultFilters {
p.checklist = append(p.checklist, checklistEntry{f: f})
}
return p
} | go | {
"resource": ""
} |
q32625 | Process | train | func (p *Pipeline) Process(n *NodeInfo) bool {
for i, entry := range p.checklist {
if entry.enabled && !entry.f.Check(n) {
// Immediately stop on first failure.
p.checklist[i].failureCount++
return false
}
}
for i := range p.checklist {
p.checklist[i].failureCount = 0
}
return true
} | go | {
"resource": ""
} |
q32626 | SetTask | train | func (p *Pipeline) SetTask(t *api.Task) {
for i := range p.checklist {
p.checklist[i].enabled = p.checklist[i].f.SetTask(t)
p.checklist[i].failureCount = 0
}
} | go | {
"resource": ""
} |
q32627 | Explain | train | func (p *Pipeline) Explain() string {
var explanation string
// Sort from most failures to least
sortedByFailures := make([]checklistEntry, len(p.checklist))
copy(sortedByFailures, p.checklist)
sort.Sort(sort.Reverse(checklistByFailures(sortedByFailures)))
for _, entry := range sortedByFailures {
if entry.fa... | go | {
"resource": ""
} |
q32628 | validateImage | train | func validateImage(image string) error {
if image == "" {
return status.Errorf(codes.InvalidArgument, "ContainerSpec: image reference must be provided")
}
if _, err := reference.ParseNormalizedNamed(image); err != nil {
return status.Errorf(codes.InvalidArgument, "ContainerSpec: %q is not a valid repository/tag... | go | {
"resource": ""
} |
q32629 | validateMounts | train | func validateMounts(mounts []api.Mount) error {
mountMap := make(map[string]bool)
for _, mount := range mounts {
if _, exists := mountMap[mount.Target]; exists {
return status.Errorf(codes.InvalidArgument, "ContainerSpec: duplicate mount point: %s", mount.Target)
}
mountMap[mount.Target] = true
}
return n... | go | {
"resource": ""
} |
q32630 | validateHealthCheck | train | func validateHealthCheck(hc *api.HealthConfig) error {
if hc == nil {
return nil
}
if hc.Interval != nil {
interval, err := gogotypes.DurationFromProto(hc.Interval)
if err != nil {
return err
}
if interval != 0 && interval < minimumDuration {
return status.Errorf(codes.InvalidArgument, "ContainerSpe... | go | {
"resource": ""
} |
q32631 | validateSecretRefsSpec | train | func validateSecretRefsSpec(spec api.TaskSpec) error {
container := spec.GetContainer()
if container == nil {
return nil
}
// Keep a map to track all the targets that will be exposed
// The string returned is only used for logging. It could as well be struct{}{}
existingTargets := make(map[string]string)
for ... | go | {
"resource": ""
} |
q32632 | validateConfigRefsSpec | train | func validateConfigRefsSpec(spec api.TaskSpec) error {
container := spec.GetContainer()
if container == nil {
return nil
}
// check if we're using a config as a CredentialSpec -- if so, we need to
// verify
var (
credSpecConfig string
credSpecConfigFound bool
)
if p := container.Privileges; p != nil... | go | {
"resource": ""
} |
q32633 | checkSecretExistence | train | func (s *Server) checkSecretExistence(tx store.Tx, spec *api.ServiceSpec) error {
container := spec.Task.GetContainer()
if container == nil {
return nil
}
var failedSecrets []string
for _, secretRef := range container.Secrets {
secret := store.GetSecret(tx, secretRef.SecretID)
// Check to see if the secret ... | go | {
"resource": ""
} |
q32634 | checkConfigExistence | train | func (s *Server) checkConfigExistence(tx store.Tx, spec *api.ServiceSpec) error {
container := spec.Task.GetContainer()
if container == nil {
return nil
}
var failedConfigs []string
for _, configRef := range container.Configs {
config := store.GetConfig(tx, configRef.ConfigID)
// Check to see if the config ... | go | {
"resource": ""
} |
q32635 | CreateService | train | func (s *Server) CreateService(ctx context.Context, request *api.CreateServiceRequest) (*api.CreateServiceResponse, error) {
if err := validateServiceSpec(request.Spec); err != nil {
return nil, err
}
if err := s.validateNetworks(request.Spec.Task.Networks); err != nil {
return nil, err
}
if err := s.checkPo... | go | {
"resource": ""
} |
q32636 | GetService | train | func (s *Server) GetService(ctx context.Context, request *api.GetServiceRequest) (*api.GetServiceResponse, error) {
if request.ServiceID == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
var service *api.Service
s.store.View(func(tx store.ReadTx) {
service = store.GetServic... | go | {
"resource": ""
} |
q32637 | RemoveService | train | func (s *Server) RemoveService(ctx context.Context, request *api.RemoveServiceRequest) (*api.RemoveServiceResponse, error) {
if request.ServiceID == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
err := s.store.Update(func(tx store.Tx) error {
return store.DeleteService(tx, ... | go | {
"resource": ""
} |
q32638 | ListServices | train | func (s *Server) ListServices(ctx context.Context, request *api.ListServicesRequest) (*api.ListServicesResponse, error) {
var (
services []*api.Service
err error
)
s.store.View(func(tx store.ReadTx) {
switch {
case request.Filters != nil && len(request.Filters.Names) > 0:
services, err = store.FindS... | go | {
"resource": ""
} |
q32639 | Start | train | func (lb *LogBroker) Start(ctx context.Context) error {
lb.mu.Lock()
defer lb.mu.Unlock()
if lb.cancelAll != nil {
return errAlreadyRunning
}
lb.pctx, lb.cancelAll = context.WithCancel(ctx)
lb.logQueue = watch.NewQueue()
lb.subscriptionQueue = watch.NewQueue()
lb.registeredSubscriptions = make(map[string]*s... | go | {
"resource": ""
} |
q32640 | Stop | train | func (lb *LogBroker) Stop() error {
lb.mu.Lock()
defer lb.mu.Unlock()
if lb.cancelAll == nil {
return errNotRunning
}
lb.cancelAll()
lb.cancelAll = nil
lb.logQueue.Close()
lb.subscriptionQueue.Close()
return nil
} | go | {
"resource": ""
} |
q32641 | watchSubscriptions | train | func (lb *LogBroker) watchSubscriptions(nodeID string) ([]*subscription, chan events.Event, func()) {
lb.mu.RLock()
defer lb.mu.RUnlock()
// Watch for subscription changes for this node.
ch, cancel := lb.subscriptionQueue.CallbackWatch(events.MatcherFunc(func(event events.Event) bool {
s := event.(*subscription)... | go | {
"resource": ""
} |
q32642 | SubscribeLogs | train | func (lb *LogBroker) SubscribeLogs(request *api.SubscribeLogsRequest, stream api.Logs_SubscribeLogsServer) error {
ctx := stream.Context()
if err := validateSelector(request.Selector); err != nil {
return err
}
lb.mu.Lock()
pctx := lb.pctx
lb.mu.Unlock()
if pctx == nil {
return errNotRunning
}
subscript... | go | {
"resource": ""
} |
q32643 | ListenSubscriptions | train | func (lb *LogBroker) ListenSubscriptions(request *api.ListenSubscriptionsRequest, stream api.LogBroker_ListenSubscriptionsServer) error {
remote, err := ca.RemoteNode(stream.Context())
if err != nil {
return err
}
lb.mu.Lock()
pctx := lb.pctx
lb.mu.Unlock()
if pctx == nil {
return errNotRunning
}
lb.node... | go | {
"resource": ""
} |
q32644 | PublishLogs | train | func (lb *LogBroker) PublishLogs(stream api.LogBroker_PublishLogsServer) (err error) {
remote, err := ca.RemoteNode(stream.Context())
if err != nil {
return err
}
var currentSubscription *subscription
defer func() {
if currentSubscription != nil {
lb.markDone(currentSubscription, remote.NodeID, err)
}
}... | go | {
"resource": ""
} |
q32645 | ParseAddSecret | train | func ParseAddSecret(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
flags := cmd.Flags()
if flags.Changed(flagName) {
secrets, err := flags.GetStringSlice(flagName)
if err != nil {
return err
}
container := spec.Task.GetContainer()
if container == nil {
spec.Task.Runtime = &api.T... | go | {
"resource": ""
} |
q32646 | ParseRemoveSecret | train | func ParseRemoveSecret(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
flags := cmd.Flags()
if flags.Changed(flagName) {
secrets, err := flags.GetStringSlice(flagName)
if err != nil {
return err
}
container := spec.Task.GetContainer()
if container == nil {
return nil
}
wantT... | go | {
"resource": ""
} |
q32647 | NewGlobalOrchestrator | train | func NewGlobalOrchestrator(store *store.MemoryStore) *Orchestrator {
restartSupervisor := restart.NewSupervisor(store)
updater := update.NewSupervisor(store, restartSupervisor)
return &Orchestrator{
store: store,
nodes: make(map[string]*api.Node),
globalServices: make(map[string]globalService... | go | {
"resource": ""
} |
q32648 | FixTask | train | func (g *Orchestrator) FixTask(ctx context.Context, batch *store.Batch, t *api.Task) {
if _, exists := g.globalServices[t.ServiceID]; !exists {
return
}
// if a task's DesiredState has past running, the task has been processed
if t.DesiredState > api.TaskStateRunning {
return
}
var node *api.Node
if t.NodeI... | go | {
"resource": ""
} |
q32649 | handleTaskChange | train | func (g *Orchestrator) handleTaskChange(ctx context.Context, t *api.Task) {
if _, exists := g.globalServices[t.ServiceID]; !exists {
return
}
// if a task's DesiredState has passed running, it
// means the task has been processed
if t.DesiredState > api.TaskStateRunning {
return
}
// if a task has passed ru... | go | {
"resource": ""
} |
q32650 | updateNode | train | func (g *Orchestrator) updateNode(node *api.Node) {
if node.Spec.Availability == api.NodeAvailabilityDrain || node.Status.State == api.NodeStatus_DOWN {
delete(g.nodes, node.ID)
} else {
g.nodes[node.ID] = node
}
} | go | {
"resource": ""
} |
q32651 | updateService | train | func (g *Orchestrator) updateService(service *api.Service) {
var constraints []constraint.Constraint
if service.Spec.Task.Placement != nil && len(service.Spec.Task.Placement.Constraints) != 0 {
constraints, _ = constraint.Parse(service.Spec.Task.Placement.Constraints)
}
g.globalServices[service.ID] = globalServ... | go | {
"resource": ""
} |
q32652 | SlotTuple | train | func (g *Orchestrator) SlotTuple(t *api.Task) orchestrator.SlotTuple {
return orchestrator.SlotTuple{
ServiceID: t.ServiceID,
NodeID: t.NodeID,
}
} | go | {
"resource": ""
} |
q32653 | removeTask | train | func (nodeInfo *NodeInfo) removeTask(t *api.Task) bool {
oldTask, ok := nodeInfo.Tasks[t.ID]
if !ok {
return false
}
delete(nodeInfo.Tasks, t.ID)
if oldTask.DesiredState <= api.TaskStateRunning {
nodeInfo.ActiveTasksCount--
nodeInfo.ActiveTasksCountByService[t.ServiceID]--
}
if t.Endpoint != nil {
for ... | go | {
"resource": ""
} |
q32654 | addTask | train | func (nodeInfo *NodeInfo) addTask(t *api.Task) bool {
oldTask, ok := nodeInfo.Tasks[t.ID]
if ok {
if t.DesiredState <= api.TaskStateRunning && oldTask.DesiredState > api.TaskStateRunning {
nodeInfo.Tasks[t.ID] = t
nodeInfo.ActiveTasksCount++
nodeInfo.ActiveTasksCountByService[t.ServiceID]++
return true
... | go | {
"resource": ""
} |
q32655 | taskFailed | train | func (nodeInfo *NodeInfo) taskFailed(ctx context.Context, t *api.Task) {
expired := 0
now := time.Now()
if now.Sub(nodeInfo.lastCleanup) >= monitorFailures {
nodeInfo.cleanupFailures(now)
}
versionedService := versionedService{serviceID: t.ServiceID}
if t.SpecVersion != nil {
versionedService.specVersion = ... | go | {
"resource": ""
} |
q32656 | countRecentFailures | train | func (nodeInfo *NodeInfo) countRecentFailures(now time.Time, t *api.Task) int {
versionedService := versionedService{serviceID: t.ServiceID}
if t.SpecVersion != nil {
versionedService.specVersion = *t.SpecVersion
}
recentFailureCount := len(nodeInfo.recentFailures[versionedService])
for i := recentFailureCount ... | go | {
"resource": ""
} |
q32657 | ContainerCreate | train | func (sa *StubAPIClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networking *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) {
sa.called()
return sa.ContainerCreateFn(ctx, config, hostConfig, networking, containerNa... | go | {
"resource": ""
} |
q32658 | ContainerInspect | train | func (sa *StubAPIClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) {
sa.called()
return sa.ContainerInspectFn(ctx, containerID)
} | go | {
"resource": ""
} |
q32659 | ContainerKill | train | func (sa *StubAPIClient) ContainerKill(ctx context.Context, containerID, signal string) error {
sa.called()
return sa.ContainerKillFn(ctx, containerID, signal)
} | go | {
"resource": ""
} |
q32660 | ContainerRemove | train | func (sa *StubAPIClient) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error {
sa.called()
return sa.ContainerRemoveFn(ctx, containerID, options)
} | go | {
"resource": ""
} |
q32661 | ContainerStart | train | func (sa *StubAPIClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error {
sa.called()
return sa.ContainerStartFn(ctx, containerID, options)
} | go | {
"resource": ""
} |
q32662 | ContainerStop | train | func (sa *StubAPIClient) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error {
sa.called()
return sa.ContainerStopFn(ctx, containerID, timeout)
} | go | {
"resource": ""
} |
q32663 | ImagePull | train | func (sa *StubAPIClient) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) {
sa.called()
return sa.ImagePullFn(ctx, refStr, options)
} | go | {
"resource": ""
} |
q32664 | Events | train | func (sa *StubAPIClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) {
sa.called()
return sa.EventsFn(ctx, options)
} | go | {
"resource": ""
} |
q32665 | Watch | train | func (s *Server) Watch(request *api.WatchRequest, stream api.Watch_WatchServer) error {
ctx := stream.Context()
s.mu.Lock()
pctx := s.pctx
s.mu.Unlock()
if pctx == nil {
return errNotRunning
}
watchArgs, err := api.ConvertWatchArgs(request.Entries)
if err != nil {
return status.Errorf(codes.InvalidArgumen... | go | {
"resource": ""
} |
q32666 | ExpandContainerSpec | train | func ExpandContainerSpec(n *api.NodeDescription, t *api.Task) (*api.ContainerSpec, error) {
container := t.Spec.GetContainer()
if container == nil {
return nil, errors.Errorf("task missing ContainerSpec to expand")
}
container = container.Copy()
ctx := NewContext(n, t)
var err error
container.Env, err = expa... | go | {
"resource": ""
} |
q32667 | ExpandSecretSpec | train | func ExpandSecretSpec(s *api.Secret, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.SecretSpec, error) {
if s.Spec.Templating == nil {
return &s.Spec, nil
}
if s.Spec.Templating.Name == "golang" {
ctx := NewPayloadContextFromTask(node, t, dependencies)
secretSpec := s.Spec.Co... | go | {
"resource": ""
} |
q32668 | ExpandConfigSpec | train | func ExpandConfigSpec(c *api.Config, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.ConfigSpec, bool, error) {
if c.Spec.Templating == nil {
return &c.Spec, false, nil
}
if c.Spec.Templating.Name == "golang" {
ctx := NewPayloadContextFromTask(node, t, dependencies)
configSpec... | go | {
"resource": ""
} |
q32669 | Get | train | func (s *secrets) Get(secretID string) (*api.Secret, error) {
s.mu.RLock()
defer s.mu.RUnlock()
if s, ok := s.m[secretID]; ok {
return s, nil
}
return nil, fmt.Errorf("secret %s not found", secretID)
} | go | {
"resource": ""
} |
q32670 | Add | train | func (s *secrets) Add(secrets ...api.Secret) {
s.mu.Lock()
defer s.mu.Unlock()
for _, secret := range secrets {
s.m[secret.ID] = secret.Copy()
}
} | go | {
"resource": ""
} |
q32671 | Remove | train | func (s *secrets) Remove(secrets []string) {
s.mu.Lock()
defer s.mu.Unlock()
for _, secret := range secrets {
delete(s.m, secret)
}
} | go | {
"resource": ""
} |
q32672 | Reset | train | func (s *secrets) Reset() {
s.mu.Lock()
defer s.mu.Unlock()
s.m = make(map[string]*api.Secret)
} | go | {
"resource": ""
} |
q32673 | Restrict | train | func Restrict(secrets exec.SecretGetter, t *api.Task) exec.SecretGetter {
sids := map[string]struct{}{}
container := t.Spec.GetContainer()
if container != nil {
for _, ref := range container.Secrets {
sids[ref.SecretID] = struct{}{}
}
}
return &taskRestrictedSecretsProvider{secrets: secrets, secretIDs: si... | go | {
"resource": ""
} |
q32674 | IsReplicatedService | train | func IsReplicatedService(service *api.Service) bool {
// service nil validation is required as there are scenarios
// where service is removed from store
if service == nil {
return false
}
_, ok := service.Spec.GetMode().(*api.ServiceSpec_Replicated)
return ok
} | go | {
"resource": ""
} |
q32675 | IsGlobalService | train | func IsGlobalService(service *api.Service) bool {
if service == nil {
return false
}
_, ok := service.Spec.GetMode().(*api.ServiceSpec_Global)
return ok
} | go | {
"resource": ""
} |
q32676 | SetServiceTasksRemove | train | func SetServiceTasksRemove(ctx context.Context, s *store.MemoryStore, service *api.Service) {
var (
tasks []*api.Task
err error
)
s.View(func(tx store.ReadTx) {
tasks, err = store.FindTasks(tx, store.ByServiceID(service.ID))
})
if err != nil {
log.G(ctx).WithError(err).Errorf("failed to list tasks")
re... | go | {
"resource": ""
} |
q32677 | DeepcopyEnabled | train | func DeepcopyEnabled(options *google_protobuf.MessageOptions) bool {
return proto.GetBoolExtension(options, E_Deepcopy, true)
} | go | {
"resource": ""
} |
q32678 | New | train | func New(store *store.MemoryStore) *Deallocator {
return &Deallocator{
store: store,
services: make(map[string]*serviceWithTaskCounts),
stopChan: make(chan struct{}),
doneChan: make(chan struct{}),
}
} | go | {
"resource": ""
} |
q32679 | notifyEventChan | train | func (deallocator *Deallocator) notifyEventChan(updated bool) {
if deallocator.eventChan != nil {
deallocator.eventChan <- updated
}
} | go | {
"resource": ""
} |
q32680 | processService | train | func (deallocator *Deallocator) processService(ctx context.Context, service *api.Service) (bool, error) {
if !service.PendingDelete {
return false, nil
}
var (
tasks []*api.Task
err error
)
deallocator.store.View(func(tx store.ReadTx) {
tasks, err = store.FindTasks(tx, store.ByServiceID(service.ID))
}... | go | {
"resource": ""
} |
q32681 | processNewEvent | train | func (deallocator *Deallocator) processNewEvent(ctx context.Context, event events.Event) (bool, error) {
switch typedEvent := event.(type) {
case api.EventDeleteTask:
serviceID := typedEvent.Task.ServiceID
if serviceWithCount, present := deallocator.services[serviceID]; present {
if serviceWithCount.taskCount... | go | {
"resource": ""
} |
q32682 | NewSecurityConfig | train | func NewSecurityConfig(rootCA *RootCA, krw *KeyReadWriter, tlsKeyPair *tls.Certificate, issuerInfo *IssuerInfo) (*SecurityConfig, func() error, error) {
// Create the Server TLS Credentials for this node. These will not be used by workers.
serverTLSCreds, err := rootCA.NewServerTLSCredentials(tlsKeyPair)
if err != n... | go | {
"resource": ""
} |
q32683 | RootCA | train | func (s *SecurityConfig) RootCA() *RootCA {
s.mu.Lock()
defer s.mu.Unlock()
return s.rootCA
} | go | {
"resource": ""
} |
q32684 | UpdateRootCA | train | func (s *SecurityConfig) UpdateRootCA(rootCA *RootCA) error {
s.mu.Lock()
defer s.mu.Unlock()
// refuse to update the root CA if the current TLS credentials do not validate against it
if err := validateRootCAAndTLSCert(rootCA, s.certificate); err != nil {
return err
}
s.rootCA = rootCA
return s.updateTLSCred... | go | {
"resource": ""
} |
q32685 | IssuerInfo | train | func (s *SecurityConfig) IssuerInfo() *IssuerInfo {
s.mu.Lock()
defer s.mu.Unlock()
return s.issuerInfo
} | go | {
"resource": ""
} |
q32686 | updateTLSCredentials | train | func (s *SecurityConfig) updateTLSCredentials(certificate *tls.Certificate, issuerInfo *IssuerInfo) error {
certs := []tls.Certificate{*certificate}
clientConfig, err := NewClientTLSConfig(certs, s.rootCA.Pool, ManagerRole)
if err != nil {
return errors.Wrap(err, "failed to create a new client config using the new... | go | {
"resource": ""
} |
q32687 | UpdateTLSCredentials | train | func (s *SecurityConfig) UpdateTLSCredentials(certificate *tls.Certificate, issuerInfo *IssuerInfo) error {
s.mu.Lock()
defer s.mu.Unlock()
return s.updateTLSCredentials(certificate, issuerInfo)
} | go | {
"resource": ""
} |
q32688 | NewConfigPaths | train | func NewConfigPaths(baseCertDir string) *SecurityConfigPaths {
return &SecurityConfigPaths{
Node: CertPaths{
Cert: filepath.Join(baseCertDir, nodeTLSCertFilename),
Key: filepath.Join(baseCertDir, nodeTLSKeyFilename)},
RootCA: CertPaths{
Cert: filepath.Join(baseCertDir, rootCACertFilename),
Key: filep... | go | {
"resource": ""
} |
q32689 | DownloadRootCA | train | func DownloadRootCA(ctx context.Context, paths CertPaths, token string, connBroker *connectionbroker.Broker) (RootCA, error) {
var rootCA RootCA
// Get a digest for the optional CA hash string that we've been provided
// If we were provided a non-empty string, and it is an invalid hash, return
// otherwise, allow t... | go | {
"resource": ""
} |
q32690 | LoadSecurityConfig | train | func LoadSecurityConfig(ctx context.Context, rootCA RootCA, krw *KeyReadWriter, allowExpired bool) (*SecurityConfig, func() error, error) {
ctx = log.WithModule(ctx, "tls")
// At this point we've successfully loaded the CA details from disk, or
// successfully downloaded them remotely. The next step is to try to
/... | go | {
"resource": ""
} |
q32691 | CreateSecurityConfig | train | func (rootCA RootCA) CreateSecurityConfig(ctx context.Context, krw *KeyReadWriter, config CertificateRequestConfig) (*SecurityConfig, func() error, error) {
ctx = log.WithModule(ctx, "tls")
// Create a new random ID for this certificate
cn := identity.NewID()
org := config.Organization
if config.Organization == "... | go | {
"resource": ""
} |
q32692 | RenewTLSConfigNow | train | func RenewTLSConfigNow(ctx context.Context, s *SecurityConfig, connBroker *connectionbroker.Broker, rootPaths CertPaths) error {
s.renewalMu.Lock()
defer s.renewalMu.Unlock()
ctx = log.WithModule(ctx, "tls")
log := log.G(ctx).WithFields(logrus.Fields{
"node.id": s.ClientTLSCreds.NodeID(),
"node.role": s.Clie... | go | {
"resource": ""
} |
q32693 | calculateRandomExpiry | train | func calculateRandomExpiry(validFrom, validUntil time.Time) time.Duration {
duration := validUntil.Sub(validFrom)
var randomExpiry int
// Our lower bound of renewal will be half of the total expiration time
minValidity := int(duration.Minutes() * CertLowerRotationRange)
// Our upper bound of renewal will be 80% o... | go | {
"resource": ""
} |
q32694 | NewServerTLSConfig | train | func NewServerTLSConfig(certs []tls.Certificate, rootCAPool *x509.CertPool) (*tls.Config, error) {
if rootCAPool == nil {
return nil, errors.New("valid root CA pool required")
}
return &tls.Config{
Certificates: certs,
// Since we're using the same CA server to issue Certificates to new nodes, we can't
// u... | go | {
"resource": ""
} |
q32695 | NewClientTLSConfig | train | func NewClientTLSConfig(certs []tls.Certificate, rootCAPool *x509.CertPool, serverName string) (*tls.Config, error) {
if rootCAPool == nil {
return nil, errors.New("valid root CA pool required")
}
return &tls.Config{
ServerName: serverName,
Certificates: certs,
RootCAs: rootCAPool,
MinVersion: tl... | go | {
"resource": ""
} |
q32696 | NewClientTLSCredentials | train | func (rootCA *RootCA) NewClientTLSCredentials(cert *tls.Certificate, serverName string) (*MutableTLSCreds, error) {
tlsConfig, err := NewClientTLSConfig([]tls.Certificate{*cert}, rootCA.Pool, serverName)
if err != nil {
return nil, err
}
mtls, err := NewMutableTLS(tlsConfig)
return mtls, err
} | go | {
"resource": ""
} |
q32697 | NewServerTLSCredentials | train | func (rootCA *RootCA) NewServerTLSCredentials(cert *tls.Certificate) (*MutableTLSCreds, error) {
tlsConfig, err := NewServerTLSConfig([]tls.Certificate{*cert}, rootCA.Pool)
if err != nil {
return nil, err
}
mtls, err := NewMutableTLS(tlsConfig)
return mtls, err
} | go | {
"resource": ""
} |
q32698 | ParseRole | train | func ParseRole(apiRole api.NodeRole) (string, error) {
switch apiRole {
case api.NodeRoleManager:
return ManagerRole, nil
case api.NodeRoleWorker:
return WorkerRole, nil
default:
return "", errors.Errorf("failed to parse api role: %v", apiRole)
}
} | go | {
"resource": ""
} |
q32699 | FormatRole | train | func FormatRole(role string) (api.NodeRole, error) {
switch strings.ToLower(role) {
case strings.ToLower(ManagerRole):
return api.NodeRoleManager, nil
case strings.ToLower(WorkerRole):
return api.NodeRoleWorker, nil
default:
return 0, errors.Errorf("failed to parse role: %s", role)
}
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.