-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2026 from syedriko/syedriko-master-lint
Make lint happy
- Loading branch information
Showing
4 changed files
with
33 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 16 additions & 16 deletions
32
internal/validations/clusterlogforwarder/validate_url_to_output_tls_config.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package clusterlogforwarder | ||
|
||
import ( | ||
"fmt" | ||
log "github.com/ViaQ/logerr/v2/log/static" | ||
"github.com/openshift/cluster-logging-operator/apis/logging/v1" | ||
"github.com/openshift/cluster-logging-operator/internal/url" | ||
"strings" | ||
"fmt" | ||
log "github.com/ViaQ/logerr/v2/log/static" | ||
"github.com/openshift/cluster-logging-operator/apis/logging/v1" | ||
"github.com/openshift/cluster-logging-operator/internal/url" | ||
"strings" | ||
) | ||
|
||
// validateUrlAccordingToTls validate that if Output has TLS configuration Output URL scheme must be secure e.g. https, tls etc | ||
func validateUrlAccordingToTls(clf v1.ClusterLogForwarder) error { | ||
for i, output := range clf.Spec.Outputs { | ||
_, output := i, output // Don't bind range variable. | ||
u, _ := url.Parse(output.URL) | ||
scheme := strings.ToLower(u.Scheme) | ||
if !url.IsTLSScheme(scheme) && (output.TLS != nil && (output.TLS.InsecureSkipVerify || output.TLS.TLSSecurityProfile != nil)) { | ||
log.V(3).Info("validateUrlAccordingToTls failed", "reason", "URL not secure but output has TLS configuration parameters", | ||
"output URL", output.URL, "output Name", output.Name) | ||
return fmt.Errorf("URL not secure: %v, but output %s has TLS configuration parameters", u, output.Name) | ||
} | ||
} | ||
return nil | ||
for i, output := range clf.Spec.Outputs { | ||
_, output := i, output // Don't bind range variable. | ||
u, _ := url.Parse(output.URL) | ||
scheme := strings.ToLower(u.Scheme) | ||
if !url.IsTLSScheme(scheme) && (output.TLS != nil && (output.TLS.InsecureSkipVerify || output.TLS.TLSSecurityProfile != nil)) { | ||
log.V(3).Info("validateUrlAccordingToTls failed", "reason", "URL not secure but output has TLS configuration parameters", | ||
"output URL", output.URL, "output Name", output.Name) | ||
return fmt.Errorf("URL not secure: %v, but output %s has TLS configuration parameters", u, output.Name) | ||
} | ||
} | ||
return nil | ||
} |