// loadDefaultIdpIdentities loads identities for the default IDP users and returns the valid users along with their KC identities
// (if a user is missing his/her KC identity, he/she is filtered out of the result array)
18402
func loadDefaultIdpIdentities(repos repository.Repositories, users []accountrepo.User) ([]accountrepo.User, []accountrepo.Identity, error) {
	var resultUsers []accountrepo.User
	var resultIdentities []accountrepo.Identity
	for _, user := range users {
		identity, err := loadDefaultIdpIdentity(repos, user)
		// if we can't find the default IDP identity
		if err != nil {
			log.Error(nil, map[string]interface{}{"user": user, "err": err}, "unable to load user default IDP identity")
		} else {
			resultUsers = append(resultUsers, user)
			resultIdentities = append(resultIdentities, *identity)
		}
	}
	return resultUsers, resultIdentities, nil
}
100278
func RegisterDefaults(scheme *runtime.Scheme) error {
	scheme.AddTypeDefaultingFunc(&v1beta1.MutatingWebhookConfiguration{}, func(obj interface{}) {
		SetObjectDefaults_MutatingWebhookConfiguration(obj.(*v1beta1.MutatingWebhookConfiguration))
	})
	scheme.AddTypeDefaultingFunc(&v1beta1.MutatingWebhookConfigurationList{}, func(obj interface{}) {
		SetObjectDefaults_MutatingWebhookConfigurationList(obj.(*v1beta1.MutatingWebhookConfigurationList))
	})
	scheme.AddTypeDefaultingFunc(&v1beta1.ValidatingWebhookConfiguration{}, func(obj interface{}) {
		SetObjectDefaults_ValidatingWebhookConfiguration(obj.(*v1beta1.ValidatingWebhookConfiguration))
	})
	scheme.AddTypeDefaultingFunc(&v1beta1.ValidatingWebhookConfigurationList{}, func(obj interface{}) {
		SetObjectDefaults_ValidatingWebhookConfigurationList(obj.(*v1beta1.ValidatingWebhookConfigurationList))
	})
	return nil
}
1059332
func (s *userServiceImpl) LoadContextIdentityIfNotBanned(ctx context.Context) (*repository.Identity, error) {
	identity, err := s.LoadContextIdentityAndUser(ctx)
	if err != nil {
		return nil, err
	}
	if identity.User.Banned {
		return nil, errors.NewUnauthorizedError("user banned")
	}
	return identity, err
}
460405
func GetIdentityCache() IdentityCache {
	cache := IdentityCache{}

	if IdentityAllocator != nil {

		IdentityAllocator.ForeachCache(func(id idpool.ID, val allocator.AllocatorKey) {
			if val != nil {
				if gi, ok := val.(globalIdentity); ok {
					cache[identity.NumericIdentity(id)] = gi.LabelArray
				} else {
					log.Warningf("Ignoring unknown identity type '%s': %+v",
						reflect.TypeOf(val), val)
				}
			}
		})
	}

	for key, identity := range identity.ReservedIdentityCache {
		cache[key] = identity.Labels.LabelArray()
	}

	if localIdentities != nil {
		for _, identity := range localIdentities.GetIdentities() {
			cache[identity.ID] = identity.Labels.LabelArray()
		}
	}

	return cache
}
310851
func RegisterDefaults(scheme *runtime.Scheme) error {
	scheme.AddTypeDefaultingFunc(&v1beta1.Deployment{}, func(obj interface{}) { SetObjectDefaults_Deployment(obj.(*v1beta1.Deployment)) })
	scheme.AddTypeDefaultingFunc(&v1beta1.DeploymentList{}, func(obj interface{}) { SetObjectDefaults_DeploymentList(obj.(*v1beta1.DeploymentList)) })
	scheme.AddTypeDefaultingFunc(&v1beta1.StatefulSet{}, func(obj interface{}) { SetObjectDefaults_StatefulSet(obj.(*v1beta1.StatefulSet)) })
	scheme.AddTypeDefaultingFunc(&v1beta1.StatefulSetList{}, func(obj interface{}) { SetObjectDefaults_StatefulSetList(obj.(*v1beta1.StatefulSetList)) })
	return nil
}
955331
func RegisterDefaults(scheme *runtime.Scheme) error {
	scheme.AddTypeDefaultingFunc(&v1beta1.KubeletConfiguration{}, func(obj interface{}) { SetObjectDefaults_KubeletConfiguration(obj.(*v1beta1.KubeletConfiguration)) })
	return nil
}
894715
func GetDefaultUserName(client *api.Client, serverID int64) (string, error) {

	// read server
	server, err := client.GetServerAPI().Read(serverID)
	if err != nil {
		return "", err
	}

	if len(server.Disks) == 0 {
		return "", nil
	}

	return getSSHDefaultUserNameDiskRec(client, server.Disks[0].ID)
}
1114230
func importIdentities(c context.Context, cfg *config.ProjectsCfg) error {
	storage := projectidentity.ProjectIdentities(c)

	// TODO (fmatenaar): Make this transactional and provide some guarantees around cleanup
	// but do this after we have a stronger story for warning about config changes which are
	// about to remove an identity config from a project since this can cause an outage.
	for _, project := range cfg.Projects {
		if project.IdentityConfig != nil && project.IdentityConfig.ServiceAccountEmail != "" {
			identity := &projectidentity.ProjectIdentity{
				Project: project.Id,
				Email:   project.IdentityConfig.ServiceAccountEmail,
			}
			logging.Infof(c, "updating project scoped account: %v", identity)
			if _, err := storage.Update(c, identity); err != nil {
				logging.Errorf(c, "failed to update project scoped account: %v", identity)
				return err
			}
		}
	}
	return nil
}
1040294
func RegisterDefaults(scheme *runtime.Scheme) error {
	scheme.AddTypeDefaultingFunc(&v1.NetworkPolicy{}, func(obj interface{}) { SetObjectDefaults_NetworkPolicy(obj.(*v1.NetworkPolicy)) })
	scheme.AddTypeDefaultingFunc(&v1.NetworkPolicyList{}, func(obj interface{}) { SetObjectDefaults_NetworkPolicyList(obj.(*v1.NetworkPolicyList)) })
	return nil
}
122693
func (c *configV8) loadDefaults() {
	// MinIO server running locally.
	c.setHost("local", hostConfigV8{
		URL:       "http://localhost:9000",
		AccessKey: "",
		SecretKey: "",
		API:       "S3v4",
	})

	// Amazon S3 cloud storage service.
	c.setHost("s3", hostConfigV8{
		URL:       "https://s3.amazonaws.com",
		AccessKey: defaultAccessKey,
		SecretKey: defaultSecretKey,
		API:       "S3v4",
	})

	// Google cloud storage service.
	c.setHost("gcs", hostConfigV8{
		URL:       "https://storage.googleapis.com",
		AccessKey: defaultAccessKey,
		SecretKey: defaultSecretKey,
		API:       "S3v2",
	})

	// MinIO anonymous server for demo.
	c.setHost("play", hostConfigV8{
		URL:       "https://play.min.io:9000",
		AccessKey: "Q3AM3UQ867SPQQA43P2F",
		SecretKey: "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
		API:       "S3v4",
	})
}
1211928
func identityRoleFilterByIdentityID(identityID uuid.UUID) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("identity_id = ?", identityID)
	}
}
109145
func WaitForInitialIdentities(ctx context.Context) error {
	select {
	case <-identityAllocatorInitialized:
	case <-ctx.Done():
		return fmt.Errorf("initial identity sync was cancelled: %s", ctx.Err())
	}

	return IdentityAllocator.WaitForInitialSync(ctx)
}
1000918
func (m *GormIdentityRepository) LoadWithUser(ctx context.Context, id uuid.UUID) (*Identity, error) {
	identities, err := m.Query(IdentityFilterByID(id), IdentityWithUser())
	if err != nil {
		return nil, err
	}
	if len(identities) == 0 {
		return nil, errs.WithStack(errors.NewNotFoundError("identity", id.String()))
	}
	if identities[0].User.ID == uuid.Nil {
		return nil, errs.WithStack(errors.NewNotFoundError("user for identity", id.String()))
	}
	return &identities[0], nil
}
913767
func (c *Config) LoadDefaultScopes(dataDir string) {
	for k, v := range datastore.DefaultScopes(dataDir) {
		if _, ok := c.Scopes[k]; !ok {
			c.Scopes[k] = v
		}
	}
}
674869
func RegisterDefaults(scheme *runtime.Scheme) error {
	scheme.AddTypeDefaultingFunc(&CustomResourceDefinition{}, func(obj interface{}) { SetObjectDefaults_CustomResourceDefinition(obj.(*CustomResourceDefinition)) })
	scheme.AddTypeDefaultingFunc(&CustomResourceDefinitionList{}, func(obj interface{}) {
		SetObjectDefaults_CustomResourceDefinitionList(obj.(*CustomResourceDefinitionList))
	})
	return nil
}
281104
func NewDefaultUserIdentityInfo(providerName, providerUserName string) *DefaultUserIdentityInfo {
	return &DefaultUserIdentityInfo{
		ProviderName:     providerName,
		ProviderUserName: providerUserName,
		Extra:            map[string]string{},
	}
}
1365972
func RegisterDefaults(scheme *runtime.Scheme) error {
	scheme.AddTypeDefaultingFunc(&v1.OAuthAuthorizeToken{}, func(obj interface{}) { SetObjectDefaults_OAuthAuthorizeToken(obj.(*v1.OAuthAuthorizeToken)) })
	scheme.AddTypeDefaultingFunc(&v1.OAuthAuthorizeTokenList{}, func(obj interface{}) { SetObjectDefaults_OAuthAuthorizeTokenList(obj.(*v1.OAuthAuthorizeTokenList)) })
	return nil
}