// generateCPU infor generates any model/fallback related settings. These are
// typically to allow for better compatibility across versions of libvirt/qemu AFAIU.
965256
func generateCPU(p domainParams) *CPU {
	if p.Arch() == arch.ARM64 {
		return &CPU{
			Mode:  "custom",
			Match: "exact",
			Model: Model{
				Fallback: "allow",
				Text:     "cortex-a53"},
		}
	}
	return nil
}
1054807
func (c cpuInfo) logicalcpu() int {
	if c.maxFunc < 1 {
		return -1
	}
	_, ebx, _, _ := cpuid(1)
	return int(ebx >> 24)
}
934807
func (l *persistentVolumeLabel) getGCEPVLabeler() (cloudprovider.PVLabeler, error) {
	l.mutex.Lock()
	defer l.mutex.Unlock()

	if l.gcePVLabeler == nil {
		var cloudConfigReader io.Reader
		if len(l.cloudConfig) > 0 {
			cloudConfigReader = bytes.NewReader(l.cloudConfig)
		}

		cloudProvider, err := cloudprovider.GetCloudProvider("gce", cloudConfigReader)
		if err != nil || cloudProvider == nil {
			return nil, err
		}

		gcePVLabeler, ok := cloudProvider.(cloudprovider.PVLabeler)
		if !ok {
			return nil, errors.New("GCE cloud provider does not implement PV labeling")
		}

		l.gcePVLabeler = gcePVLabeler

	}
	return l.gcePVLabeler, nil
}
1308859
func Infof(format string, v ...interface{}) {
	std.Fprint(std.flags, LEVEL_INFO, 2, fmt.Sprintf(format, v...), nil)
}
123922
func (mag MaterialAttributesGit) GenerateGeneric() (ma map[string]interface{}) {
	ma = map[string]interface{}{
		"name":             mag.Name,
		"url":              mag.URL,
		"auto_update":      mag.AutoUpdate,
		"branch":           mag.Branch,
		"submodule_folder": mag.SubmoduleFolder,
		"destination":      mag.Destination,
		"shallow_clone":    mag.ShallowClone,
		"invert_filter":    mag.InvertFilter,
	}
	if f := mag.Filter.GenerateGeneric(); f != nil {
		ma["filter"] = f
	}
	return
}
1135741
func (g *Generator) SetSolarisCappedCPUNcpus(ncpus string) {
	g.initConfigSolarisCappedCPU()
	g.Config.Solaris.CappedCPU.Ncpus = ncpus
}
667396
func generateSecret(opts *Options) (*v1.Secret, error) {

	labels := generateLabels(map[string]string{"name": "tiller"})
	secret := &v1.Secret{
		Type: v1.SecretTypeOpaque,
		Data: make(map[string][]byte),
		ObjectMeta: metav1.ObjectMeta{
			Name:      secretName,
			Labels:    labels,
			Namespace: opts.Namespace,
		},
	}
	var err error
	if secret.Data["tls.key"], err = read(opts.TLSKeyFile); err != nil {
		return nil, err
	}
	if secret.Data["tls.crt"], err = read(opts.TLSCertFile); err != nil {
		return nil, err
	}
	if opts.VerifyTLS {
		if secret.Data["ca.crt"], err = read(opts.TLSCaCertFile); err != nil {
			return nil, err
		}
	}
	return secret, nil
}
473622
func (c *ClientsetCAStore) generateCACertificate(id string) (*keyset, error) {
	template := BuildCAX509Template()

	caRsaKey, err := rsa.GenerateKey(crypto_rand.Reader, 2048)
	if err != nil {
		return nil, fmt.Errorf("error generating RSA private key: %v", err)
	}

	caPrivateKey := &pki.PrivateKey{Key: caRsaKey}

	t := time.Now().UnixNano()
	template.SerialNumber = pki.BuildPKISerial(t)

	caCertificate, err := pki.SignNewCertificate(caPrivateKey, template, nil, nil)
	if err != nil {
		return nil, err
	}

	return c.storeAndVerifyKeypair(id, caCertificate, caPrivateKey)
}
664845
func (r *RDBDriver) GetByCpeURI(uri string) ([]models.CveDetail, error) {
	cveIDs, err := r.GetCveIDsByCpeURI(uri)
	if err != nil {
		return nil, err
	}

	cveDetails, err := r.GetMulti(cveIDs)
	if err != nil {
		return nil, err
	}

	// Convert from map to array
	details := make([]models.CveDetail, len(cveDetails))
	i := 0
	for _, d := range cveDetails {
		details[i] = d
		i++
		log.Debugf("%s", d.CveID)
	}
	return details, nil
}
1285429
func NewPDFGenerator() (*PDFGenerator, error) {
	pdfg := &PDFGenerator{
		globalOptions:  newGlobalOptions(),
		outlineOptions: newOutlineOptions(),
		Cover: cover{
			pageOptions: newPageOptions(),
		},
		TOC: toc{
			allTocOptions: allTocOptions{
				tocOptions:  newTocOptions(),
				pageOptions: newPageOptions(),
			},
		},
	}
	err := pdfg.findPath()
	return pdfg, err
}
404397
func NewECU(cfg *ECUConfig) *ECU {
	if cfg == nil {
		defaultCfg := DefaultECUConfig()
		cfg = &defaultCfg
	}
	return &ECU{
		cfg:             cfg,
		shutdown:        make(chan bool),
		shutdownControl: make(chan bool),
		shutdownMonitor: make(chan bool),
	}
}
422180
func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
	// println(">>>>>>>>> DecFallback")
	rv := reflect.ValueOf(iv)
	if chkPtr {
		rv = f.d.ensureDecodeable(rv)
	}
	f.d.decodeValue(rv, nil, false)
	// f.d.decodeValueFallback(rv)
}
558683
func (ch *CredHub) GenerateCertificate(name string, gen generate.Certificate, overwrite Mode) (credentials.Certificate, error) {
	var cred credentials.Certificate
	err := ch.generateCredential(name, "certificate", gen, overwrite, &cred)
	return cred, err
}
478655
func generateVerbatim(p *parser, out *bytes.Buffer, data []byte, offset int) int {
	return generator(p, out, data, offset, '=', false, p.r.CodeSpan)
}
1104326
func GenerateClientCertificate() (*Certificate, error) {
	cert, key, err := shared.GenerateMemCert(true)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return NewCertificate(cert, key), nil
}
801265
func GodelPropsDistPkgInfo(projectDir string) (godelgetter.PkgSrc, error) {
	wrapperSpec, err := specdir.New(projectDir, layout.WrapperSpec(), nil, specdir.Validate)
	if err != nil {
		return nil, errors.Wrapf(err, "unable to create wrapper spec")
	}
	configDir := wrapperSpec.Path(layout.WrapperConfigDir)

	propsFilePath := path.Join(configDir, fmt.Sprintf("%s.properties", layout.AppName))
	props, err := readPropertiesFile(propsFilePath)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to read properties file %s", propsFilePath)
	}
	url, ok := props[propertiesURLKey]
	if !ok {
		return nil, errors.Wrapf(err, "properties file %s does not contain key %s", propsFilePath, propertiesURLKey)
	}
	checksum := props[propertiesChecksumKey]
	return godelgetter.NewPkgSrc(url, checksum), nil
}
1209839
func randGenerator(newRand func() *rand.Rand) ExponentialOption {
	return func(options *exponentialOptions) {
		options.newRand = newRand
	}
}