Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PodNetworkConnectivityChecks #174

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ var GetCmd = &cobra.Command{
getClusterLoggingResources(resourceNamePlural, resourceGroup, vars.GetArgs[resourceNamePlural+"."+resourceGroup])
} else if resourceNamePlural == "clusterlogforwarders" {
getClusterLogForwarderResources(resourceNamePlural, resourceGroup, vars.GetArgs[resourceNamePlural+"."+resourceGroup])
} else if resourceNamePlural == "podnetworkconnectivitychecks" {
getPodNetworkConnectivityChecksResources(resourceNamePlural, resourceGroup, vars.GetArgs[resourceNamePlural+"."+resourceGroup])
} else if namespaced {
getNamespacedResources(resourceNamePlural, resourceGroup, vars.GetArgs[resourceNamePlural+"."+resourceGroup])
} else {
Expand Down Expand Up @@ -544,3 +546,21 @@ func handleOutput(w io.Writer) {
}
}
}

func getPodNetworkConnectivityChecksResources(resourceNamePlural string, resourceGroup string, resources map[string]struct{}) {
resourcesYamlPath := vars.MustGatherRootPath + "/pod_network_connectivity_check/podnetworkconnectivitychecks.yaml"
_file, err := ioutil.ReadFile(resourcesYamlPath)
if err == nil {
UnstructuredItems := types.UnstructuredList{ApiVersion: "v1", Kind: "List"}
if err := yaml.Unmarshal(_file, &UnstructuredItems); err != nil {
fmt.Fprintln(os.Stderr, "Error when trying to unmarshal file: "+resourcesYamlPath)
os.Exit(1)
}
for _, item := range UnstructuredItems.Items {
_, ok := resources[item.GetName()]
if ok || len(resources) == 0 {
handleObject(item)
}
}
}
}
Loading