refactor: Clean up code and change log format (#719)

This commit is contained in:
TwiN
2024-04-01 21:47:14 -04:00
committed by GitHub
parent 979d467e36
commit 922638e071
19 changed files with 95 additions and 96 deletions

View File

@ -150,7 +150,7 @@ func (c Condition) evaluate(result *Result, dontResolveFailedConditions bool) bo
return false
}
if !success {
//log.Printf("[Condition][evaluate] Condition '%s' did not succeed because '%s' is false", condition, condition)
//log.Printf("[Condition.evaluate] Condition '%s' did not succeed because '%s' is false", condition, condition)
}
result.ConditionResults = append(result.ConditionResults, &ConditionResult{Condition: conditionToDisplay, Success: success})
return success

View File

@ -151,7 +151,7 @@ func (s *SSH) ValidateAndSetDefaults() error {
}
// IsEnabled returns whether the endpoint is enabled or not
func (endpoint Endpoint) IsEnabled() bool {
func (endpoint *Endpoint) IsEnabled() bool {
if endpoint.Enabled == nil {
return true
}
@ -159,7 +159,7 @@ func (endpoint Endpoint) IsEnabled() bool {
}
// Type returns the endpoint type
func (endpoint Endpoint) Type() EndpointType {
func (endpoint *Endpoint) Type() EndpointType {
switch {
case endpoint.DNS != nil:
return EndpointTypeDNS
@ -264,7 +264,7 @@ func (endpoint *Endpoint) ValidateAndSetDefaults() error {
}
// DisplayName returns an identifier made up of the Name and, if not empty, the Group.
func (endpoint Endpoint) DisplayName() string {
func (endpoint *Endpoint) DisplayName() string {
if len(endpoint.Group) > 0 {
return endpoint.Group + "/" + endpoint.Name
}
@ -272,7 +272,7 @@ func (endpoint Endpoint) DisplayName() string {
}
// Key returns the unique key for the Endpoint
func (endpoint Endpoint) Key() string {
func (endpoint *Endpoint) Key() string {
return util.ConvertGroupAndEndpointNameToKey(endpoint.Group, endpoint.Name)
}

View File

@ -241,13 +241,13 @@ func TestEndpoint(t *testing.T) {
}
func TestEndpoint_IsEnabled(t *testing.T) {
if !(Endpoint{Enabled: nil}).IsEnabled() {
if !(&Endpoint{Enabled: nil}).IsEnabled() {
t.Error("endpoint.IsEnabled() should've returned true, because Enabled was set to nil")
}
if value := false; (Endpoint{Enabled: &value}).IsEnabled() {
if value := false; (&Endpoint{Enabled: &value}).IsEnabled() {
t.Error("endpoint.IsEnabled() should've returned false, because Enabled was set to false")
}
if value := true; !(Endpoint{Enabled: &value}).IsEnabled() {
if value := true; !(&Endpoint{Enabled: &value}).IsEnabled() {
t.Error("Endpoint.IsEnabled() should've returned true, because Enabled was set to true")
}
}