// Detect clones source locally if not already local and runs code detection
// with the given detector.
978220
func (r *SourceRepository) Detect(d Detector, dockerStrategy bool) error {
	if r.info != nil {
		return nil
	}
	path, err := r.LocalPath()
	if err != nil {
		return err
	}
	r.info, err = d.Detect(path, dockerStrategy)
	if err != nil {
		return err
	}
	if err = r.DetectAuth(); err != nil {
		return err
	}
	return nil
}
462658
func detectType(v interface{}) Type {
	if v == nil {
		return Tnil
	}
	switch v.(type) {
	case bool:
		return Tbool
	case int, int32, int64:
		return Tint64
	case float32, float64:
		return Tfloat64
	case string:
		return Tstring
	case []interface{}:
		return Tarray
	case map[string]interface{}:
		return Tmap
	default:
		return Tunknown
	}
}
627828
func NewDetectCredentialsCommand() cmd.Command {
	c := &detectCredentialsCommand{
		store:                   jujuclient.NewFileCredentialStore(),
		registeredProvidersFunc: environs.RegisteredProviders,
		cloudByNameFunc:         jujucloud.CloudByName,
	}
	c.allCloudsFunc = func() (map[string]jujucloud.Cloud, error) {
		return c.allClouds()
	}
	return c
}
1011342
func (s *Standalone) Detect(o MasterChanged) error {
	log.V(2).Info("Detect()")
	s.pollOnce.Do(func() {
		log.V(1).Info("spinning up asyc master detector poller")
		// delayed initialization allows unit tests to modify timeouts before detection starts
		s.client = &http.Client{
			Transport: s.tr,
			Timeout:   s.httpClientTimeout,
		}
		go s.poller(s.fetchPid)
	})
	if o != nil {
		log.V(1).Info("spawning asyc master detector listener")
		go func() {
			log.V(2).Infof("waiting for polled to send updates")
		pollWaiter:
			for {
				select {
				case mi, ok := <-s.ch:
					if !ok {
						break pollWaiter
					}
					log.V(1).Infof("detected master change: %+v", mi)
					o.OnMasterChanged(mi)
				case <-s.done:
					return
				}
			}
			o.OnMasterChanged(nil)
		}()
	} else {
		log.Warningf("detect called with a nil master change listener")
	}
	return nil
}
268579
func detectConfigChange(conf jsonconfig.Obj) error {
	oldHTTPSKey, oldHTTPSCert := conf.OptionalString("HTTPSKeyFile", ""), conf.OptionalString("HTTPSCertFile", "")
	if oldHTTPSKey != "" || oldHTTPSCert != "" {
		return fmt.Errorf("config keys %q and %q have respectively been renamed to %q and %q, please fix your server config",
			"HTTPSKeyFile", "HTTPSCertFile", "httpsKey", "httpsCert")
	}
	return nil
}
1037334
func DetectStorage() (ok bool) {
	defer func() {
		if r := recover(); r != nil {
			localStorage = nil
			ok = false
		}
	}()

	localStorage = js.Global.Get("localStorage")

	if localStorage == js.Undefined {
		localStorage = nil
	}
	if localStorage == nil {
		return false
	}

	// Cf. https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
	// https://gist.github.com/paulirish/5558557
	x := "__storage_test__"
	localStorage.Set(x, x)
	obj := localStorage.Get(x)
	if obj == js.Undefined || obj == nil {
		localStorage = nil
		return false
	}
	localStorage.Call("removeItem", x)
	return true
}
190653
func CloneSelectorAndAddLabel(selector *metav1.LabelSelector, labelKey, labelValue string) *metav1.LabelSelector {
	if labelKey == "" {
		// Don't need to add a label.
		return selector
	}

	// Clone.
	newSelector := new(metav1.LabelSelector)

	// TODO(madhusudancs): Check if you can use deepCopy_extensions_LabelSelector here.
	newSelector.MatchLabels = make(map[string]string)
	if selector.MatchLabels != nil {
		for key, val := range selector.MatchLabels {
			newSelector.MatchLabels[key] = val
		}
	}
	newSelector.MatchLabels[labelKey] = labelValue

	if selector.MatchExpressions != nil {
		newMExps := make([]metav1.LabelSelectorRequirement, len(selector.MatchExpressions))
		for i, me := range selector.MatchExpressions {
			newMExps[i].Key = me.Key
			newMExps[i].Operator = me.Operator
			if me.Values != nil {
				newMExps[i].Values = make([]string, len(me.Values))
				copy(newMExps[i].Values, me.Values)
			} else {
				newMExps[i].Values = nil
			}
		}
		newSelector.MatchExpressions = newMExps
	} else {
		newSelector.MatchExpressions = nil
	}

	return newSelector
}
794690
func Detect(config backend.BuildConfig) (remote builder.Source, dockerfile *parser.Result, err error) {
	remoteURL := config.Options.RemoteContext
	dockerfilePath := config.Options.Dockerfile

	switch {
	case remoteURL == "":
		remote, dockerfile, err = newArchiveRemote(config.Source, dockerfilePath)
	case remoteURL == ClientSessionRemote:
		res, err := parser.Parse(config.Source)
		if err != nil {
			return nil, nil, errdefs.InvalidParameter(err)
		}

		return nil, res, nil
	case urlutil.IsGitURL(remoteURL):
		remote, dockerfile, err = newGitRemote(remoteURL, dockerfilePath)
	case urlutil.IsURL(remoteURL):
		remote, dockerfile, err = newURLRemote(remoteURL, dockerfilePath, config.ProgressWriter.ProgressReaderFunc)
	default:
		err = fmt.Errorf("remoteURL (%s) could not be recognized as URL", remoteURL)
	}
	return
}
1061484
func (t *FunctionType) Clone() interface{} {
	retVal := new(FunctionType)

	if ac, ok := t.a.(Cloner); ok {
		retVal.a = ac.Clone().(Type)
	} else {
		retVal.a = t.a
	}

	if bc, ok := t.b.(Cloner); ok {
		retVal.b = bc.Clone().(Type)
	} else {
		retVal.b = t.b
	}
	return retVal
}
135693
func Detect(data []string) (sp Splitter, err error) {
	if len(data) == 0 {
		err = ErrNoData
		return
	}

	// joinSeparator can take the following values:
	// 0 -> assuming camelCase because not enough data
	// 1 -> camelCase, found at least one camelCase transition
	// any other punctuation rune -> that's the separator
	var joinSeparator rune = 0

	for _, s := range data {
		var innerErr error
		joinSeparator, innerErr = UpdateJoinStylePrediction(s, joinSeparator)
		if innerErr == ErrInconsistentData {
			err = ErrInconsistentData
			return
		}
	}

	d := Detected{}

	// We have now enough information to make a determination about the
	// separator.
	if joinSeparator <= 1 {
		d.Split = camelJoinStyle.Split
		if joinSeparator == 0 {
			err = ErrNotEnoughData
		}
	} else {
		d.Split = SimpleJoinStyle(string(joinSeparator)).Split
	}
	return d, err
}
1307683
func matchLocalFileAndUnit(file string, su *schema.Unit) (bool, error) {
	a := schema.MapSchemaUnitOptionsToUnitFile(su.Options)

	_, err := os.Stat(file)
	if err != nil {
		return false, err
	}

	b, err := getUnitFromFile(file)
	if err != nil {
		return false, err
	}

	return unit.MatchUnitFiles(a, b), nil
}
894974
func (p *parser) cloneState() storeDict {
	// ==template== {{ if not .Optimize }}
	if p.debug {
		defer p.out(p.in("cloneState"))
	}
	// {{ end }} ==template==

	state := make(storeDict, len(p.cur.state))
	for k, v := range p.cur.state {
		if c, ok := v.(Cloner); ok {
			state[k] = c.Clone()
		} else {
			state[k] = v
		}
	}
	return state
}
991423
func (e *Event) Clone() *Event {
	return &Event{
		Meta: &domevents.EventMetable{EventType: e.Meta.EventType, EventTarget: e.Meta.EventTarget},
		Fx:   e.Fx,
	}
}
1145551
func (cl *CommandLine) Clone() *CommandLine {
	return &CommandLine{
		Target: cl.Target,
		Flags:  append([]CommandLineFlag(nil), cl.Flags...),
		Args:   append([]string(nil), cl.Args...),
	}
}
754397
func isLocalReference(source string) bool {
	_, err := os.Stat(source)
	return err == nil
}
793761
func (p *UserAgent) detectOS(s section) {
	if s.name == "Mozilla" {
		// Get the platform here. Be aware that IE11 provides a new format
		// that is not backwards-compatible with previous versions of IE.
		p.platform = getPlatform(s.comment)
		if p.platform == "Windows" && len(s.comment) > 0 {
			p.os = normalizeOS(s.comment[0])
		}

		// And finally get the OS depending on the engine.
		switch p.browser.Engine {
		case "":
			p.undecided = true
		case "Gecko":
			gecko(p, s.comment)
		case "AppleWebKit":
			webkit(p, s.comment)
		case "Trident":
			trident(p, s.comment)
		}
	} else if s.name == "Opera" {
		if len(s.comment) > 0 {
			opera(p, s.comment)
		}
	} else if s.name == "Dalvik" {
		if len(s.comment) > 0 {
			dalvik(p, s.comment)
		}
	} else {
		// Check whether this is a bot or just a weird browser.
		p.undecided = true
	}
}
614688
func (b *UpdateService) DetectNoop(detectNoop bool) *UpdateService {
	b.detectNoop = &detectNoop
	return b
}