// parseTarget splits target into a struct containing scheme, authority and
// endpoint.
//
// If target is not a valid scheme://authority/endpoint, it returns {Endpoint:
// target}.
322294
func parseTarget(target string) (ret resolver.Target) {
	var ok bool
	ret.Scheme, ret.Endpoint, ok = split2(target, "://")
	if !ok {
		return resolver.Target{Endpoint: target}
	}
	ret.Authority, ret.Endpoint, ok = split2(ret.Endpoint, "/")
	if !ok {
		return resolver.Target{Endpoint: target}
	}
	return ret
}
915196
func (c *Client) SimpleGet(target string) (*http.Response, error) {
	// We parse the URL and then convert it right back to a string
	// later; this just acts as a check that Fastly isn't sending
	// us nonsense.
	url, err := url.Parse(target)
	if err != nil {
		return nil, err
	}

	request, err := http.NewRequest("GET", url.String(), nil)
	if err != nil {
		return nil, err
	}

	if len(c.apiKey) > 0 {
		request.Header.Set(APIKeyHeader, c.apiKey)
	}
	request.Header.Set("User-Agent", UserAgent)

	resp, err := checkResp(c.HTTPClient.Do(request))
	if err != nil {
		return resp, err
	}
	return resp, nil
}
463124
func isValidTargetsStructure(t Targets, roleName RoleName) error {
	if roleName != CanonicalTargetsRole && !IsDelegation(roleName) {
		return ErrInvalidRole{Role: roleName}
	}

	// even if it's a delegated role, the metadata type is "Targets"
	expectedType := TUFTypes[CanonicalTargetsRole]
	if t.Type != expectedType {
		return ErrInvalidMetadata{
			role: roleName, msg: fmt.Sprintf("expected type %s, not %s", expectedType, t.Type)}
	}

	if t.Version < 1 {
		return ErrInvalidMetadata{role: roleName, msg: "version cannot be less than one"}
	}

	for _, roleObj := range t.Delegations.Roles {
		if !IsDelegation(roleObj.Name) || path.Dir(roleObj.Name.String()) != roleName.String() {
			return ErrInvalidMetadata{
				role: roleName, msg: fmt.Sprintf("delegation role %s invalid", roleObj.Name)}
		}
		if err := isValidRootRoleStructure(roleName, roleObj.Name, roleObj.RootRole, t.Delegations.Keys); err != nil {
			return err
		}
	}
	return nil
}
426695
func (s *GetConnectionStatusInput) SetTarget(v string) *GetConnectionStatusInput {
	s.Target = &v
	return s
}
1088519
func parseTargetID(s string) (*TargetID, error) {
	tokens := strings.Split(s, ":")
	if len(tokens) != 2 {
		return nil, fmt.Errorf("invalid TargetID format '%v'", s)
	}

	return &TargetID{
		ID:   tokens[0],
		Name: tokens[1],
	}, nil
}
122742
func (c *Client) calculateTargets(opts requestOptions) ([]fab.Peer, error) {

	if opts.Targets != nil && opts.TargetFilter != nil {
		return nil, errors.New("If targets are provided, filter cannot be provided")
	}

	targets := opts.Targets
	targetFilter := opts.TargetFilter

	var err error
	if targets == nil {
		// Retrieve targets from discovery
		targets, err = c.discovery.GetPeers()
		if err != nil {
			return nil, err
		}

		if targetFilter == nil {
			targetFilter = c.filter
		}
	}

	if targetFilter != nil {
		targets = filterTargets(targets, targetFilter)
	}

	if len(targets) == 0 {
		return nil, errors.WithStack(status.New(status.ClientStatus, status.NoPeersFound.ToInt32(), "no targets available", nil))
	}

	if len(targets) < opts.MinTargets {
		return nil, errors.Errorf("Error getting minimum number of targets. %d available, %d required", len(targets), opts.MinTargets)
	}

	// Calculate number of targets required
	numOfTargets := opts.MaxTargets
	if len(targets) < opts.MaxTargets {
		numOfTargets = len(targets)
	}

	// Shuffle to randomize
	shuffle(targets)

	return targets[:numOfTargets], nil
}
167634
func (s *GetConnectionStatusOutput) SetTarget(v string) *GetConnectionStatusOutput {
	s.Target = &v
	return s
}
1190283
func hasJumpTarget(c *compilerContext, conditionalIndex, potentialTarget int) bool {
	return c.jts.hasJumpTarget(c, conditionalIndex, potentialTarget) ||
		c.jfs.hasJumpTarget(c, conditionalIndex, potentialTarget)
}
739173
func (c *Target) AttachToTarget(targetId string, flatten bool) (string, error) {
	var v TargetAttachToTargetParams
	v.TargetId = targetId
	v.Flatten = flatten
	return c.AttachToTargetWithParams(&v)
}
950675
func (cr *Context) GetTarget() *Surface {
	ret := wrapSurface(C.cairo_get_target(cr.Ptr))
	if err := cr.status(); err != nil {
		panic(err)
	}
	return ret
}
1286849
func (s *Service) ListTargets(ctx context.Context) (list []platform.ScraperTarget, err error) {
	list = make([]platform.ScraperTarget, 0)
	s.scraperTargetKV.Range(func(_, v interface{}) bool {
		b, ok := v.(platform.ScraperTarget)
		if !ok {
			err = &platform.Error{
				Code: platform.EInvalid,
				Msg:  fmt.Sprintf("type %T is not a scraper target", v),
			}
			return false
		}
		list = append(list, b)
		return true
	})
	return list, err
}
271319
func (s *CustomRule) SetTarget(v string) *CustomRule {
	s.Target = &v
	return s
}
364851
func (s *DetachPolicyInput) SetTarget(v string) *DetachPolicyInput {
	s.Target = &v
	return s
}
1263097
func (s *PresetWatermark) SetTarget(v string) *PresetWatermark {
	s.Target = &v
	return s
}
564536
func (s *SigningPlatform) SetTarget(v string) *SigningPlatform {
	s.Target = &v
	return s
}
917645
func (actor Actor) SetTarget(settings TargetSettings) (Warnings, error) {
	if actor.Config.Target() == settings.URL && actor.Config.SkipSSLValidation() == settings.SkipSSLValidation {
		return nil, nil
	}

	warnings, err := actor.CloudControllerClient.TargetCF(ccv2.TargetSettings(settings))
	if err != nil {
		return Warnings(warnings), err
	}

	actor.Config.SetTargetInformation(
		actor.CloudControllerClient.API(),
		actor.CloudControllerClient.APIVersion(),
		actor.CloudControllerClient.AuthorizationEndpoint(),
		actor.CloudControllerClient.MinCLIVersion(),
		actor.CloudControllerClient.DopplerEndpoint(),
		actor.CloudControllerClient.RoutingEndpoint(),
		settings.SkipSSLValidation,
	)
	actor.Config.SetTokenInformation("", "", "")

	return Warnings(warnings), nil
}
579097
func (launcher *Launcher) GetTarget() string {
	launcher.Mutex.RLock()
	arg := launcher.target
	launcher.Mutex.RUnlock()
	return arg
}