mirror of
https://github.com/k3s-io/k3s.git
synced 2026-02-03 20:39:49 -05:00
lint: exported
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
parent
7c7e442be0
commit
f279a979b3
6 changed files with 35 additions and 35 deletions
|
|
@ -92,8 +92,8 @@ func collectCertInfo(controlConfig config.Control, ServicesList []string) (*Cert
|
|||
return result, nil
|
||||
}
|
||||
|
||||
// CertFormatter defines the interface for formatting certificate information
|
||||
type CertFormatter interface {
|
||||
// Formatter defines the interface for formatting certificate information
|
||||
type Formatter interface {
|
||||
Format(*CertificateInfo) error
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ func check(app *cli.Context, cfg *cmds.Server) error {
|
|||
}
|
||||
outFmt := app.String("output")
|
||||
|
||||
var formatter CertFormatter
|
||||
var formatter Formatter
|
||||
switch outFmt {
|
||||
case "text":
|
||||
formatter = &TextFormatter{Writer: os.Stdout}
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
|
|||
|
||||
// if not set, try setting advertise-ip from agent VPN
|
||||
if cmds.AgentConfig.VPNAuth != "" {
|
||||
vpnInfo, err := vpn.GetVPNInfo(cmds.AgentConfig.VPNAuth)
|
||||
vpnInfo, err := vpn.GetInfo(cmds.AgentConfig.VPNAuth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
const scheme = "etcd-endpoint"
|
||||
|
||||
type EtcdSimpleResolver struct {
|
||||
type SimpleResolver struct {
|
||||
*manual.Resolver
|
||||
endpoint string
|
||||
}
|
||||
|
|
@ -19,12 +19,12 @@ type EtcdSimpleResolver struct {
|
|||
// Cribbed from https://github.com/etcd-io/etcd/blob/v3.6.4/client/v3/internal/resolver/resolver.go
|
||||
// but only supports a single fixed endpoint. We use this instead of the internal etcd client resolver
|
||||
// because the agent loadbalancer handles failover and we don't want etcd or grpc's special behavior.
|
||||
func NewSimpleResolver(endpoint string) *EtcdSimpleResolver {
|
||||
func NewSimpleResolver(endpoint string) *SimpleResolver {
|
||||
r := manual.NewBuilderWithScheme(scheme)
|
||||
return &EtcdSimpleResolver{Resolver: r, endpoint: endpoint}
|
||||
return &SimpleResolver{Resolver: r, endpoint: endpoint}
|
||||
}
|
||||
|
||||
func (r *EtcdSimpleResolver) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
|
||||
func (r *SimpleResolver) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
|
||||
res, err := r.Resolver.Build(target, cc, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ import (
|
|||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
type SnapshotStatus string
|
||||
type Status string
|
||||
|
||||
const (
|
||||
SuccessfulStatus SnapshotStatus = "successful"
|
||||
FailedStatus SnapshotStatus = "failed"
|
||||
SuccessfulStatus Status = "successful"
|
||||
FailedStatus Status = "failed"
|
||||
|
||||
CompressedExtension = ".zip"
|
||||
MetadataDir = ".metadata"
|
||||
|
|
@ -59,15 +59,15 @@ type File struct {
|
|||
Name string `json:"name"`
|
||||
// Location contains the full path of the snapshot. For
|
||||
// local paths, the location will be prefixed with "file://".
|
||||
Location string `json:"location,omitempty"`
|
||||
Metadata string `json:"metadata,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
NodeName string `json:"nodeName,omitempty"`
|
||||
CreatedAt *metav1.Time `json:"createdAt,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
Status SnapshotStatus `json:"status,omitempty"`
|
||||
S3 *S3Config `json:"s3Config,omitempty"`
|
||||
Compressed bool `json:"compressed"`
|
||||
Location string `json:"location,omitempty"`
|
||||
Metadata string `json:"metadata,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
NodeName string `json:"nodeName,omitempty"`
|
||||
CreatedAt *metav1.Time `json:"createdAt,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
Status Status `json:"status,omitempty"`
|
||||
S3 *S3Config `json:"s3Config,omitempty"`
|
||||
Compressed bool `json:"compressed"`
|
||||
|
||||
// these fields are used for the internal representation of the snapshot
|
||||
// to populate other fields before serialization to the legacy configmap.
|
||||
|
|
|
|||
|
|
@ -102,9 +102,9 @@ func (e *Embedded) Bootstrap(ctx context.Context, nodeConfig *daemonconfig.Node,
|
|||
}
|
||||
|
||||
// If there is a VPN, we must overwrite NodeIP and flannel interface
|
||||
var vpnInfo vpn.VPNInfo
|
||||
var vpnInfo *vpn.Info
|
||||
if cfg.VPNAuth != "" {
|
||||
vpnInfo, err = vpn.GetVPNInfo(cfg.VPNAuth)
|
||||
vpnInfo, err = vpn.GetInfo(cfg.VPNAuth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -136,9 +136,9 @@ func (e *Embedded) Bootstrap(ctx context.Context, nodeConfig *daemonconfig.Node,
|
|||
logrus.Warn("VPN provider overrides node-external-ip parameter")
|
||||
}
|
||||
nodeIPs = vpnIPs
|
||||
nodeConfig.Flannel.Iface, err = net.InterfaceByName(vpnInfo.VPNInterface)
|
||||
nodeConfig.Flannel.Iface, err = net.InterfaceByName(vpnInfo.Interface)
|
||||
if err != nil {
|
||||
return pkgerrors.WithMessagef(err, "unable to find vpn interface: %s", vpnInfo.VPNInterface)
|
||||
return pkgerrors.WithMessagef(err, "unable to find vpn interface: %s", vpnInfo.Interface)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ type TailscalePrefsOutput struct {
|
|||
AdvertiseRoutes []netip.Prefix `json:"AdvertiseRoutes"`
|
||||
}
|
||||
|
||||
// VPNInfo includes node information of the VPN. It is a general struct in case we want to add more vpn integrations
|
||||
type VPNInfo struct {
|
||||
// Info includes node information of the VPN. It is a general struct in case we want to add more vpn integrations
|
||||
type Info struct {
|
||||
BackendState string
|
||||
IPv4Address net.IP
|
||||
IPv6Address net.IP
|
||||
NodeID string
|
||||
ProviderName string
|
||||
VPNInterface string
|
||||
Interface string
|
||||
}
|
||||
|
||||
// vpnCliAuthInfo includes auth information of the VPN. It is a general struct in case we want to add more vpn integrations
|
||||
|
|
@ -82,17 +82,17 @@ func StartVPN(vpnAuthConfigFile string) error {
|
|||
}
|
||||
}
|
||||
|
||||
// GetVPNInfo returns a VPNInfo object with details about the VPN. General function in case we want to add more vpn integrations
|
||||
func GetVPNInfo(vpnAuth string) (VPNInfo, error) {
|
||||
// GetInfo returns an Info object with details about the VPN. General function in case we want to add more vpn integrations
|
||||
func GetInfo(vpnAuth string) (*Info, error) {
|
||||
authInfo, err := getVPNAuthInfo(vpnAuth)
|
||||
if err != nil {
|
||||
return VPNInfo{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if authInfo.Name == "tailscale" {
|
||||
return getTailscaleInfo()
|
||||
}
|
||||
return VPNInfo{}, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// getVPNAuthInfo returns the required authInfo object
|
||||
|
|
@ -142,10 +142,10 @@ func isVPNConfigOK(authInfo vpnCliAuthInfo) error {
|
|||
}
|
||||
|
||||
// getTailscaleInfo returns the IPs of the interface
|
||||
func getTailscaleInfo() (VPNInfo, error) {
|
||||
func getTailscaleInfo() (*Info, error) {
|
||||
output, err := util.ExecCommand("tailscale", []string{"status", "--json"})
|
||||
if err != nil {
|
||||
return VPNInfo{}, fmt.Errorf("failed to run tailscale status --json: %v", err)
|
||||
return nil, fmt.Errorf("failed to run tailscale status --json: %v", err)
|
||||
}
|
||||
|
||||
logrus.Debugf("Output from tailscale status --json: %v", output)
|
||||
|
|
@ -153,14 +153,14 @@ func getTailscaleInfo() (VPNInfo, error) {
|
|||
var tailscaleOutput TailscaleOutput
|
||||
err = json.Unmarshal([]byte(output), &tailscaleOutput)
|
||||
if err != nil {
|
||||
return VPNInfo{}, fmt.Errorf("failed to unmarshal tailscale output: %v", err)
|
||||
return nil, fmt.Errorf("failed to unmarshal tailscale output: %v", err)
|
||||
}
|
||||
|
||||
// Errors are ignored because the interface might not have ipv4 or ipv6 addresses (that's the only possible error)
|
||||
ipv4Address, _ := util.GetFirst4String(tailscaleOutput.TailscaleIPs)
|
||||
ipv6Address, _ := util.GetFirst6String(tailscaleOutput.TailscaleIPs)
|
||||
|
||||
return VPNInfo{BackendState: tailscaleOutput.BackendState, IPv4Address: net.ParseIP(ipv4Address), IPv6Address: net.ParseIP(ipv6Address), NodeID: "", ProviderName: "tailscale", VPNInterface: tailscaleIf}, nil
|
||||
return &Info{BackendState: tailscaleOutput.BackendState, IPv4Address: net.ParseIP(ipv4Address), IPv6Address: net.ParseIP(ipv6Address), NodeID: "", ProviderName: "tailscale", Interface: tailscaleIf}, nil
|
||||
}
|
||||
|
||||
// get Tailscale advertised route list
|
||||
|
|
|
|||
Loading…
Reference in a new issue