Skip to content

Commit f9039a0

Browse files
authored
Merge pull request #533 from replicatedhq/divolgin/gvk
Add GVK to k8s objects in cluster-resources files
2 parents 6f0cf65 + 3351c28 commit f9039a0

25 files changed

+12479
-12187
lines changed

pkg/analyze/cluster_pod_statuses.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ func clusterPodStatuses(analyzer *troubleshootv1beta2.ClusterPodStatuses, getChi
3131
}
3232
}
3333
if include {
34-
var nsPods []corev1.Pod
34+
var nsPods corev1.PodList
3535
if err := json.Unmarshal(fileContent, &nsPods); err != nil {
3636
return nil, errors.Wrapf(err, "failed to unmarshal pods list for namespace %s", podsNs)
3737
}
38-
pods = append(pods, nsPods...)
38+
pods = append(pods, nsPods.Items...)
3939
}
4040
}
4141

pkg/analyze/container_runtime.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ func analyzeContainerRuntime(analyzer *troubleshootv1beta2.ContainerRuntime, get
1616
return nil, errors.Wrap(err, "failed to get contents of nodes.json")
1717
}
1818

19-
var nodes []corev1.Node
19+
var nodes corev1.NodeList
2020
if err := json.Unmarshal(collected, &nodes); err != nil {
2121
return nil, errors.Wrap(err, "failed to unmarshal node list")
2222
}
2323

2424
foundRuntimes := []string{}
25-
for _, node := range nodes {
25+
for _, node := range nodes.Items {
2626
foundRuntimes = append(foundRuntimes, node.Status.NodeInfo.ContainerRuntimeVersion)
2727
}
2828

pkg/analyze/crd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func analyzeCustomResourceDefinition(analyzer *troubleshootv1beta2.CustomResourc
1414
return nil, err
1515
}
1616

17-
var crds []apiextensionsv1beta1.CustomResourceDefinition
17+
var crds apiextensionsv1beta1.CustomResourceDefinitionList
1818
if err := json.Unmarshal(crdData, &crds); err != nil {
1919
return nil, err
2020
}
@@ -30,7 +30,7 @@ func analyzeCustomResourceDefinition(analyzer *troubleshootv1beta2.CustomResourc
3030
IconURI: "https://troubleshoot.sh/images/analyzer-icons/custom-resource-definition.svg?w=13&h=16",
3131
}
3232

33-
for _, crd := range crds {
33+
for _, crd := range crds.Items {
3434
if crd.Name == analyzer.CustomResourceDefinitionName {
3535
result.IsPass = true
3636
for _, outcome := range analyzer.Outcomes {

pkg/analyze/deployment_status.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ func analyzeOneDeploymentStatus(analyzer *troubleshootv1beta2.DeploymentStatus,
2626

2727
var result *AnalyzeResult
2828
for _, collected := range files { // only 1 file here
29-
var deployments []appsv1.Deployment
29+
var deployments appsv1.DeploymentList
3030
if err := json.Unmarshal(collected, &deployments); err != nil {
3131
return nil, errors.Wrap(err, "failed to unmarshal deployment list")
3232
}
3333

3434
var status *appsv1.DeploymentStatus
35-
for _, deployment := range deployments {
35+
for _, deployment := range deployments.Items {
3636
if deployment.Name == analyzer.Name {
3737
status = deployment.Status.DeepCopy()
3838
}
@@ -80,12 +80,12 @@ func analyzeAllDeploymentStatuses(analyzer *troubleshootv1beta2.DeploymentStatus
8080
}
8181

8282
for _, collected := range files {
83-
var deployments []appsv1.Deployment
83+
var deployments appsv1.DeploymentList
8484
if err := json.Unmarshal(collected, &deployments); err != nil {
8585
return nil, errors.Wrap(err, "failed to unmarshal deployment list")
8686
}
8787

88-
for _, deployment := range deployments {
88+
for _, deployment := range deployments.Items {
8989
if deployment.Status.Replicas == deployment.Status.AvailableReplicas {
9090
continue
9191
}

pkg/analyze/distribution.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ func analyzeDistribution(analyzer *troubleshootv1beta2.Distribution, getCollecte
139139
return nil, errors.Wrap(err, "failed to get contents of nodes.json")
140140
}
141141

142-
var nodes []corev1.Node
142+
var nodes corev1.NodeList
143143
if err := json.Unmarshal(collected, &nodes); err != nil {
144144
return nil, errors.Wrap(err, "failed to unmarshal node list")
145145
}
146146

147-
foundProviders, _ := ParseNodesForProviders(nodes)
147+
foundProviders, _ := ParseNodesForProviders(nodes.Items)
148148

149149
apiResourcesBytes, err := getCollectedFileContents("cluster-resources/resources.json")
150150
// if the file is not found, that is not a fatal error

pkg/analyze/files/deployments/default.json

Lines changed: 421 additions & 414 deletions
Large diffs are not rendered by default.

pkg/analyze/files/deployments/kube-system.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
[
1+
{
2+
"kind": "DeploymentList",
3+
"apiVersion": "apps/v1",
4+
"metadata": {
5+
"resourceVersion": "27195652"
6+
},
7+
"items": [
28
{
39
"metadata": {
410
"name": "coredns",
@@ -658,4 +664,4 @@
658664
}
659665
}
660666
]
661-
667+
}

pkg/analyze/files/deployments/monitoring.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
[
1+
{
2+
"kind": "DeploymentList",
3+
"apiVersion": "apps/v1",
4+
"metadata": {
5+
"resourceVersion": "27195653"
6+
},
7+
"items": [
28
{
39
"metadata": {
410
"name": "grafana",
@@ -1640,5 +1646,5 @@
16401646
]
16411647
}
16421648
}
1643-
]
1644-
1649+
]
1650+
}

pkg/analyze/files/jobs/projectcontour.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
[
1+
{
2+
"kind": "JobList",
3+
"apiVersion": "batch/v1",
4+
"metadata": {
5+
"resourceVersion": "27195661"
6+
},
7+
"items": [
28
{
39
"metadata": {
410
"name": "contour-certgen-v1.19.1",
@@ -195,4 +201,4 @@
195201
}
196202
}
197203
]
198-
204+
}

0 commit comments

Comments
 (0)