auth.go

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
package common

import (
	"fmt"
	"strings"
)

type AuthInfo struct {
	Name         string
	Domain       string
	IsMaintainer bool
}

func (ai AuthInfo) String() string {
	domain, isSecure := strings.CutPrefix(ai.Domain, "https://")
	if !isSecure {
		domain, _ = strings.CutPrefix(ai.Domain, "http://")
	}
	domain, _ = strings.CutSuffix(domain, "/")
	return fmt.Sprintf("%s@%s", ai.Name, domain)
}