package types

import "errors"

type OidcProviderType string

const (
	GithubOidcProvider OidcProviderType = "github"
	FakeOidcProvider   OidcProviderType = "fake"
)

// String is used both by fmt.Print and by Cobra in help text
func (e *OidcProviderType) String() string {
	return string(*e)
}

// Set must have pointer receiver so it doesn't change the value of a copy
func (e *OidcProviderType) Set(v string) error {
	switch v {
	case string(GithubOidcProvider):
		*e = OidcProviderType(v)
		return nil
	case string(FakeOidcProvider):
		*e = OidcProviderType(v)
		return nil
	default:
		return errors.New(`only support github`)
	}
}

// Type is only used in help text
func (e *OidcProviderType) Type() string {
	return "OidcProvider"
}

type OidcProvider interface {
	GetTokenUrl() string
	GetToken() string
	GetIdToken() (string, error)
	GetRunID() string
	IsFake() bool
	GetEnvMap() map[string]string
}
