-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Gate ECP logs behind ENABLE_ENTERPRISE_CERTIFICATE_LOGS environ…
…ment variable.
- Loading branch information
Showing
13 changed files
with
88 additions
and
1 deletion.
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
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,3 +1,7 @@ | ||
module github.com/googleapis/enterprise-certificate-proxy | ||
|
||
go 1.18 | ||
|
||
replace github.com/googleapis/enterprise-certificate-proxy/utils => ./utils | ||
|
||
require github.com/googleapis/enterprise-certificate-proxy/utils v0.0.0-00010101000000-000000000000 // indirect |
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,3 +1,7 @@ | ||
module signer | ||
|
||
go 1.18 | ||
go 1.18 | ||
|
||
replace github.com/googleapis/enterprise-certificate-proxy/utils => ../../../utils | ||
|
||
require github.com/googleapis/enterprise-certificate-proxy/utils v0.0.0-00010101000000-000000000000 // indirect |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module utils | ||
|
||
go 1.18 |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package utils | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
) | ||
|
||
// / If ECP Logging is enabled return true | ||
// / Otherwise return false | ||
func EnableECPLogging() bool { | ||
if os.Getenv("ENABLE_ENTERPRISE_CERTIFICATE_LOGS") != "" { | ||
return true | ||
} | ||
|
||
log.SetOutput(ioutil.Discard) | ||
return false | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package utils_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"os" | ||
|
||
"github.com/googleapis/enterprise-certificate-proxy/utils" | ||
) | ||
|
||
func TestEnabledLogging(t *testing.T) { | ||
os.Setenv("ENABLE_ENTERPRISE_CERTIFICATE_LOGS", "1") | ||
|
||
if !utils.EnableECPLogging() { | ||
t.Error("ECP Logging should be enabled if ENABLE_ENTERPRISE_CERTIFICATE_LOGS is set.") | ||
} | ||
} | ||
|
||
func TestDisabledLogging(t *testing.T) { | ||
os.Unsetenv("ENABLE_ENTERPRISE_CERTIFICATE_LOGS") | ||
|
||
if utils.EnableECPLogging() { | ||
t.Error("ECP Logging should be enabled if ENABLE_ENTERPRISE_CERTIFICATE_LOGS is set.") | ||
} | ||
} |