Skip to content

Commit

Permalink
fix #194 - double encoding (#195)
Browse files Browse the repository at this point in the history
* fix #194

Signed-off-by: 6za <53096417+6za@users.noreply.github.com>

* remove tls sanitize code since we fix secrets on saving

Signed-off-by: Thiago Pagotto <pagottoo@gmail.com>

* Fix encoding on values

Signed-off-by: 6za <53096417+6za@users.noreply.github.com>

Co-authored-by: Thiago Pagotto <pagottoo@gmail.com>
  • Loading branch information
6za and pagottoo committed Aug 5, 2022
1 parent bc347d4 commit 211e25c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
13 changes: 6 additions & 7 deletions internal/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
b64 "encoding/base64"
"encoding/json"
"encoding/pem"
"fmt"
Expand Down Expand Up @@ -395,9 +394,9 @@ func ChangeRegistryToGitLab(dryRun bool) {
FullURL string
}

pat := b64.StdEncoding.EncodeToString([]byte(viper.GetString("gitlab.token")))
url := b64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("https://gitlab.%s/kubefirst/", viper.GetString("aws.hostedzonename"))))
fullurl := b64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("https://gitlab.%s/kubefirst/gitops.git", viper.GetString("aws.hostedzonename"))))
pat := viper.GetString("gitlab.token")
url := fmt.Sprintf("https://gitlab.%s/kubefirst/", viper.GetString("aws.hostedzonename"))
fullurl := fmt.Sprintf("https://gitlab.%s/kubefirst/gitops.git", viper.GetString("aws.hostedzonename"))

creds := ArgocdGitCreds{PersonalAccessToken: pat, URL: url, FullURL: fullurl}

Expand Down Expand Up @@ -425,7 +424,7 @@ func ChangeRegistryToGitLab(dryRun bool) {
Data: map[string][]byte{
"password": []byte(creds.PersonalAccessToken),
"url": []byte(creds.URL),
"username": []byte("cm9vdA=="),
"username": []byte("root"),
},
Type: "Opaque",
}
Expand All @@ -448,8 +447,8 @@ func ChangeRegistryToGitLab(dryRun bool) {
},
},
Data: map[string][]byte{
"project": []byte("ZGVmYXVsdA=="),
"type": []byte("Z2l0"),
"project": []byte("default"),
"type": []byte("git"),
"url": []byte(creds.FullURL),
},
Type: "Opaque",
Expand Down
8 changes: 0 additions & 8 deletions internal/ssl/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,6 @@ func RestoreSSL() error {
delete(metadataMap, "managedFields")
data["metadata"] = metadataMap

dataMap := data["data"].(map[string]interface{})
for k, _ := range dataMap {
if k != "tls.crt" && k != "tls.key" {
log.Printf("Remove undesired keys [%s].", k)
delete(dataMap, k)
}
}
data["data"] = dataMap
dataCleaned, err := yaml2.Marshal(&data)

if err != nil {
Expand Down

0 comments on commit 211e25c

Please sign in to comment.