// AddRootNodeWrapper implements the Config interface for ConfigLocal.
499209
func (c *ConfigLocal) AddRootNodeWrapper(f func(Node) Node) {
	c.lock.Lock()
	defer c.lock.Unlock()
	c.rootNodeWrappers = append(c.rootNodeWrappers, f)
}
356714
func (c *ConfigTree) Add(ns []string, inNode Node) {
	c.log(fmt.Sprintf("Adding %v at %s\n", inNode, ns))
	if len(ns) == 0 {
		c.log(fmt.Sprintln("ns is empty - returning with no change to tree"))
		return
	}
	f, remain := ns[0], ns[1:]
	c.log(fmt.Sprintf("first ns (%s) remain (%s)", f, remain))
	if c.root == nil {
		// Create node at root
		c.root = new(node)
		c.root.setKeys([]string{f})

		c.log(fmt.Sprintf("Root now = %v\n", c.root.keys))

		// If remain is empty then the inNode belongs at this root level
		if len(remain) == 0 {
			c.log(fmt.Sprintf("adding node at root level\n"))
			c.root.Node = inNode
			// And return since we are done
			return
		}

	} else {
		if f != c.root.keys[0] {
			panic("Can't add a new root namespace")
		}
	}
	c.root.add(remain, inNode)

}
944446
func (n *Node) getRootNode() *Node {
	if n.parent == nil {
		return n
	}
	return n.parent.getRootNode()
}
97523
func (s *Simulation) AddNodesAndConnectFull(count int, opts ...AddNodeOption) (ids []enode.ID, err error) {
	if count < 2 {
		return nil, errors.New("count of nodes must be at least 2")
	}
	ids, err = s.AddNodes(count, opts...)
	if err != nil {
		return nil, err
	}
	err = s.Net.ConnectNodesFull(ids)
	if err != nil {
		return nil, err
	}
	return ids, nil
}
251957
func (s *Selection) AddMatcher(m Matcher) *Selection {
	return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, m)...)
}
906723
func (t *LaunchConfiguration) buildRootDevice(cloud awsup.AWSCloud) (map[string]*BlockDeviceMapping, error) {
	image := fi.StringValue(t.ImageID)

	// @step: resolve the image ami
	img, err := cloud.ResolveImage(image)
	if err != nil {
		return nil, fmt.Errorf("unable to resolve image: %q: %v", image, err)
	} else if img == nil {
		return nil, fmt.Errorf("unable to resolve image: %q: not found", image)
	}

	bm := make(map[string]*BlockDeviceMapping)

	bm[aws.StringValue(img.RootDeviceName)] = &BlockDeviceMapping{
		EbsDeleteOnTermination: aws.Bool(true),
		EbsVolumeSize:          t.RootVolumeSize,
		EbsVolumeType:          t.RootVolumeType,
		EbsVolumeIops:          t.RootVolumeIops,
	}

	return bm, nil
}
125430
func (cnc *CloudNodeController) AddCloudNode(obj interface{}) {
	node := obj.(*v1.Node)

	cloudTaint := getCloudTaint(node.Spec.Taints)
	if cloudTaint == nil {
		klog.V(2).Infof("This node %s is registered without the cloud taint. Will not process.", node.Name)
		return
	}

	cnc.initializeNode(node)
}
220137
func (g *generateServiceBuilder) AddRootService(spec *compile.ServiceSpec) (api.ServiceID, error) {
	id, err := g.addService(spec)
	if err != nil {
		return id, err
	}

	if _, alreadyAdded := g.rootServices[id]; !alreadyAdded {
		g.RootServices = append(g.RootServices, id)
		g.rootServices[id] = struct{}{}
	}

	return id, err
}
1159265
func (b *BigIP) AddNode(config *Node) error {
	return b.post(config, uriLtm, uriNode)
}
1247001
func (c *ApplyClusterCmd) BuildNodeUpConfig(assetBuilder *assets.AssetBuilder, ig *kops.InstanceGroup) (*nodeup.Config, error) {
	if ig == nil {
		return nil, fmt.Errorf("instanceGroup cannot be nil")
	}

	cluster := c.Cluster

	configBase, err := vfs.Context.BuildVfsPath(cluster.Spec.ConfigBase)
	if err != nil {
		return nil, fmt.Errorf("error parsing config base %q: %v", cluster.Spec.ConfigBase, err)
	}

	// TODO: Remove
	clusterTags, err := buildCloudupTags(cluster)
	if err != nil {
		return nil, err
	}

	channels := []string{
		configBase.Join("addons", "bootstrap-channel.yaml").Path(),
	}

	for i := range c.Cluster.Spec.Addons {
		channels = append(channels, c.Cluster.Spec.Addons[i].Manifest)
	}

	role := ig.Spec.Role
	if role == "" {
		return nil, fmt.Errorf("cannot determine role for instance group: %v", ig.ObjectMeta.Name)
	}

	nodeUpTags, err := buildNodeupTags(role, cluster, clusterTags)
	if err != nil {
		return nil, err
	}

	config := &nodeup.Config{}
	for _, tag := range nodeUpTags.List() {
		config.Tags = append(config.Tags, tag)
	}

	for _, a := range c.Assets {
		config.Assets = append(config.Assets, a.CompactString())
	}
	config.ClusterName = cluster.ObjectMeta.Name
	config.ConfigBase = fi.String(configBase.Path())
	config.InstanceGroupName = ig.ObjectMeta.Name

	var images []*nodeup.Image

	if components.IsBaseURL(cluster.Spec.KubernetesVersion) {
		// When using a custom version, we want to preload the images over http
		components := []string{"kube-proxy"}
		if role == kops.InstanceGroupRoleMaster {
			components = append(components, "kube-apiserver", "kube-controller-manager", "kube-scheduler")
		}

		for _, component := range components {
			baseURL, err := url.Parse(c.Cluster.Spec.KubernetesVersion)
			if err != nil {
				return nil, err
			}

			baseURL.Path = path.Join(baseURL.Path, "/bin/linux/amd64/", component+".tar")

			u, hash, err := assetBuilder.RemapFileAndSHA(baseURL)
			if err != nil {
				return nil, err
			}

			image := &nodeup.Image{
				Sources: []string{u.String()},
				Hash:    hash.Hex(),
			}
			images = append(images, image)
		}
	}

	{
		u, hash, err := ProtokubeImageSource(assetBuilder)
		if err != nil {
			return nil, err
		}

		asset := BuildMirroredAsset(u, hash)

		config.ProtokubeImage = &nodeup.Image{
			Name:    kopsbase.DefaultProtokubeImageName(),
			Sources: asset.Locations,
			Hash:    asset.Hash.Hex(),
		}
	}

	if role == kops.InstanceGroupRoleMaster {
		for _, etcdCluster := range cluster.Spec.EtcdClusters {
			if etcdCluster.Provider == kops.EtcdProviderTypeManager {
				p := configBase.Join("manifests/etcd/" + etcdCluster.Name + ".yaml").Path()
				config.EtcdManifests = append(config.EtcdManifests, p)
			}
		}
	}

	config.Images = images
	config.Channels = channels

	return config, nil
}
551908
func AddOrUpdateTaintOnNode(c clientset.Interface, nodeName string, taints ...*v1.Taint) error {
	if len(taints) == 0 {
		return nil
	}
	firstTry := true
	return clientretry.RetryOnConflict(updateTaintBackoff, func() error {
		var err error
		var oldNode *v1.Node
		// First we try getting node from the API server cache, as it's cheaper. If it fails
		// we get it from etcd to be sure to have fresh data.
		if firstTry {
			oldNode, err = c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{ResourceVersion: "0"})
			firstTry = false
		} else {
			oldNode, err = c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
		}
		if err != nil {
			return err
		}

		var newNode *v1.Node
		oldNodeCopy := oldNode
		updated := false
		for _, taint := range taints {
			curNewNode, ok, err := addOrUpdateTaint(oldNodeCopy, taint)
			if err != nil {
				return fmt.Errorf("failed to update taint of node")
			}
			updated = updated || ok
			newNode = curNewNode
			oldNodeCopy = curNewNode
		}
		if !updated {
			return nil
		}
		return PatchNodeTaints(c, nodeName, oldNode, newNode)
	})
}
1072889
func importsForRootNode(rootNode *ast.File) (imports *ast.GenDecl, err error) {
	for _, declaration := range rootNode.Decls {
		decl, ok := declaration.(*ast.GenDecl)
		if !ok || len(decl.Specs) == 0 {
			continue
		}

		_, ok = decl.Specs[0].(*ast.ImportSpec)
		if ok {
			imports = decl
			return
		}
	}

	err = errors.New(fmt.Sprintf("Could not find imports for root node:\n\t%#v\n", rootNode))
	return
}
498606
func (p *parser) addUnitType(t nodeType) {
	p.unit = newRegexNode(t, p.options)
}
9896
func (gServer *GRPCServer) appendClientRootCA(clientRoot []byte) error {

	errMsg := "Failed to append client root certificate(s): %s"
	//convert to x509
	certs, subjects, err := pemToX509Certs(clientRoot)
	if err != nil {
		return fmt.Errorf(errMsg, err.Error())
	}

	if len(certs) < 1 {
		return fmt.Errorf(errMsg, "No client root certificates found")
	}

	for i, cert := range certs {
		//first add to the ClientCAs
		gServer.tlsConfig.ClientCAs.AddCert(cert)
		//add it to our clientRootCAs map using subject as key
		gServer.clientRootCAs[subjects[i]] = cert
	}
	return nil
}
241884
func (s *Selection) WrapMatcher(m Matcher) *Selection {
	return s.wrapNodes(m.MatchAll(s.document.rootNode)...)
}
504465
func NewRootFlagSet() *pflag.FlagSet {
	flags := &pflag.FlagSet{}

	// root level flags
	flags.BoolP("version", "", false, "Display the build version hash")
	flags.StringP("env", "e", "prod", "The config files environment to load")

	return flags
}
1044414
func (s *UpdateStackInput) SetDefaultRootDeviceType(v string) *UpdateStackInput {
	s.DefaultRootDeviceType = &v
	return s
}