func NewMetadataCredentialService(addr string, opts *Options) (*metadataCredentialService, error) {
	mcs := new(metadataCredentialService)
	mcs.options = opts
	if opts.Logger != nil {
		logger = opts.Logger
	}
	mcs.configResolver = config.DefaultResolver.WithLogger(logger)
	mcs.clientOptions = client.DefaultOptions
	mcs.clientOptions.Logger = logger
	mcs.clientOptions.AwsLogLevel = opts.AwsLogLevel
	var err error
	if strings.HasPrefix(addr, DefaultEc2ImdsAddr) && os.Getuid() != 0 && runtime.GOOS == "linux" {
		logger.Debugf("enabling Linux capabilities")
		if err = linuxSetCap(); err != nil {
			return nil, err
		}
	}
	mcs.listener, err = configureListener(addr)
	if err != nil {
		return nil, err
	}
	indexHtml, err = content.ReadFile("templates/index.html")
	if err != nil {
		return nil, err
	}
	siteCss, err = content.ReadFile("templates/site.css")
	if err != nil {
		return nil, err
	}
	favicon, err = content.ReadFile("templates/favicon.ico")
	if err != nil {
		return nil, err
	}
	return mcs, nil
}
NewMetadataCredentialService creates a new metadataCredentialService using the supplied 'opts' Options.
After calling this constructor, the service can be started via the Run() method.
package metadata
import (
	"context"
	"embed"
	"encoding/json"
	"errors"
	"fmt"
	"github.com/aws/smithy-go/logging"
	"github.com/mmmorris1975/aws-runas/client"
	"github.com/mmmorris1975/aws-runas/config"
	"github.com/mmmorris1975/aws-runas/credentials"
	"github.com/mmmorris1975/aws-runas/credentials/helpers"
	"github.com/mmmorris1975/aws-runas/shared"
	"github.com/syndtr/gocapability/capability"
	"io"
	"net"
	"net/http"
	"net/http/httptest"
	"net/url"
	"os"
	"os/signal"
	"runtime"
	"strings"
	"sync"
	"syscall"
	"text/template"
)
const (
	DefaultEcsCredPath = "/credentials"
	DefaultEc2ImdsAddr = "169.254.169.254"
	DefaultEc2ImdsCidr = DefaultEc2ImdsAddr + "/22"
	imdsv2TtlHdr = "X-Aws-Ec2-Metadata-Token-Ttl-Seconds"
	imdsTokenPath    = "/latest/api/token"  
	ec2CredPath      = "/latest/meta-data/iam/security-credentials/"
	authPath         = "/auth"
	mfaPath          = "/mfa"
	profilePath      = "/profile"
	newProfilePath   = "/profile/custom"
	listRolesPath    = "/list-roles"
	listProfilesPath = "/list-profiles"
	refreshPath      = "/refresh"
)
var (
	logger shared.Logger = new(shared.DefaultLogger)
	content embed.FS
	mu sync.Mutex  
	indexHtml, siteCss, favicon []byte
)
type Options struct {
	Path        string
	Profile     string
	Logger      shared.Logger
	AwsLogLevel logging.Classification
	Headless    bool
}
type metadataCredentialService struct {
	options        *Options
	awsClient      client.AwsClient
	awsConfig      *config.AwsConfig
	configResolver config.Resolver
	clientFactory  *client.Factory
	clientOptions  *client.Options
	listener       net.Listener
}