You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: credentials.go
    path of file: ./repos/juju/provider/openstack
    
    the code of the file until where you have to start completion: // Copyright 2016 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package openstack

import (
	"fmt"
	"os"
	"path/filepath"
	"regexp"
	"strconv"

	"github.com/go-goose/goose/v5/identity"
	"github.com/juju/errors"
	"github.com/juju/utils/v3"
	"gopkg.in/ini.v1"

	"github.com/juju/juju/cloud"
	"github.com/juju/juju/environs"
)

const (
	CredAttrTenantName        = "tenant-name"
	CredAttrTenantID          = "tenant-id"
	CredAttrUserName          = "username"
	CredAttrPassword          = "password"
	CredAttrDomainName        = "domain-name"
	CredAttrProjectDomainName = "project-domain-name"
	CredAttrUserDomainName    = "user-domain-name"
	CredAttrAccessKey         = "access-key"
	CredAttrSecretKey         = "secret-key"
	CredAttrVersion           = "version"
)

type OpenstackCredentials struct{}

// CredentialSchemas is part of the environs.ProviderCredentials interface.
func (OpenstackCredentials) CredentialSchemas() map[cloud.AuthType]cloud.CredentialSchema {
	return map[cloud.AuthType]cloud.CredentialSchema{
		cloud.UserPassAuthType: {
			{
				CredAttrUserName, cloud.CredentialAttr{Description: "The username
    
func (c OpenstackCredentials) detectCredential() (*cloud.Credential, string, string, error) {
	creds, err := identity.CredentialsFromEnv()
	if err != nil {
		return nil, "", "", errors.Errorf("failed to retrieve credential from env : %v", err)
	}
	if creds.TenantName == "" {
		logger.Debugf("neither OS_TENANT_NAME nor OS_PROJECT_NAME environment variable not set")
	}
	if creds.TenantID == "" {
		logger.Debugf("neither OS_TENANT_ID nor OS_PROJECT_ID environment variable not set")
	}
	if creds.User == "" {
		return nil, "", "", errors.NewNotFound(nil, "neither OS_USERNAME nor OS_ACCESS_KEY environment variable not set")
	}
	if creds.Secrets == "" {
		return nil, "", "", errors.NewNotFound(nil, "neither OS_PASSWORD nor OS_SECRET_KEY environment variable not set")
	}

	user, err := utils.LocalUsername()
	if err != nil {
		return nil, "", "", errors.Trace(err)
	}

	var version string
	if creds.Version != 0 {
		version = strconv.Itoa(creds.Version)
	} else {
		version = ""
	}
	// If OS_USERNAME or NOVA_USERNAME is set, assume userpass.
	var credential cloud.Credential
	if os.Getenv("OS_USERNAME") != "" || os.Getenv("NOVA_USERNAME") != "" {
		user = creds.User
		credential = cloud.NewCredential(
			cloud.UserPassAuthType,
			map[string]string{
				CredAttrUserName:          creds.User,
				CredAttrPassword:          creds.Secrets,
				CredAttrTenantName:        creds.TenantName,
				CredAttrTenantID:          creds.TenantID,
				CredAttrUserDomainName:    creds.UserDomain,
				CredAttrProjectDomainName: creds.ProjectDomain,
				CredAttrDomainName:        creds.Domain,
				CredAttrVersion:           version,
			},
		)
	} else {
		credential = cloud.NewCredential(
			cloud.AccessKeyAuthType,
			map[string]string{
				CredAttrAccessKey:  creds.User,
				CredAttrSecretKey:  creds.Secrets,
				CredAttrTenantName: creds.TenantName,
				CredAttrTenantID:   creds.TenantID,
				CredAttrVersion:    version,
			},
		)
	}
	region := creds.Region
	if region == "" {
		region = "<unspecified>"
	}
	credential.Label = fmt.Sprintf("openstack region %q project %q user %q", region, creds.TenantName, user)
	return &credential, user, creds.Region, nil
}