Skip to content

Commit

Permalink
fix: do not rename aws node names
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra authored and moshloop committed Oct 30, 2023
1 parent 0b9e4e8 commit e3af2bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions js/k8s.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ k8s = {
for (i in results) {
node = results[i].Object
components.push({
name: k8s.getNodeName(node.metadata.name),
name: node.metadata.name,
properties: [
{
name: "cpu",
Expand Down Expand Up @@ -181,9 +181,6 @@ k8s = {
}
return filtered
},
getNodeName: function(name) {
return name.replace(".compute.internal", "")
},
getPodTopology: function(results) {
var pods = []
for (i in results) {
Expand Down Expand Up @@ -269,7 +266,7 @@ k8s = {
for (i in results) {
node = results[i].Object
_node = {
name: k8s.getNodeName(node.metadata.name),
name: node.metadata.name,
type: "KubernetesNode",
external_id: node.metadata.name,
labels: k8s.filterLabels(node.metadata.labels),
Expand Down
6 changes: 3 additions & 3 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ func RunTemplate(environment map[string]any, template Template) (string, error)
vm := otto.New()
for k, v := range environment {
if err := vm.Set(k, v); err != nil {
return "", fmt.Errorf("error setting %s: %v", k, err)
return "", fmt.Errorf("error setting %s: %w", k, err)
}
}

out, err := vm.Run(template.Javascript)
if err != nil {
return "", fmt.Errorf("failed to run javascript: %v", err)
return "", fmt.Errorf("failed to run javascript: %w", err)
}

if s, err := out.ToString(); err != nil {
return "", fmt.Errorf("failed to cast output to string: %v", err)
return "", fmt.Errorf("failed to cast output to string: %w", err)
} else {
return s, nil
}
Expand Down
2 changes: 1 addition & 1 deletion tests/javascript_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestJavascript(t *testing.T) {
{map[string]interface{}{"arr": []int{1, 2, 1, 4, 1, 2}}, "_.uniq(arr)", "1,2,4"},
{map[string]interface{}{"x": "1Ki"}, "fromSI(x)", "1024"},
{map[string]interface{}{"x": "2m"}, "fromMillicores(x)", "2"},
{map[string]interface{}{"name": "mission.compute.internal"}, "k8s.getNodeName(name)", "mission"},
{map[string]any{"name": "mission"}, "name", "mission"},
{map[string]interface{}{"msg": map[string]any{"healthStatus": map[string]string{"status": "HEALTHY"}}}, "k8s.conditions.isReady(msg)", "true"},
{structEnv, `results.name + " " + results.Address.city_name`, "Aditya Kathmandu"},
}
Expand Down

0 comments on commit e3af2bf

Please sign in to comment.