// fullProfileName takes a profile directory and the host the user is trying
// to connect to and returns the name of the profile file.
173248
func fullProfileName(profileDir string, proxyHost string) (string, error) {
	var err error
	var profileName string

	// If no profile name was passed in, try and extract the active profile from
	// the ~/.tsh/profile symlink. If one was passed in, append .yaml to name.
	if proxyHost == "" {
		profileName, err = os.Readlink(filepath.Join(profileDir, "profile"))
		if err != nil {
			return "", trace.ConvertSystemError(err)
		}
	} else {
		profileName = proxyHost + ".yaml"
	}

	// Make sure the profile requested actually exists.
	_, err = os.Stat(filepath.Join(profileDir, profileName))
	if err != nil {
		return "", trace.ConvertSystemError(err)
	}

	return profileName, nil
}
437513
func (provider *OpenShiftIdentityProviderImpl) Profile(ctx context.Context, token oauth2.Token) (*UserProfile, error) {
	body, err := provider.UserProfilePayload(ctx, token)
	if err != nil {
		return nil, err
	}
	var u openshiftUser
	err = json.Unmarshal(body, &u)
	if err != nil {
		return nil, err
	}
	userProfile := &UserProfile{
		Username: u.Metadata.Name,
	}
	return userProfile, nil
}
708110
func validateProfile(profile string, loadedProfiles map[string]bool) error {
	if err := ValidateProfileFormat(profile); err != nil {
		return err
	}

	if strings.HasPrefix(profile, ProfileNamePrefix) {
		profileName := strings.TrimPrefix(profile, ProfileNamePrefix)
		if !loadedProfiles[profileName] {
			return fmt.Errorf("profile %q is not loaded", profileName)
		}
	}

	return nil
}
596853
func (m *containerManager) LXDProfileNames(containerName string) ([]string, error) {
	return m.server.GetContainerProfiles(containerName)
}
904339
func (s profileService) DefineProfile(request *Profile) (*ProfileResponse, error) {
	var response ProfileResponse
	req, err := s.client.NewRequest("POST", defineProfilePath, request)
	if err != nil {
		return nil, err
	}
	err = s.client.Do(req, &response)
	if err != nil {
		return nil, err
	}
	return &response, nil
}
152624
func IdentityFilterByProfileURL(profileURL string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("profile_url = ?", profileURL).Limit(1)
	}
}
388480
func parseJavaProfile(b []byte) (*Profile, error) {
	h := bytes.SplitAfterN(b, []byte("\n"), 2)
	if len(h) < 2 {
		return nil, errUnrecognized
	}

	p := &Profile{
		PeriodType: &ValueType{},
	}
	header := string(bytes.TrimSpace(h[0]))

	var err error
	var pType string
	switch header {
	case "--- heapz 1 ---":
		pType = "heap"
	case "--- contentionz 1 ---":
		pType = "contention"
	default:
		return nil, errUnrecognized
	}

	if b, err = parseJavaHeader(pType, h[1], p); err != nil {
		return nil, err
	}
	var locs map[uint64]*Location
	if b, locs, err = parseJavaSamples(pType, b, p); err != nil {
		return nil, err
	}
	if err = parseJavaLocations(b, locs, p); err != nil {
		return nil, err
	}

	// Strip out addresses for better merge.
	if err = p.Aggregate(true, true, true, true, false); err != nil {
		return nil, err
	}

	return p, nil
}
304859
func (s *Server) GetContainerProfiles(name string) ([]string, error) {
	container, _, err := s.GetContainer(name)
	if err != nil {
		return []string{}, errors.Trace(err)
	}
	return container.Profiles, nil
}
995270
func (s *ListActiveViolationsInput) SetSecurityProfileName(v string) *ListActiveViolationsInput {
	s.SecurityProfileName = &v
	return s
}
457244
func (s *ModelPackageValidationProfile) SetProfileName(v string) *ModelPackageValidationProfile {
	s.ProfileName = &v
	return s
}
637706
func goldenFileName(name string) string {
	return filepath.Join(FixtureDir, fmt.Sprintf("%s%s", name, FileNameSuffix))
}
1332443
func (env *environ) LXDProfileNames(containerName string) ([]string, error) {
	return env.server().GetContainerProfiles(containerName)
}
1071014
func (s *UpdateProfileInput) SetProfileName(v string) *UpdateProfileInput {
	s.ProfileName = &v
	return s
}
931947
func (s *CreateSecurityProfileInput) SetSecurityProfileName(v string) *CreateSecurityProfileInput {
	s.SecurityProfileName = &v
	return s
}
1276190
func (p *SharedCredentialsProvider) profile() string {
	if p.Profile == "" {
		p.Profile = os.Getenv("AWS_PROFILE")
	}
	if p.Profile == "" {
		p.Profile = "default"
	}

	return p.Profile
}
879589
func restDeleteProfileByName(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	n, err := url.QueryUnescape(vars[NAME])
	if err != nil {
		LoggingClient.Error(err.Error())
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	// Check if the device profile exists
	dp, err := dbClient.GetDeviceProfileByName(n)
	if err != nil {
		if err == db.ErrNotFound {
			http.Error(w, err.Error(), http.StatusNotFound)
		} else {
			http.Error(w, err.Error(), http.StatusInternalServerError)
		}
		LoggingClient.Error(err.Error())
		return
	}

	// Delete the device profile
	if err = deleteDeviceProfile(dp, w); err != nil {
		LoggingClient.Error(err.Error())
		return
	}
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)
	w.Write([]byte("true"))
}
180593
func (s *CancelSigningProfileInput) SetProfileName(v string) *CancelSigningProfileInput {
	s.ProfileName = &v
	return s
}