Skip to content

Commit

Permalink
remove path exception for logging resources
Browse files Browse the repository at this point in the history
  • Loading branch information
gmeghnag committed Sep 4, 2024
1 parent 107c08a commit 2d3d1ae
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 70 deletions.
41 changes: 1 addition & 40 deletions cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,10 @@ var GetCmd = &cobra.Command{
klog.V(1).ErrorS(err, "ERROR")
os.Exit(1)
}
// namespaces, clusterloggings and clusterlogforwarders locations
// namespaces and projects resources
// are exceptions to must-gather resources structure
if resourceNamePlural == "namespaces" || resourceNamePlural == "projects" {
getNamespacesResources(resourceNamePlural, resourceGroup, vars.GetArgs[resourceNamePlural+"."+resourceGroup])
} else if resourceNamePlural == "clusterloggings" {
getClusterLoggingResources(resourceNamePlural, resourceGroup, vars.GetArgs[resourceNamePlural+"."+resourceGroup])
} else if resourceNamePlural == "clusterlogforwarders" {
getClusterLogForwarderResources(resourceNamePlural, resourceGroup, vars.GetArgs[resourceNamePlural+"."+resourceGroup])
} else if namespaced {
getNamespacedResources(resourceNamePlural, resourceGroup, vars.GetArgs[resourceNamePlural+"."+resourceGroup])
} else {
Expand Down Expand Up @@ -271,41 +267,6 @@ func getNamespacedResources(resourceNamePlural string, resourceGroup string, res
}
}

func getClusterLogForwarderResources(resourceNamePlural string, resourceGroup string, resources map[string]struct{}) {
resourcesYamlPath := vars.MustGatherRootPath + "/cluster-logging/clo/clusterlogforwarder_instance.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)
}
}
}
}

func getClusterLoggingResources(resourceNamePlural string, resourceGroup string, resources map[string]struct{}) {
resourcesYamlPath := vars.MustGatherRootPath + "/cluster-logging/clo/clusterlogging_instance.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)
}
}
}
}

func getNamespacesResources(resourceNamePlural string, resourceGroup string, resources map[string]struct{}) {
if len(resources) > 0 {
Expand Down
30 changes: 0 additions & 30 deletions cmd/get/known-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,36 +203,6 @@ ns:
name: namespace
namespaced: false
plural: namespaces
clf:
group: logging.openshift.io
name: clusterlogforwarder
namespaced: false
plural: clusterlogforwarders
clusterlogforwarder:
group: logging.openshift.io
name: clusterlogforwarder
namespaced: false
plural: clusterlogforwarders
clusterlogforwarders:
group: logging.openshift.io
name: clusterlogforwarder
namespaced: true
plural: clusterlogforwarders
cl:
group: logging.openshift.io
name: clusterlogging
namespaced: false
plural: clusterloggings
clusterlogging:
group: logging.openshift.io
name: clusterlogging
namespaced: false
plural: clusterloggings
clusterloggings:
group: logging.openshift.io
name: clusterlogging
namespaced: true
plural: clusterloggings
node:
group: core
name: node
Expand Down

0 comments on commit 2d3d1ae

Please sign in to comment.