// vcsPreflight returns the metadata for the VCS directory path.
177442
func vcsPreflight(path string) error {
	vcs, err := vcsDetect(path)
	if err != nil {
		return fmt.Errorf("error detecting VCS: %s", err)
	}

	if vcs.Preflight != nil {
		return vcs.Preflight(path)
	}

	return nil
}
463628
func (d *OvsDriver) AddSvcSpec(svcName string, spec *core.ServiceSpec) error {
	log.Infof("AddSvcSpec: %s", svcName)
	ss := convSvcSpec(spec)
	errs := ""
	for _, sw := range d.switchDb {
		log.Infof("sw AddSvcSpec: %s", svcName)
		err := sw.AddSvcSpec(svcName, ss)
		if err != nil {
			errs += err.Error()
		}
	}

	err := d.HostProxy.AddSvcSpec(svcName, spec)
	if err != nil {
		errs += err.Error()
	}

	if errs != "" {
		return errors.New(errs)
	}

	d.nameServer.AddLbService(nameserver.K8sDefaultTenant, svcName, spec.IPAddress)

	return nil
}
388022
func (d *VppDriver) AddSvcSpec(svcName string, spec *core.ServiceSpec) error {
	log.Infof("Not implemented")
	return nil
}
577669
func (sw *OvsSwitch) AddSvcSpec(svcName string, spec *ofnet.ServiceSpec) error {
	log.Infof("OvsSwitch AddSvcSpec %s", svcName)
	if sw.ofnetAgent != nil {
		return sw.ofnetAgent.AddSvcSpec(svcName, spec)
	}

	return nil
}
1275500
func (client *Client) DescribeVpcs(args *DescribeVpcsArgs) (vpcs []VpcSetType, pagination *common.PaginationResult, err error) {
	response, err := client.DescribeVpcsWithRaw(args)
	if err != nil {
		return nil, nil, err
	}

	return response.Vpcs.Vpc, &response.PaginationResult, nil
}
244131
func destinations(svc *Service) ([]*Destination, error) {
	msg, err := netlink.NewMessage(C.IPVS_CMD_GET_DEST, family, netlink.MFDump)
	if err != nil {
		return nil, err
	}
	defer msg.Free()

	ic := &ipvsCommand{Service: newIPVSService(svc)}
	if err := msg.Marshal(ic); err != nil {
		return nil, err
	}

	var dsts []*Destination
	cb := func(msg *netlink.Message, arg interface{}) error {
		ic := &ipvsCommand{}
		if err := msg.Unmarshal(ic); err != nil {
			return fmt.Errorf("failed to unmarshal service: %v", err)
		}
		if ic.Destination == nil {
			return errors.New("no destination in unmarshalled message")
		}
		dsts = append(dsts, ic.Destination.toDestination())
		return nil
	}
	if err := msg.SendCallback(cb, nil); err != nil {
		return nil, err
	}
	return dsts, nil
}
983515
func (vm *VirtualMachine) GetVirtualDiskPath(ctx context.Context) (string, error) {
	vmDevices, err := vm.Device(ctx)
	if err != nil {
		klog.Errorf("Failed to get the devices for VM: %q. err: %+v", vm.InventoryPath, err)
		return "", err
	}
	// filter vm devices to retrieve device for the given vmdk file identified by disk path
	for _, device := range vmDevices {
		if vmDevices.TypeName(device) == "VirtualDisk" {
			virtualDevice := device.GetVirtualDevice()
			if backing, ok := virtualDevice.Backing.(*types.VirtualDiskFlatVer2BackingInfo); ok {
				return backing.FileName, nil
			}
		}
	}
	return "", nil
}
106522
func (d *Domain) ManagedSaveRemove(flags uint32) error {
	var err C.virError
	ret := C.virDomainManagedSaveRemoveWrapper(d.ptr, C.uint(flags), &err)
	if ret == -1 {
		return makeError(&err)
	}

	return nil
}
906761
func gitPreflight(path string) error {
	var stderr, stdout bytes.Buffer

	cmd := exec.Command("git", "--version")
	cmd.Dir = path
	cmd.Stdout = &stdout
	cmd.Stderr = &stderr
	if err := cmd.Run(); err != nil {
		return fmt.Errorf("error getting git version: %s\nstdout: %s\nstderr: %s",
			err, stdout.String(), stderr.String())
	}

	// Check if the output is valid
	output := strings.Split(strings.TrimSpace(stdout.String()), " ")
	if len(output) < 1 {
		log.Printf("[WARN] could not extract version output from Git")
		return nil
	}

	// Parse the version
	gitv, err := version.NewVersion(output[len(output)-1])
	if err != nil {
		log.Printf("[WARN] could not parse version output from Git")
		return nil
	}

	constraint, err := version.NewConstraint("> 1.8")
	if err != nil {
		log.Printf("[WARN] could not create version constraint to check")
		return nil
	}
	if !constraint.Check(gitv) {
		return fmt.Errorf("git version (%s) is too old, please upgrade", gitv.String())
	}

	return nil
}
63976
func (_class VMClass) GetSRsRequiredForRecovery(sessionID SessionRef, self VMRef, sessionTo SessionRef) (_retval []SRRef, _err error) {
	_method := "VM.get_SRs_required_for_recovery"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertVMRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_sessionToArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_to"), sessionTo)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg, _sessionToArg)
	if _err != nil {
		return
	}
	_retval, _err = convertSRRefSetToGo(_method + " -> ", _result.Value)
	return
}
299185
func vcsMetadata(path string) (map[string]string, error) {
	vcs, err := vcsDetect(path)
	if err != nil {
		return nil, fmt.Errorf("error detecting VCS: %s", err)
	}

	if vcs.Metadata != nil {
		return vcs.Metadata(path)
	}

	return nil, nil
}
277228
func NewTiKVAndPDClient(cluster *Cluster, mvccStore MVCCStore, path string) (*RPCClient, pd.Client, error) {
	if cluster == nil {
		cluster = NewCluster()
		BootstrapWithSingleStore(cluster)
	}

	if mvccStore == nil {
		var err error
		mvccStore, err = NewMVCCLevelDB(path)
		if err != nil {
			return nil, nil, errors.Trace(err)
		}
	}

	return NewRPCClient(cluster, mvccStore), NewPDClient(cluster), nil
}
103628
func (c *Client) StatVFS(path string) (*StatVFS, error) {
	// send the StatVFS packet to the server
	id := c.nextID()
	typ, data, err := c.sendPacket(sshFxpStatvfsPacket{
		ID:   id,
		Path: path,
	})
	if err != nil {
		return nil, err
	}

	switch typ {
	// server responded with valid data
	case ssh_FXP_EXTENDED_REPLY:
		var response StatVFS
		err = binary.Read(bytes.NewReader(data), binary.BigEndian, &response)
		if err != nil {
			return nil, errors.New("can not parse reply")
		}

		return &response, nil

	// the resquest failed
	case ssh_FXP_STATUS:
		return nil, errors.New(fxp(ssh_FXP_STATUS).String())

	default:
		return nil, unimplementedPacketErr(typ)
	}
}
986100
func (p *NodeSvcProxy) AddSvcSpec(svcName string, spec *core.ServiceSpec) error {
	p.Mutex.Lock()
	defer p.Mutex.Unlock()
	log.Infof("Node proxy AddSvcSpec: %s", svcName)
	// Determine if this is a node service
	isNodeSvc := false
	for _, port := range spec.Ports {
		if port.NodePort != 0 && port.Protocol == "TCP" {
			isNodeSvc = true
			if p.detectClash(svcName, port.NodePort) {
				return nil
			}
		}
	}

	if !isNodeSvc {
		p.deleteSvc(svcName) // delete it if it exists
		return nil
	}

	p.SvcMap[svcName] = *spec
	p.syncSvc(svcName)
	return nil
}
103977
func lookVCS(dir string) (*vcsCmd, error) {
	for _, vcsDir := range []string{".git", ".hg", ".bzr", ".svn"} {
		_, err := os.Stat(filepath.Join(dir, vcsDir))
		if os.IsNotExist(err) {
			continue
		}
		if err != nil {
			return nil, err
		}
		vcs := vcsByCmd(vcsDir[1:])
		if vcs == nil {
			return nil, fmt.Errorf("unknown version control system %q", vcsDir[1:])
		}
		return vcs, nil
	}
	return nil, fmt.Errorf("no repo found: %s", dir)
}
823531
func runPreflight(c workflow.RunData) error {
	j, ok := c.(JoinData)
	if !ok {
		return errors.New("preflight phase invoked with an invalid data struct")
	}
	fmt.Println("[preflight] Running pre-flight checks")

	// Start with general checks
	klog.V(1).Infoln("[preflight] Running general checks")
	if err := preflight.RunJoinNodeChecks(utilsexec.New(), j.Cfg(), j.IgnorePreflightErrors()); err != nil {
		return err
	}

	initCfg, err := j.InitCfg()
	if err != nil {
		return err
	}

	// Continue with more specific checks based on the init configuration
	klog.V(1).Infoln("[preflight] Running configuration dependant checks")
	if err := preflight.RunOptionalJoinNodeChecks(utilsexec.New(), &initCfg.ClusterConfiguration, j.IgnorePreflightErrors()); err != nil {
		return err
	}

	if j.Cfg().ControlPlane != nil {
		// Checks if the cluster configuration supports
		// joining a new control plane instance and if all the necessary certificates are provided
		hasCertificateKey := len(j.CertificateKey()) > 0
		if err := checkIfReadyForAdditionalControlPlane(&initCfg.ClusterConfiguration, hasCertificateKey); err != nil {
			// outputs the not ready for hosting a new control plane instance message
			ctx := map[string]string{
				"Error": err.Error(),
			}

			var msg bytes.Buffer
			notReadyToJoinControlPlaneTemp.Execute(&msg, ctx)
			return errors.New(msg.String())
		}

		// run kubeadm init preflight checks for checking all the prerequisites
		fmt.Println("[preflight] Running pre-flight checks before initializing the new control plane instance")

		if err := preflight.RunInitNodeChecks(utilsexec.New(), initCfg, j.IgnorePreflightErrors(), true, hasCertificateKey); err != nil {
			return err
		}

		fmt.Println("[preflight] Pulling images required for setting up a Kubernetes cluster")
		fmt.Println("[preflight] This might take a minute or two, depending on the speed of your internet connection")
		fmt.Println("[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'")
		if err := preflight.RunPullImagesCheck(utilsexec.New(), initCfg, j.IgnorePreflightErrors()); err != nil {
			return err
		}
	}
	return nil
}
208431
func RemotesDocs(serverType string, services map[string]*component.Service, getPtrNames bool) (map[string]interface{}, error) {
	docs := &docs{
		Remotes: map[string]*doc{},
	}

	for serviceName, service := range services {
		for name, remote := range service.Remotes {
			routeName := route.NewRoute(serverType, serviceName, name)
			docs.Remotes[routeName.String()] = docForMethod(remote.Method, getPtrNames)
		}
	}

	return docs.Remotes.toMap()
}