_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q32700 | New | train | func New(store *store.MemoryStore) *TaskReaper {
return &TaskReaper{
store: store,
dirty: make(map[orchestrator.SlotTuple]struct{}),
stopChan: make(chan struct{}),
doneChan: make(chan struct{}),
}
} | go | {
"resource": ""
} |
q32701 | taskInTerminalState | train | func taskInTerminalState(task *api.Task) bool {
return task.Status.State > api.TaskStateRunning
} | go | {
"resource": ""
} |
q32702 | taskWillNeverRun | train | func taskWillNeverRun(task *api.Task) bool {
return task.Status.State < api.TaskStateAssigned && task.DesiredState > api.TaskStateRunning
} | go | {
"resource": ""
} |
q32703 | CreateConfig | train | func CreateConfig(tx Tx, c *api.Config) error {
// Ensure the name is not already in use.
if tx.lookup(tableConfig, indexName, strings.ToLower(c.Spec.Annotations.Name)) != nil {
return ErrNameConflict
}
return tx.create(tableConfig, c)
} | go | {
"resource": ""
} |
q32704 | UpdateConfig | train | func UpdateConfig(tx Tx, c *api.Config) error {
// Ensure the name is either not in use or already used by this same Config.
if existing := tx.lookup(tableConfig, indexName, strings.ToLower(c.Spec.Annotations.Name)); existing != nil {
if existing.GetID() != c.ID {
return ErrNameConflict
}
}
return tx.update... | go | {
"resource": ""
} |
q32705 | DeleteConfig | train | func DeleteConfig(tx Tx, id string) error {
return tx.delete(tableConfig, id)
} | go | {
"resource": ""
} |
q32706 | GetConfig | train | func GetConfig(tx ReadTx, id string) *api.Config {
c := tx.get(tableConfig, id)
if c == nil {
return nil
}
return c.(*api.Config)
} | go | {
"resource": ""
} |
q32707 | FindConfigs | train | func FindConfigs(tx ReadTx, by By) ([]*api.Config, error) {
checkType := func(by By) error {
switch by.(type) {
case byName, byNamePrefix, byIDPrefix, byCustom, byCustomPrefix:
return nil
default:
return ErrInvalidFindBy
}
}
configList := []*api.Config{}
appendResult := func(o api.StoreObject) {
co... | go | {
"resource": ""
} |
q32708 | Decrypt | train | func (m MultiDecrypter) Decrypt(r api.MaybeEncryptedRecord) ([]byte, error) {
decrypters, ok := m.decrypters[r.Algorithm]
if !ok {
return nil, fmt.Errorf("cannot decrypt record encrypted using %s",
api.MaybeEncryptedRecord_Algorithm_name[int32(r.Algorithm)])
}
var rerr error
for _, d := range decrypters {
r... | go | {
"resource": ""
} |
q32709 | NewMultiDecrypter | train | func NewMultiDecrypter(decrypters ...Decrypter) MultiDecrypter {
m := MultiDecrypter{decrypters: make(map[api.MaybeEncryptedRecord_Algorithm][]Decrypter)}
for _, d := range decrypters {
if md, ok := d.(MultiDecrypter); ok {
for algo, dec := range md.decrypters {
m.decrypters[algo] = append(m.decrypters[algo]... | go | {
"resource": ""
} |
q32710 | Decrypt | train | func Decrypt(encryptd []byte, decrypter Decrypter) ([]byte, error) {
if decrypter == nil {
return nil, ErrCannotDecrypt{msg: "no decrypter specified"}
}
r := api.MaybeEncryptedRecord{}
if err := proto.Unmarshal(encryptd, &r); err != nil {
// nope, this wasn't marshalled as a MaybeEncryptedRecord
return nil, E... | go | {
"resource": ""
} |
q32711 | Encrypt | train | func Encrypt(plaintext []byte, encrypter Encrypter) ([]byte, error) {
if encrypter == nil {
return nil, fmt.Errorf("no encrypter specified")
}
encryptedRecord, err := encrypter.Encrypt(plaintext)
if err != nil {
return nil, errors.Wrap(err, "unable to encrypt data")
}
data, err := proto.Marshal(encryptedRec... | go | {
"resource": ""
} |
q32712 | Defaults | train | func Defaults(key []byte, fips bool) (Encrypter, Decrypter) {
f := NewFernet(key)
if fips {
return f, f
}
n := NewNACLSecretbox(key)
return n, NewMultiDecrypter(n, f)
} | go | {
"resource": ""
} |
q32713 | GenerateSecretKey | train | func GenerateSecretKey() []byte {
secretData := make([]byte, naclSecretboxKeySize)
if _, err := io.ReadFull(cryptorand.Reader, secretData); err != nil {
// panic if we can't read random data
panic(errors.Wrap(err, "failed to read random bytes"))
}
return secretData
} | go | {
"resource": ""
} |
q32714 | ParseHumanReadableKey | train | func ParseHumanReadableKey(key string) ([]byte, error) {
if !strings.HasPrefix(key, humanReadablePrefix) {
return nil, fmt.Errorf("invalid key string")
}
keyBytes, err := base64.RawStdEncoding.DecodeString(strings.TrimPrefix(key, humanReadablePrefix))
if err != nil {
return nil, fmt.Errorf("invalid key string")... | go | {
"resource": ""
} |
q32715 | NewSet | train | func NewSet(key string, vals ...string) []*api.GenericResource {
rs := make([]*api.GenericResource, 0, len(vals))
for _, v := range vals {
rs = append(rs, NewString(key, v))
}
return rs
} | go | {
"resource": ""
} |
q32716 | NewString | train | func NewString(key, val string) *api.GenericResource {
return &api.GenericResource{
Resource: &api.GenericResource_NamedResourceSpec{
NamedResourceSpec: &api.NamedGenericResource{
Kind: key,
Value: val,
},
},
}
} | go | {
"resource": ""
} |
q32717 | NewDiscrete | train | func NewDiscrete(key string, val int64) *api.GenericResource {
return &api.GenericResource{
Resource: &api.GenericResource_DiscreteResourceSpec{
DiscreteResourceSpec: &api.DiscreteGenericResource{
Kind: key,
Value: val,
},
},
}
} | go | {
"resource": ""
} |
q32718 | GetResource | train | func GetResource(kind string, resources []*api.GenericResource) []*api.GenericResource {
var res []*api.GenericResource
for _, r := range resources {
if Kind(r) != kind {
continue
}
res = append(res, r)
}
return res
} | go | {
"resource": ""
} |
q32719 | ConsumeNodeResources | train | func ConsumeNodeResources(nodeAvailableResources *[]*api.GenericResource, res []*api.GenericResource) {
if nodeAvailableResources == nil {
return
}
w := 0
loop:
for _, na := range *nodeAvailableResources {
for _, r := range res {
if Kind(na) != Kind(r) {
continue
}
if remove(na, r) {
continu... | go | {
"resource": ""
} |
q32720 | remove | train | func remove(na, r *api.GenericResource) bool {
switch tr := r.Resource.(type) {
case *api.GenericResource_DiscreteResourceSpec:
if na.GetDiscreteResourceSpec() == nil {
return false // Type change, ignore
}
na.GetDiscreteResourceSpec().Value -= tr.DiscreteResourceSpec.Value
if na.GetDiscreteResourceSpec()... | go | {
"resource": ""
} |
q32721 | TasksEqualStable | train | func TasksEqualStable(a, b *api.Task) bool {
// shallow copy
copyA, copyB := *a, *b
copyA.Status, copyB.Status = api.TaskStatus{}, api.TaskStatus{}
copyA.Meta, copyB.Meta = api.Meta{}, api.Meta{}
return reflect.DeepEqual(©A, ©B)
} | go | {
"resource": ""
} |
q32722 | TaskStatusesEqualStable | train | func TaskStatusesEqualStable(a, b *api.TaskStatus) bool {
copyA, copyB := *a, *b
copyA.Timestamp, copyB.Timestamp = nil, nil
return reflect.DeepEqual(©A, ©B)
} | go | {
"resource": ""
} |
q32723 | RootCAEqualStable | train | func RootCAEqualStable(a, b *api.RootCA) bool {
if a == nil && b == nil {
return true
}
if a == nil || b == nil {
return false
}
var aRotationKey, bRotationKey []byte
if a.RootRotation != nil {
aRotationKey = a.RootRotation.CAKey
}
if b.RootRotation != nil {
bRotationKey = b.RootRotation.CAKey
}
if s... | go | {
"resource": ""
} |
q32724 | ExternalCAsEqualStable | train | func ExternalCAsEqualStable(a, b []*api.ExternalCA) bool {
// because DeepEqual will treat an empty list and a nil list differently, we want to manually check this first
if len(a) == 0 && len(b) == 0 {
return true
}
// The assumption is that each individual api.ExternalCA within both lists are created from deseri... | go | {
"resource": ""
} |
q32725 | ValidateSecretPayload | train | func ValidateSecretPayload(data []byte) error {
if len(data) >= MaxSecretSize || len(data) < 1 {
return fmt.Errorf("secret data must be larger than 0 and less than %d bytes", MaxSecretSize)
}
return nil
} | go | {
"resource": ""
} |
q32726 | WithTimeout | train | func WithTimeout(timeout time.Duration) func(*Queue) error {
return func(q *Queue) error {
q.sinkGen = NewTimeoutDropErrSinkGen(timeout)
return nil
}
} | go | {
"resource": ""
} |
q32727 | WithCloseOutChan | train | func WithCloseOutChan() func(*Queue) error {
return func(q *Queue) error {
q.closeOutChan = true
return nil
}
} | go | {
"resource": ""
} |
q32728 | WithLimit | train | func WithLimit(limit uint64) func(*Queue) error {
return func(q *Queue) error {
q.limit = limit
return nil
}
} | go | {
"resource": ""
} |
q32729 | Watch | train | func (q *Queue) Watch() (eventq chan events.Event, cancel func()) {
return q.CallbackWatch(nil)
} | go | {
"resource": ""
} |
q32730 | WatchContext | train | func (q *Queue) WatchContext(ctx context.Context) (eventq chan events.Event) {
return q.CallbackWatchContext(ctx, nil)
} | go | {
"resource": ""
} |
q32731 | CallbackWatch | train | func (q *Queue) CallbackWatch(matcher events.Matcher) (eventq chan events.Event, cancel func()) {
chanSink, ch := q.sinkGen.NewChannelSink()
lq := queue.NewLimitQueue(chanSink, q.limit)
sink := events.Sink(lq)
if matcher != nil {
sink = events.NewFilter(sink, matcher)
}
q.broadcast.Add(sink)
cancelFunc := f... | go | {
"resource": ""
} |
q32732 | CallbackWatchContext | train | func (q *Queue) CallbackWatchContext(ctx context.Context, matcher events.Matcher) (eventq chan events.Event) {
c, cancel := q.CallbackWatch(matcher)
go func() {
<-ctx.Done()
cancel()
}()
return c
} | go | {
"resource": ""
} |
q32733 | Publish | train | func (q *Queue) Publish(item events.Event) {
q.broadcast.Write(item)
} | go | {
"resource": ""
} |
q32734 | Close | train | func (q *Queue) Close() error {
// Make sure all watchers have been closed to avoid a deadlock when
// closing the broadcaster.
q.mu.Lock()
for _, cancelFunc := range q.cancelFuncs {
cancelFunc()
}
q.cancelFuncs = make(map[events.Sink]func())
q.mu.Unlock()
return q.broadcast.Close()
} | go | {
"resource": ""
} |
q32735 | MustTimestampProto | train | func MustTimestampProto(t time.Time) *gogotypes.Timestamp {
ts, err := gogotypes.TimestampProto(t)
if err != nil {
panic(err.Error())
}
return ts
} | go | {
"resource": ""
} |
q32736 | NewReplicatedOrchestrator | train | func NewReplicatedOrchestrator(store *store.MemoryStore) *Orchestrator {
restartSupervisor := restart.NewSupervisor(store)
updater := update.NewSupervisor(store, restartSupervisor)
return &Orchestrator{
store: store,
stopChan: make(chan struct{}),
doneChan: make(chan struct{}),
... | go | {
"resource": ""
} |
q32737 | Run | train | func (r *Orchestrator) Run(ctx context.Context) error {
defer close(r.doneChan)
// Watch changes to services and tasks
queue := r.store.WatchQueue()
watcher, cancel := queue.Watch()
defer cancel()
// Balance existing services and drain initial tasks attached to invalid
// nodes
var err error
r.store.View(fun... | go | {
"resource": ""
} |
q32738 | SetLocalConn | train | func (b *Broker) SetLocalConn(localConn *grpc.ClientConn) {
b.mu.Lock()
defer b.mu.Unlock()
b.localConn = localConn
} | go | {
"resource": ""
} |
q32739 | Select | train | func (b *Broker) Select(dialOpts ...grpc.DialOption) (*Conn, error) {
b.mu.Lock()
localConn := b.localConn
b.mu.Unlock()
if localConn != nil {
return &Conn{
ClientConn: localConn,
isLocal: true,
}, nil
}
return b.SelectRemote(dialOpts...)
} | go | {
"resource": ""
} |
q32740 | SelectRemote | train | func (b *Broker) SelectRemote(dialOpts ...grpc.DialOption) (*Conn, error) {
peer, err := b.remotes.Select()
if err != nil {
return nil, err
}
// gRPC dialer connects to proxy first. Provide a custom dialer here avoid that.
// TODO(anshul) Add an option to configure this.
dialOpts = append(dialOpts,
grpc.Wit... | go | {
"resource": ""
} |
q32741 | Close | train | func (c *Conn) Close(success bool) error {
if c.isLocal {
return nil
}
if success {
c.remotes.ObserveIfExists(c.peer, remotes.DefaultObservationWeight)
} else {
c.remotes.ObserveIfExists(c.peer, -remotes.DefaultObservationWeight)
}
return c.ClientConn.Close()
} | go | {
"resource": ""
} |
q32742 | SetTask | train | func (f *ConstraintFilter) SetTask(t *api.Task) bool {
if t.Spec.Placement == nil || len(t.Spec.Placement.Constraints) == 0 {
return false
}
constraints, err := constraint.Parse(t.Spec.Placement.Constraints)
if err != nil {
// constraints have been validated at controlapi
// if in any case it finds an error ... | go | {
"resource": ""
} |
q32743 | Check | train | func (f *ConstraintFilter) Check(n *NodeInfo) bool {
return constraint.NodeMatches(f.constraints, n.Node)
} | go | {
"resource": ""
} |
q32744 | SetTask | train | func (f *MaxReplicasFilter) SetTask(t *api.Task) bool {
if t.Spec.Placement != nil && t.Spec.Placement.MaxReplicas > 0 {
f.t = t
return true
}
return false
} | go | {
"resource": ""
} |
q32745 | Dial | train | func Dial(cmd *cobra.Command) (api.ControlClient, error) {
conn, err := DialConn(cmd)
if err != nil {
return nil, err
}
return api.NewControlClient(conn), nil
} | go | {
"resource": ""
} |
q32746 | DialConn | train | func DialConn(cmd *cobra.Command) (*grpc.ClientConn, error) {
addr, err := cmd.Flags().GetString("socket")
if err != nil {
return nil, err
}
opts := []grpc.DialOption{}
insecureCreds := credentials.NewTLS(&tls.Config{InsecureSkipVerify: true})
opts = append(opts, grpc.WithTransportCredentials(insecureCreds))
... | go | {
"resource": ""
} |
q32747 | ParseLogDriverFlags | train | func ParseLogDriverFlags(flags *pflag.FlagSet) (*api.Driver, error) {
if !flags.Changed("log-driver") {
return nil, nil
}
name, err := flags.GetString("log-driver")
if err != nil {
return nil, err
}
var opts map[string]string
if flags.Changed("log-opt") {
rawOpts, err := flags.GetStringSlice("log-opt")
... | go | {
"resource": ""
} |
q32748 | WithMetadataForwardTLSInfo | train | func WithMetadataForwardTLSInfo(ctx context.Context) (context.Context, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
md = metadata.MD{}
}
ous := []string{}
org := ""
cn := ""
certSubj, err := certSubjectFromContext(ctx)
if err == nil {
cn = certSubj.CommonName
ous = certSubj.Organization... | go | {
"resource": ""
} |
q32749 | NewServer | train | func NewServer(store *store.MemoryStore, securityConfig *SecurityConfig) *Server {
return &Server{
store: store,
securityConfig: securityConfig,
localRootCA: securityConfig.RootCA(),
externalCA: NewExternalCA(nil, nil),
pendi... | go | {
"resource": ""
} |
q32750 | ExternalCA | train | func (s *Server) ExternalCA() *ExternalCA {
s.signingMu.Lock()
defer s.signingMu.Unlock()
return s.externalCA
} | go | {
"resource": ""
} |
q32751 | RootCA | train | func (s *Server) RootCA() *RootCA {
s.signingMu.Lock()
defer s.signingMu.Unlock()
return s.localRootCA
} | go | {
"resource": ""
} |
q32752 | GetUnlockKey | train | func (s *Server) GetUnlockKey(ctx context.Context, request *api.GetUnlockKeyRequest) (*api.GetUnlockKeyResponse, error) {
// This directly queries the store, rather than storing the unlock key and version on
// the `Server` object and updating it `updateCluster` is called, because we need this
// API to return the l... | go | {
"resource": ""
} |
q32753 | NodeCertificateStatus | train | func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCertificateStatusRequest) (*api.NodeCertificateStatusResponse, error) {
if request.NodeID == "" {
return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
}
serverCtx, err := s.isRunningLocked()
if err != nil {
... | go | {
"resource": ""
} |
q32754 | issueRenewCertificate | train | func (s *Server) issueRenewCertificate(ctx context.Context, nodeID string, csr []byte) (*api.IssueNodeCertificateResponse, error) {
var (
cert api.Certificate
node *api.Node
)
err := s.store.Update(func(tx store.Tx) error {
// Attempt to retrieve the node with nodeID
node = store.GetNode(tx, nodeID)
if nod... | go | {
"resource": ""
} |
q32755 | GetRootCACertificate | train | func (s *Server) GetRootCACertificate(ctx context.Context, request *api.GetRootCACertificateRequest) (*api.GetRootCACertificateResponse, error) {
log.G(ctx).WithFields(logrus.Fields{
"method": "GetRootCACertificate",
})
s.signingMu.Lock()
defer s.signingMu.Unlock()
return &api.GetRootCACertificateResponse{
C... | go | {
"resource": ""
} |
q32756 | Stop | train | func (s *Server) Stop() error {
s.mu.Lock()
if !s.isRunning() {
s.mu.Unlock()
return errors.New("CA signer is already stopped")
}
s.cancel()
s.started = make(chan struct{})
s.joinTokens = nil
s.mu.Unlock()
// Wait for Run to complete
s.wg.Wait()
return nil
} | go | {
"resource": ""
} |
q32757 | Ready | train | func (s *Server) Ready() <-chan struct{} {
s.mu.Lock()
defer s.mu.Unlock()
return s.started
} | go | {
"resource": ""
} |
q32758 | filterExternalCAURLS | train | func filterExternalCAURLS(ctx context.Context, desiredCert, defaultCert []byte, apiExternalCAs []*api.ExternalCA) (urls []string) {
desiredCert = NormalizePEMs(desiredCert)
// TODO(aaronl): In the future, this will be abstracted with an ExternalCA interface that has different
// implementations for different CA typ... | go | {
"resource": ""
} |
q32759 | evaluateAndSignNodeCert | train | func (s *Server) evaluateAndSignNodeCert(ctx context.Context, node *api.Node) error {
// If the desired membership and actual state are in sync, there's
// nothing to do.
certState := node.Certificate.Status.State
if node.Spec.Membership == api.NodeMembershipAccepted &&
(certState == api.IssuanceStateIssued || ce... | go | {
"resource": ""
} |
q32760 | reconcileNodeCertificates | train | func (s *Server) reconcileNodeCertificates(ctx context.Context, nodes []*api.Node) error {
for _, node := range nodes {
s.evaluateAndSignNodeCert(ctx, node)
}
return nil
} | go | {
"resource": ""
} |
q32761 | isFinalState | train | func isFinalState(status api.IssuanceStatus) bool {
if status.State == api.IssuanceStateIssued || status.State == api.IssuanceStateFailed ||
status.State == api.IssuanceStateRotate {
return true
}
return false
} | go | {
"resource": ""
} |
q32762 | RootCAFromAPI | train | func RootCAFromAPI(ctx context.Context, apiRootCA *api.RootCA, expiry time.Duration) (RootCA, error) {
var intermediates []byte
signingCert := apiRootCA.CACert
signingKey := apiRootCA.CAKey
if apiRootCA.RootRotation != nil {
signingCert = apiRootCA.RootRotation.CrossSignedCACert
signingKey = apiRootCA.RootRotat... | go | {
"resource": ""
} |
q32763 | ValidateTask | train | func ValidateTask(resources *api.Resources) error {
for _, v := range resources.Generic {
if v.GetDiscreteResourceSpec() != nil {
continue
}
return fmt.Errorf("invalid argument for resource %s", Kind(v))
}
return nil
} | go | {
"resource": ""
} |
q32764 | HasEnough | train | func HasEnough(nodeRes []*api.GenericResource, taskRes *api.GenericResource) (bool, error) {
t := taskRes.GetDiscreteResourceSpec()
if t == nil {
return false, fmt.Errorf("task should only hold Discrete type")
}
if nodeRes == nil {
return false, nil
}
nrs := GetResource(t.Kind, nodeRes)
if len(nrs) == 0 {
... | go | {
"resource": ""
} |
q32765 | HasResource | train | func HasResource(res *api.GenericResource, resources []*api.GenericResource) bool {
for _, r := range resources {
if Kind(res) != Kind(r) {
continue
}
switch rtype := r.Resource.(type) {
case *api.GenericResource_DiscreteResourceSpec:
if res.GetDiscreteResourceSpec() == nil {
return false
}
i... | go | {
"resource": ""
} |
q32766 | GetRequestMetadata | train | func (c *MutableTLSCreds) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {
return nil, nil
} | go | {
"resource": ""
} |
q32767 | ClientHandshake | train | func (c *MutableTLSCreds) ClientHandshake(ctx context.Context, addr string, rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
// borrow all the code from the original TLS credentials
c.Lock()
if c.config.ServerName == "" {
colonPos := strings.LastIndex(addr, ":")
if colonPos == -1 {
colonPos = len(a... | go | {
"resource": ""
} |
q32768 | ServerHandshake | train | func (c *MutableTLSCreds) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) {
c.Lock()
conn := tls.Server(rawConn, c.config)
c.Unlock()
if err := conn.Handshake(); err != nil {
rawConn.Close()
return nil, nil, err
}
return conn, credentials.TLSInfo{State: conn.ConnectionState()}, nil
... | go | {
"resource": ""
} |
q32769 | loadNewTLSConfig | train | func (c *MutableTLSCreds) loadNewTLSConfig(newConfig *tls.Config) error {
newSubject, err := GetAndValidateCertificateSubject(newConfig.Certificates)
if err != nil {
return err
}
c.Lock()
defer c.Unlock()
c.subject = newSubject
c.config = newConfig
return nil
} | go | {
"resource": ""
} |
q32770 | Config | train | func (c *MutableTLSCreds) Config() *tls.Config {
c.Lock()
defer c.Unlock()
return c.config
} | go | {
"resource": ""
} |
q32771 | Role | train | func (c *MutableTLSCreds) Role() string {
c.Lock()
defer c.Unlock()
return c.subject.OrganizationalUnit[0]
} | go | {
"resource": ""
} |
q32772 | Organization | train | func (c *MutableTLSCreds) Organization() string {
c.Lock()
defer c.Unlock()
return c.subject.Organization[0]
} | go | {
"resource": ""
} |
q32773 | NodeID | train | func (c *MutableTLSCreds) NodeID() string {
c.Lock()
defer c.Unlock()
return c.subject.CommonName
} | go | {
"resource": ""
} |
q32774 | NewMutableTLS | train | func NewMutableTLS(c *tls.Config) (*MutableTLSCreds, error) {
originalTC := credentials.NewTLS(c)
if len(c.Certificates) < 1 {
return nil, errors.New("invalid configuration: needs at least one certificate")
}
subject, err := GetAndValidateCertificateSubject(c.Certificates)
if err != nil {
return nil, err
}
... | go | {
"resource": ""
} |
q32775 | GetAndValidateCertificateSubject | train | func GetAndValidateCertificateSubject(certs []tls.Certificate) (pkix.Name, error) {
for i := range certs {
cert := &certs[i]
x509Cert, err := x509.ParseCertificate(cert.Certificate[0])
if err != nil {
continue
}
if len(x509Cert.Subject.OrganizationalUnit) < 1 {
return pkix.Name{}, errors.New("no OU fou... | go | {
"resource": ""
} |
q32776 | Print | train | func Print(tasks []*api.Task, all bool, res *common.Resolver) {
w := tabwriter.NewWriter(os.Stdout, 4, 4, 4, ' ', 0)
defer w.Flush()
common.PrintHeader(w, "Task ID", "Service", "Slot", "Image", "Desired State", "Last State", "Node")
sort.Stable(tasksBySlot(tasks))
for _, t := range tasks {
if !all && t.DesiredS... | go | {
"resource": ""
} |
q32777 | NewExternalCATLSConfig | train | func NewExternalCATLSConfig(certs []tls.Certificate, rootPool *x509.CertPool) *tls.Config {
return &tls.Config{
Certificates: certs,
RootCAs: rootPool,
MinVersion: tls.VersionTLS12,
}
} | go | {
"resource": ""
} |
q32778 | NewExternalCA | train | func NewExternalCA(intermediates []byte, tlsConfig *tls.Config, urls ...string) *ExternalCA {
return &ExternalCA{
ExternalRequestTimeout: 5 * time.Second,
intermediates: intermediates,
urls: urls,
client: &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
... | go | {
"resource": ""
} |
q32779 | UpdateTLSConfig | train | func (eca *ExternalCA) UpdateTLSConfig(tlsConfig *tls.Config) {
eca.mu.Lock()
defer eca.mu.Unlock()
eca.client = &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
}
} | go | {
"resource": ""
} |
q32780 | UpdateURLs | train | func (eca *ExternalCA) UpdateURLs(urls ...string) {
eca.mu.Lock()
defer eca.mu.Unlock()
eca.urls = urls
} | go | {
"resource": ""
} |
q32781 | Sign | train | func (eca *ExternalCA) Sign(ctx context.Context, req signer.SignRequest) (cert []byte, err error) {
// Get the current HTTP client and list of URLs in a small critical
// section. We will use these to make certificate signing requests.
eca.mu.Lock()
urls := eca.urls
client := eca.client
intermediates := eca.inter... | go | {
"resource": ""
} |
q32782 | CrossSignRootCA | train | func (eca *ExternalCA) CrossSignRootCA(ctx context.Context, rca RootCA) ([]byte, error) {
// ExtractCertificateRequest generates a new key request, and we want to continue to use the old
// key. However, ExtractCertificateRequest will also convert the pkix.Name to csr.Name, which we
// need in order to generate a s... | go | {
"resource": ""
} |
q32783 | Task | train | func Task(t *api.Task) string {
if t.Annotations.Name != "" {
// if set, use the container Annotations.Name field, set in the orchestrator.
return t.Annotations.Name
}
slot := fmt.Sprint(t.Slot)
if slot == "" || t.Slot == 0 {
// when no slot id is assigned, we assume that this is node-bound task.
slot = t.... | go | {
"resource": ""
} |
q32784 | CreateService | train | func CreateService(tx Tx, s *api.Service) error {
// Ensure the name is not already in use.
if tx.lookup(tableService, indexName, strings.ToLower(s.Spec.Annotations.Name)) != nil {
return ErrNameConflict
}
return tx.create(tableService, s)
} | go | {
"resource": ""
} |
q32785 | UpdateService | train | func UpdateService(tx Tx, s *api.Service) error {
// Ensure the name is either not in use or already used by this same Service.
if existing := tx.lookup(tableService, indexName, strings.ToLower(s.Spec.Annotations.Name)); existing != nil {
if existing.GetID() != s.ID {
return ErrNameConflict
}
}
return tx.up... | go | {
"resource": ""
} |
q32786 | DeleteService | train | func DeleteService(tx Tx, id string) error {
return tx.delete(tableService, id)
} | go | {
"resource": ""
} |
q32787 | GetService | train | func GetService(tx ReadTx, id string) *api.Service {
s := tx.get(tableService, id)
if s == nil {
return nil
}
return s.(*api.Service)
} | go | {
"resource": ""
} |
q32788 | FindServices | train | func FindServices(tx ReadTx, by By) ([]*api.Service, error) {
checkType := func(by By) error {
switch by.(type) {
case byName, byNamePrefix, byIDPrefix, byRuntime, byReferencedNetworkID, byReferencedSecretID, byReferencedConfigID, byCustom, byCustomPrefix, byAll:
return nil
default:
return ErrInvalidFindBy... | go | {
"resource": ""
} |
q32789 | Beat | train | func (hb *Heartbeat) Beat() {
hb.timer.Reset(time.Duration(atomic.LoadInt64(&hb.timeout)))
} | go | {
"resource": ""
} |
q32790 | Update | train | func (hb *Heartbeat) Update(d time.Duration) {
atomic.StoreInt64(&hb.timeout, int64(d))
} | go | {
"resource": ""
} |
q32791 | displayUnlockKey | train | func displayUnlockKey(cmd *cobra.Command) error {
conn, err := common.DialConn(cmd)
if err != nil {
return err
}
defer conn.Close()
resp, err := api.NewCAClient(conn).GetUnlockKey(common.Context(cmd), &api.GetUnlockKeyRequest{})
if err != nil {
return err
}
if len(resp.UnlockKey) == 0 {
fmt.Printf("Mana... | go | {
"resource": ""
} |
q32792 | New | train | func New(store *store.MemoryStore) *ConstraintEnforcer {
return &ConstraintEnforcer{
store: store,
stopChan: make(chan struct{}),
doneChan: make(chan struct{}),
}
} | go | {
"resource": ""
} |
q32793 | Run | train | func (ce *ConstraintEnforcer) Run() {
defer close(ce.doneChan)
watcher, cancelWatch := state.Watch(ce.store.WatchQueue(), api.EventUpdateNode{})
defer cancelWatch()
var (
nodes []*api.Node
err error
)
ce.store.View(func(readTx store.ReadTx) {
nodes, err = store.FindNodes(readTx, store.All)
})
if err !... | go | {
"resource": ""
} |
q32794 | New | train | func New(pg plugingetter.PluginGetter, netConfig *NetworkConfig) (networkallocator.NetworkAllocator, error) {
na := &cnmNetworkAllocator{
networks: make(map[string]*network),
services: make(map[string]struct{}),
tasks: make(map[string]struct{}),
nodes: make(map[string]map[string]struct{}),
}
// There ... | go | {
"resource": ""
} |
q32795 | Allocate | train | func (na *cnmNetworkAllocator) Allocate(n *api.Network) error {
if _, ok := na.networks[n.ID]; ok {
return fmt.Errorf("network %s already allocated", n.ID)
}
d, err := na.resolveDriver(n)
if err != nil {
return err
}
nw := &network{
nw: n,
endpoints: make(map[string]string),
isNodeLocal: d.... | go | {
"resource": ""
} |
q32796 | Deallocate | train | func (na *cnmNetworkAllocator) Deallocate(n *api.Network) error {
localNet := na.getNetwork(n.ID)
if localNet == nil {
return fmt.Errorf("could not get networker state for network %s", n.ID)
}
// No swarm-level resource deallocation needed for node-local networks
if localNet.isNodeLocal {
delete(na.networks, ... | go | {
"resource": ""
} |
q32797 | AllocateService | train | func (na *cnmNetworkAllocator) AllocateService(s *api.Service) (err error) {
if err = na.portAllocator.serviceAllocatePorts(s); err != nil {
return err
}
defer func() {
if err != nil {
na.DeallocateService(s)
}
}()
if s.Endpoint == nil {
s.Endpoint = &api.Endpoint{}
}
s.Endpoint.Spec = s.Spec.Endpoin... | go | {
"resource": ""
} |
q32798 | DeallocateService | train | func (na *cnmNetworkAllocator) DeallocateService(s *api.Service) error {
if s.Endpoint == nil {
return nil
}
for _, vip := range s.Endpoint.VirtualIPs {
if err := na.deallocateVIP(vip); err != nil {
// don't bail here, deallocate as many as possible.
log.L.WithError(err).
WithField("vip.network", vip.... | go | {
"resource": ""
} |
q32799 | IsAllocated | train | func (na *cnmNetworkAllocator) IsAllocated(n *api.Network) bool {
_, ok := na.networks[n.ID]
return ok
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.