Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some optimizations for cert.go #9404

Merged
merged 1 commit into from May 17, 2022
Merged

Conversation

ls0f
Copy link
Contributor

@ls0f ls0f commented May 13, 2022

No description provided.

Signed-off-by: ls0f <lovedboy.tk@qq.com>
@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #9404 (34a9c4a) into master (f75e881) will decrease coverage by 0.42%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #9404      +/-   ##
==========================================
- Coverage   46.19%   45.76%   -0.43%     
==========================================
  Files         218      220       +2     
  Lines       25917    26164     +247     
==========================================
+ Hits        11972    11975       +3     
- Misses      12290    12531     +241     
- Partials     1655     1658       +3     
Impacted Files Coverage Δ
util/cert/cert.go 81.81% <100.00%> (-0.59%) ⬇️
...is/applicationset/v1alpha1/applicationset_types.go 27.58% <0.00%> (-7.11%) ⬇️
applicationset/services/scm_provider/gitlab.go 74.19% <0.00%> (-2.16%) ⬇️
applicationset/services/scm_provider/github.go 81.17% <0.00%> (ø)
pkg/apiclient/grpcproxy.go 0.00% <0.00%> (ø)
pkg/apiclient/apiclient.go 0.68% <0.00%> (ø)
server/application/logs.go 85.71% <0.00%> (+4.58%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f75e881...34a9c4a. Read the comment docs.

@ishitasequeira
Copy link
Member

@ls0f Can we add some description to the PR for the need of the change?

@@ -100,11 +99,10 @@ func GetTLSCertificateDataPath() string {
// filesystem. If ARGOCD_SSH_DATA_PATH environment is set, path is taken from
// there, otherwise the default will be returned.
func GetSSHKnownHostsDataPath() string {
envPath := os.Getenv(common.EnvVarSSHDataPath)
if envPath != "" {
return envPath + "/" + common.DefaultSSHKnownHostsName
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use filepath.Join to get the final dst path

@@ -332,7 +327,7 @@ func GetCertificateForConnect(serverName string) ([]string, error) {
// mount. This function makes sure that the path returned actually contain
// at least one valid certificate, and no invalid data.
func GetCertBundlePathForRepository(serverName string) (string, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use filepath.Join to get the final dst path too.

@@ -302,9 +300,6 @@ func ServerNameWithoutPort(serverName string) string {
// consider it an error and just return empty data.
func GetCertificateForConnect(serverName string) ([]string, error) {
dataPath := GetTLSCertificateDataPath()
if !strings.HasSuffix(dataPath, "/") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since use file path to combine dir, it's unnecessary

Copy link
Member

@ishitasequeira ishitasequeira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ls0f
Copy link
Contributor Author

ls0f commented May 17, 2022

@ls0f Can we add some description to the PR for the need of the change?

i will update

@@ -88,8 +88,7 @@ func IsValidHostname(hostname string, fqdn bool) bool {
// filesystem. If ARGOCD_TLS_DATA_PATH environment is set, path is taken from
// there, otherwise the default will be returned.
func GetTLSCertificateDataPath() string {
envPath := os.Getenv(common.EnvVarTLSDataPath)
if envPath != "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more clean code i think

@ls0f ls0f requested a review from ishitasequeira May 17, 2022 01:22
Copy link
Collaborator

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@crenshaw-dev crenshaw-dev merged commit 4b4fd88 into argoproj:master May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants