// GetExternalID returns the ExternalID field if it's non-nil, zero value otherwise.
439752
func (c *CreateCheckRunOptions) GetExternalID() string {
	if c == nil || c.ExternalID == nil {
		return ""
	}
	return *c.ExternalID
}
1056792
func (s *Principal) SetExternal(v bool) *Principal {
	s.External = &v
	return s
}
202546
func FromGlobalID(globalID string) *ResolvedGlobalID {
	strID := ""
	b, err := base64.StdEncoding.DecodeString(globalID)
	if err == nil {
		strID = string(b)
	}
	tokens := strings.Split(strID, ":")
	if len(tokens) < 2 {
		return nil
	}
	return &ResolvedGlobalID{
		Type: tokens[0],
		ID:   tokens[1],
	}
}
778539
func (d *OvsdbDriver) GetPortOrIntfNameFromID(id string, isPort bool) (string, error) {
	table := portTable
	if !isPort {
		table = interfaceTable
	}

	d.cacheLock.RLock()
	defer d.cacheLock.RUnlock()

	// walk thru all ports
	for _, row := range d.cache[table] {
		if extIDs, ok := row.Fields["external_ids"]; ok {
			extIDMap := extIDs.(libovsdb.OvsMap).GoMap
			if portID, ok := extIDMap["endpoint-id"]; ok && portID == id {
				return row.Fields["name"].(string), nil
			}
		}
	}
	return "", core.Errorf("Ovs port/intf not found for id: %s", id)
}
1053157
func GetAlternateColor(index int) drawing.Color {
	finalIndex := index % len(DefaultAlternateColors)
	return DefaultAlternateColors[finalIndex]
}
463733
func (s *FailureDetails) SetExternalExecutionId(v string) *FailureDetails {
	s.ExternalExecutionId = &v
	return s
}
72337
func (s *AssumeRoleInput) SetExternalId(v string) *AssumeRoleInput {
	s.ExternalId = &v
	return s
}
578090
func (s *IGDService) GetExternalIPAddress() (net.IP, error) {
	tpl := `<u:GetExternalIPAddress xmlns:u="%s" />`

	body := fmt.Sprintf(tpl, s.URN)

	response, err := soapRequest(s.URL, s.URN, "GetExternalIPAddress", body)

	if err != nil {
		return nil, err
	}

	envelope := &soapGetExternalIPAddressResponseEnvelope{}
	err = xml.Unmarshal(response, envelope)
	if err != nil {
		return nil, err
	}

	result := net.ParseIP(envelope.Body.GetExternalIPAddressResponse.NewExternalIPAddress)

	return result, nil
}
888790
func ExternalTokenFilterByIdentityID(identityID uuid.UUID) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("identity_id = ?", identityID)
	}
}
41102
func (s *tokenServiceImpl) RetrieveExternalToken(ctx context.Context, forResource string, req *goa.RequestData, forcePull *bool) (*app.ExternalToken, *string, error) {
	if forResource == "" {
		return nil, nil, errors.NewBadParameterError("for", "").Expected("git or OpenShift resource URL")
	}

	var currentIdentityID uuid.UUID
	serviceAccount := authtoken.IsSpecificServiceAccount(ctx, authtoken.OsoProxy, authtoken.Tenant, authtoken.JenkinsIdler, authtoken.JenkinsProxy)
	if serviceAccount {
		// Extract SA ID
		id, err := manager.ContextIdentity(ctx)
		if err != nil {
			return nil, nil, err
		}
		currentIdentityID = *id
	} else {
		// Extract user ID
		currentIdentity, err := s.Services().UserService().LoadContextIdentityIfNotBanned(ctx)
		if err != nil {
			return nil, nil, err
		}
		currentIdentityID = currentIdentity.ID
	}

	var appResponse app.ExternalToken

	linkingProvider, err := s.Factories().LinkingProviderFactory().NewLinkingProvider(ctx, currentIdentityID,
		rest.AbsoluteURL(req, "", nil), forResource)
	if err != nil {
		return nil, nil, err
	}

	osProvider, ok := linkingProvider.(provider.OpenShiftIdentityProvider)
	if ok && serviceAccount {
		// This is a request from OSO proxy, tenant, Jenkins Idler, or Jenkins proxy service to obtain a cluster wide token
		return s.retrieveClusterToken(ctx, forResource, forcePull, osProvider)
	}

	var externalToken *tokenrepo.ExternalToken
	err = s.ExecuteInTransaction(func() error {
		err := s.Repositories().Identities().CheckExists(ctx, currentIdentityID.String())
		if err != nil {
			return errors.NewUnauthorizedError(err.Error())
		}
		tokens, err := s.Repositories().ExternalTokens().LoadByProviderIDAndIdentityID(ctx, linkingProvider.ID(), currentIdentityID)
		if err != nil {
			return err
		}
		if len(tokens) > 0 {
			externalToken = &tokens[0]
		}
		return nil

	})
	if err != nil {
		return nil, nil, err
	}

	if externalToken != nil {
		if forcePull != nil && *forcePull {
			userProfile, err := linkingProvider.Profile(ctx, oauth2.Token{AccessToken: externalToken.Token})
			if err != nil {
				log.Error(ctx, map[string]interface{}{
					"err":           err,
					"for":           forResource,
					"provider_name": linkingProvider.TypeName(),
				}, "Unable to fetch user profile for external token. Account relinking may be required.")
				linkURL := rest.AbsoluteURL(req, fmt.Sprintf("%s?for=%s", client.LinkTokenPath(), forResource), nil)
				errorResponse := fmt.Sprintf("LINK url=%s, description=\"%s token is not valid or expired. Relink %s account\"",
					linkURL, linkingProvider.TypeName(), linkingProvider.TypeName())
				return nil, &errorResponse, errors.NewUnauthorizedError(err.Error())
			}

			externalToken.Username = userProfile.Username
			err = s.ExecuteInTransaction(func() error {
				return s.Repositories().ExternalTokens().Save(ctx, externalToken)
			})
			if err != nil {
				return nil, nil, err
			}
		}

		appResponse = app.ExternalToken{
			Scope:          externalToken.Scope,
			AccessToken:    externalToken.Token,
			TokenType:      "Bearer", // We aren't saving the token_type in the database
			Username:       externalToken.Username,
			ProviderAPIURL: linkingProvider.URL(),
		}

		return &appResponse, nil, nil
	}
	providerName := linkingProvider.TypeName()
	linkURL := rest.AbsoluteURL(req, fmt.Sprintf("%s?for=%s", client.LinkTokenPath(), forResource), nil)
	errorResponse := fmt.Sprintf("LINK url=%s, description=\"%s token is missing. Link %s account\"", linkURL, providerName, providerName)
	return nil, &errorResponse, errors.NewUnauthorizedError("token is missing")
}
685758
func (c *Client) GetExportRootClientsByID(
	ctx context.Context, id int) ([]string, error) {

	ex, err := c.GetExportByID(ctx, id)
	if err != nil {
		return nil, err
	}
	if ex == nil {
		return nil, nil
	}
	if ex.RootClients == nil {
		return nil, nil
	}
	return *ex.RootClients, nil
}
316588
func (f *Facade) GetTenantID(ctx datastore.Context, serviceID string) (string, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetTenantID"))
	logger := plog.WithFields(log.Fields{
		"serviceID": serviceID,
	})
	logger.Debug("Started Facade.GetTenantID")
	defer logger.Debug("Finished Facade.GetTenantID")

	gs := func(id string) (*service.ServiceDetails, error) {
		return f.GetServiceDetails(ctx, id)
	}
	return f.serviceCache.GetTenantID(serviceID, gs)
}
1082958
func (c *Cloud) ExternalID(nodeName types.NodeName) (string, error) {
	if c.selfAWSInstance.nodeName == nodeName {
		// We assume that if this is run on the instance itself, the instance exists and is alive
		return c.selfAWSInstance.awsID, nil
	}
	// We must verify that the instance still exists
	// Note that if the instance does not exist or is no longer running, we must return ("", cloudprovider.InstanceNotFound)
	instance, err := c.findInstanceByNodeName(nodeName)
	if err != nil {
		return "", err
	}
	if instance == nil {
		return "", cloudprovider.ErrInstanceNotFound
	}
	return orEmpty(instance.InstanceId), nil
}
746848
func (bf *BlockFilterer) foundExternal(scopedIndex waddrmgr.ScopedIndex) {
	if _, ok := bf.FoundExternal[scopedIndex.Scope]; !ok {
		bf.FoundExternal[scopedIndex.Scope] = make(map[uint32]struct{})
	}
	bf.FoundExternal[scopedIndex.Scope][scopedIndex.Index] = struct{}{}
}
887265
func NewExternalUserLogInfo(UserIdentifier string, IdentifierType *IdentifierType) *ExternalUserLogInfo {
	s := new(ExternalUserLogInfo)
	s.UserIdentifier = UserIdentifier
	s.IdentifierType = IdentifierType
	return s
}
420989
func (s *ActionExecution) SetExternalExecutionUrl(v string) *ActionExecution {
	s.ExternalExecutionUrl = &v
	return s
}
908664
func (c *Client) GetExportByID(ctx context.Context, id int) (Export, error) {
	return api.ExportInspect(ctx, c.API, id)
}