@@ -14,18 +14,19 @@ import (
1414)
1515
1616const (
17- username = "username"
18- password = "password"
19- token = "token"
20- identity = "identity"
21- knownHosts = "known_hosts"
17+ Username = "username"
18+ Password = "password"
19+ Token = "token"
20+ Identity = "identity"
21+ KnownHosts = "known_hosts"
2222)
2323
2424// CreateGitCredentialsSecret creates or updates a Secret with name "git" in the fluxcd namespace.
25- // The secret contains git credentials for flux sync, read from the file d.gitCredentials .
25+ // The secret contains git credentials for the flux sync, read from the file gitCredentialsPath .
2626// The file should contain a YAML of a map[string]string, whose keys are described
2727// in https://fluxcd.io/flux/components/source/gitrepositories/#secret-reference, e.g. username and password.
28- func CreateGitCredentialsSecret (ctx context.Context , log * logrus.Logger , gitCredentialsPath string , secretName , secretNamespace string , platformClient client.Client ) error {
28+ func CreateGitCredentialsSecret (ctx context.Context , log * logrus.Logger , gitCredentialsPath , secretName , secretNamespace string , platformClient client.Client ) error {
29+
2930 log .Infof ("Creating/updating git credentials secret %s/%s" , secretNamespace , secretName )
3031
3132 gitCredentialsData := map [string ][]byte {}
@@ -44,12 +45,12 @@ func CreateGitCredentialsSecret(ctx context.Context, log *logrus.Logger, gitCred
4445
4546 if config .Authentication .BasicAuth != nil {
4647 log .Debug ("Using basic auth credentials for git operations" )
47- gitCredentialsData [username ] = []byte (config .Authentication .BasicAuth .Username )
48- gitCredentialsData [password ] = []byte (config .Authentication .BasicAuth .Password )
48+ gitCredentialsData [Username ] = []byte (config .Authentication .BasicAuth .Username )
49+ gitCredentialsData [Password ] = []byte (config .Authentication .BasicAuth .Password )
4950 }
5051 if config .Authentication .BearerToken != nil {
5152 log .Debug ("Using bearer token for git operations" )
52- gitCredentialsData [token ] = []byte (config .Authentication .BearerToken .Token )
53+ gitCredentialsData [Token ] = []byte (config .Authentication .BearerToken .Token )
5354 }
5455 if config .Authentication .SSHPrivateKey != nil {
5556 log .Debug ("Using ssh private key for git operations" )
@@ -58,7 +59,7 @@ func CreateGitCredentialsSecret(ctx context.Context, log *logrus.Logger, gitCred
5859 return err
5960 }
6061
61- gitCredentialsData [identity ] = privateKey
62+ gitCredentialsData [Identity ] = privateKey
6263
6364 if config .Authentication .SSHPrivateKey .KnownHosts != "" {
6465 knownHostsPath := config .Authentication .SSHPrivateKey .KnownHosts
@@ -69,7 +70,7 @@ func CreateGitCredentialsSecret(ctx context.Context, log *logrus.Logger, gitCred
6970 if err != nil {
7071 return fmt .Errorf ("error reading known hosts file %s: %w" , knownHostsPath , err )
7172 }
72- gitCredentialsData [knownHosts ] = knownHostsContent
73+ gitCredentialsData [KnownHosts ] = knownHostsContent
7374 }
7475 }
7576 }
0 commit comments