mirror of
https://github.com/rancher/os.git
synced 2025-09-16 06:59:12 +00:00
Fix golint errors
This commit is contained in:
@@ -31,15 +31,15 @@ const (
|
||||
userdataPath = apiVersion + "instance/attributes/user-data"
|
||||
)
|
||||
|
||||
type metadataService struct {
|
||||
type MetadataService struct {
|
||||
metadata.MetadataService
|
||||
}
|
||||
|
||||
func NewDatasource(root string) *metadataService {
|
||||
return &metadataService{metadata.NewDatasource(root, apiVersion, userdataPath, metadataPath, http.Header{"Metadata-Flavor": {"Google"}})}
|
||||
func NewDatasource(root string) *MetadataService {
|
||||
return &MetadataService{metadata.NewDatasource(root, apiVersion, userdataPath, metadataPath, http.Header{"Metadata-Flavor": {"Google"}})}
|
||||
}
|
||||
|
||||
func (ms metadataService) FetchMetadata() (datasource.Metadata, error) {
|
||||
func (ms MetadataService) FetchMetadata() (datasource.Metadata, error) {
|
||||
public, err := ms.fetchIP("instance/network-interfaces/0/access-configs/0/external-ip")
|
||||
if err != nil {
|
||||
return datasource.Metadata{}, err
|
||||
@@ -53,16 +53,16 @@ func (ms metadataService) FetchMetadata() (datasource.Metadata, error) {
|
||||
return datasource.Metadata{}, err
|
||||
}
|
||||
|
||||
projectSshKeys, err := ms.fetchString("project/attributes/sshKeys")
|
||||
projectSSHKeys, err := ms.fetchString("project/attributes/sshKeys")
|
||||
if err != nil {
|
||||
return datasource.Metadata{}, err
|
||||
}
|
||||
instanceSshKeys, err := ms.fetchString("instance/attributes/sshKeys")
|
||||
instanceSSHKeys, err := ms.fetchString("instance/attributes/sshKeys")
|
||||
if err != nil {
|
||||
return datasource.Metadata{}, err
|
||||
}
|
||||
|
||||
keyStrings := strings.Split(projectSshKeys+"\n"+instanceSshKeys, "\n")
|
||||
keyStrings := strings.Split(projectSSHKeys+"\n"+instanceSSHKeys, "\n")
|
||||
|
||||
sshPublicKeys := map[string]string{}
|
||||
i := 0
|
||||
@@ -85,11 +85,11 @@ func (ms metadataService) FetchMetadata() (datasource.Metadata, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (ms metadataService) Type() string {
|
||||
func (ms MetadataService) Type() string {
|
||||
return "gce-metadata-service"
|
||||
}
|
||||
|
||||
func (ms metadataService) fetchString(key string) (string, error) {
|
||||
func (ms MetadataService) fetchString(key string) (string, error) {
|
||||
data, err := ms.FetchData(ms.MetadataUrl() + key)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -98,7 +98,7 @@ func (ms metadataService) fetchString(key string) (string, error) {
|
||||
return string(data), nil
|
||||
}
|
||||
|
||||
func (ms metadataService) fetchIP(key string) (net.IP, error) {
|
||||
func (ms MetadataService) fetchIP(key string) (net.IP, error) {
|
||||
str, err := ms.fetchString(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -110,12 +110,11 @@ func (ms metadataService) fetchIP(key string) (net.IP, error) {
|
||||
|
||||
if ip := net.ParseIP(str); ip != nil {
|
||||
return ip, nil
|
||||
} else {
|
||||
return nil, fmt.Errorf("couldn't parse %q as IP address", str)
|
||||
}
|
||||
return nil, fmt.Errorf("couldn't parse %q as IP address", str)
|
||||
}
|
||||
|
||||
func (ms metadataService) FetchUserdata() ([]byte, error) {
|
||||
func (ms MetadataService) FetchUserdata() ([]byte, error) {
|
||||
data, err := ms.FetchData(ms.UserdataUrl())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user