Skip to content

Commit

Permalink
feat: add metadata info (#25)
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <[email protected]>

Signed-off-by: chenk <[email protected]>
  • Loading branch information
chen-keinan authored Jan 4, 2023
1 parent c0f6938 commit 5d8355b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pkg/collector/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package collector
import (
"fmt"
"os"
"time"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -39,6 +40,7 @@ func CollectNodeData(cmd *cobra.Command) error {
APIVersion: Version,
Kind: Kind,
Type: nodeType,
Metadata: map[string]string{"creationTimestamp": time.Now().Format(time.RFC3339)},
Info: nodeInfo,
}
outputFormat := cmd.Flag("output").Value.String()
Expand Down
9 changes: 5 additions & 4 deletions pkg/collector/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ func getSpecInfo(info string) (*SpecInfo, error) {

// Node output node data with info results
type Node struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Type string `json:"type"`
Info map[string]*Info `json:"info"`
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Metadata map[string]string `json:"metadata"`
Type string `json:"type"`
Info map[string]*Info `json:"info"`
}

// Info comand output result
Expand Down
2 changes: 2 additions & 0 deletions pkg/collector/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package collector

import (
"bytes"

"os"
"testing"

Expand All @@ -22,6 +23,7 @@ func TestPrintOutput(t *testing.T) {
nodeData: Node{
APIVersion: Version,
Type: MasterNode,
Metadata: map[string]string{"creationTimestamp": "now"},
Kind: "NodeInfo",
Info: map[string]*Info{
"AdminConfFilePermissions": {Values: []interface{}{600}},
Expand Down
2 changes: 1 addition & 1 deletion pkg/collector/testdata/fixture/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"apiVersion":"v1","kind":"NodeInfo","type":"master","info":{"AdminConfFilePermissions":{"values":[600]},"CertificateAuthoritiesFilePermissions":{"values":["root:root"]},"ContainerNetworkInterfaceFilePermissions":{"values":[700,500]}}}
{"apiVersion":"v1","kind":"NodeInfo","metadata":{"creationTimestamp":"now"},"type":"master","info":{"AdminConfFilePermissions":{"values":[600]},"CertificateAuthoritiesFilePermissions":{"values":["root:root"]},"ContainerNetworkInterfaceFilePermissions":{"values":[700,500]}}}

0 comments on commit 5d8355b

Please sign in to comment.