Skip to content

Commit f76274a

Browse files
committed
Add a data type for discovery data gatherer
Signed-off-by: Richard Wall <[email protected]>
1 parent d54d435 commit f76274a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pkg/datagatherer/k8s/discovery.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66

7+
"k8s.io/apimachinery/pkg/version"
78
"k8s.io/client-go/discovery"
89

910
"github.com/jetstack/preflight/pkg/datagatherer"
@@ -57,17 +58,18 @@ func (g *DataGathererDiscovery) WaitForCacheSync(ctx context.Context) error {
5758
return nil
5859
}
5960

61+
type DiscoveryData struct {
62+
ServerVersion *version.Info `json:"server_version"`
63+
}
64+
6065
// Fetch will fetch discovery data from the apiserver, or return an error
6166
func (g *DataGathererDiscovery) Fetch() (interface{}, int, error) {
62-
data, err := g.cl.ServerVersion()
67+
serverVersion, err := g.cl.ServerVersion()
6368
if err != nil {
6469
return nil, -1, fmt.Errorf("failed to get server version: %v", err)
6570
}
6671

67-
response := map[string]interface{}{
68-
// data has type Info: https://godoc.org/k8s.io/apimachinery/pkg/version#Info
69-
"server_version": data,
70-
}
71-
72-
return response, len(response), nil
72+
return &DiscoveryData{
73+
ServerVersion: serverVersion,
74+
}, 1, nil
7375
}

0 commit comments

Comments
 (0)