Skip to content

Commit 0479a4e

Browse files
committed
refactor: Remove unneeded code
1 parent fd7f8e6 commit 0479a4e

File tree

2 files changed

+0
-67
lines changed

2 files changed

+0
-67
lines changed

dynatrace/export/enums.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,38 +57,6 @@ func (rt ResourceType) IsPotentialCircularDependencyTo(referringResourceID strin
5757
return rt == ResourceTypes.JSONDashboard && referredToResourceType == ResourceTypes.JSONDashboardBase && referringResourceID != referredToResourceID
5858
}
5959

60-
func (rt ResourceType) VoidResource(resource *Resource, contents []byte) ([]byte, bool) {
61-
if !rt.CanGetVoidedIfNotReferenced() {
62-
return contents, false
63-
}
64-
dashboardBaseReference := fmt.Sprintf(`${dynatrace_json_dashboard_base.%s.id}`, resource.UniqueName)
65-
dashboardReference := fmt.Sprintf(`${dynatrace_json_dashboard.%s.id}`, resource.UniqueName)
66-
var results string
67-
lastLineWasSpace := false
68-
for _, line := range strings.Split(string(contents), "\n") {
69-
if strings.Contains(line, "link_id") && strings.Contains(line, dashboardBaseReference) {
70-
continue
71-
} else if strings.Contains(line, "dashboard_id") && strings.Contains(line, dashboardBaseReference) {
72-
line = strings.Replace(line, dashboardBaseReference, dashboardReference, 1)
73-
}
74-
curLineIsSpace := len(strings.TrimSpace(line)) == 0
75-
if curLineIsSpace {
76-
if lastLineWasSpace {
77-
continue
78-
}
79-
}
80-
lastLineWasSpace = curLineIsSpace
81-
results = results + "\n" + line
82-
}
83-
// Here we assume (see ResourceType.Less) that the resource block `dynatrace_json_dashboard_base`
84-
// is located at the very end of the file. The resource block is expected to be empty.
85-
// Therefore we can expect that the } before the last one signals the end of the
86-
// resource blocks that are allowed to remain. Everything past that will get cut off
87-
results = results[:strings.LastIndex(results, "}")]
88-
results = results[:strings.LastIndex(results, "}")+1]
89-
return []byte(results), true
90-
}
91-
9260
func (rt ResourceType) CanGetVoidedIfNotReferenced() bool {
9361
return rt == ResourceTypes.JSONDashboardBase
9462
}

dynatrace/export/environment.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ var NO_REFRESH_ON_IMPORT = os.Getenv("DYNATRACE_NO_REFRESH_ON_IMPORT") == "true"
5050
var QUICK_INIT = os.Getenv("DYNATRACE_QUICK_INIT") == "true"
5151
var ULTRA_PARALLEL = os.Getenv("DYNATRACE_ULTRA_PARALLEL") == "true"
5252

53-
// var JSON_DASHBOARD_BASE_PLUS = os.Getenv("DYNATRACE_JSON_DASHBOARD_BASE_PLUS") == "true"
54-
var JSON_DASHBOARD_BASE_PLUS = true
55-
5653
const ENV_VAR_CUSTOM_PROVIDER_LOCATION = "DYNATRACE_CUSTOM_PROVIDER_LOCATION"
5754

5855
type Environment struct {
@@ -475,38 +472,6 @@ func (me *Environment) PostProcess() error {
475472
}
476473
}
477474

478-
if JSON_DASHBOARD_BASE_PLUS {
479-
// pass
480-
} else {
481-
for _, resourcesByIDToVoid := range resourcesToVoid {
482-
for _, resourceToVoid := range resourcesByIDToVoid {
483-
if err := voidResource(resourceToVoid); err != nil {
484-
logging.Debug.Warn.Printf("[POSTPROCESS] [%s][%s] Unable to remove resource: %s", resourceToVoid.Type, resourceToVoid.ID, err.Error())
485-
}
486-
}
487-
}
488-
}
489-
490-
return nil
491-
}
492-
493-
func voidResource(resource *Resource) error {
494-
if resource == nil {
495-
return nil
496-
}
497-
var err error
498-
var resourceBytes []byte
499-
var changed bool
500-
if resourceBytes, err = resource.ReadFile(); err != nil {
501-
return err
502-
}
503-
if resourceBytes, changed = resource.Type.VoidResource(resource, resourceBytes); changed {
504-
var resourceFile *os.File
505-
if resourceFile, err = resource.CreateFile(); err == nil {
506-
defer resourceFile.Close()
507-
resourceFile.Write(resourceBytes)
508-
}
509-
}
510475
return nil
511476
}
512477

0 commit comments

Comments
 (0)