Skip to content

Commit b19dcf2

Browse files
Use different creds than the default ones
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
1 parent 349ba1f commit b19dcf2

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

cmd/garm-cli/cmd/github_credentials.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package cmd
1616

1717
import (
18+
"crypto/x509"
19+
"encoding/pem"
1820
"fmt"
1921
"os"
2022
"strconv"
@@ -258,20 +260,20 @@ func init() {
258260
}
259261

260262
func parsePrivateKeyFromPath(path string) ([]byte, error) {
261-
// if _, err := os.Stat(path); err != nil {
262-
// return nil, fmt.Errorf("private key file not found: %s", credentialsPrivateKeyPath)
263-
// }
263+
if _, err := os.Stat(path); err != nil {
264+
return nil, fmt.Errorf("private key file not found: %s", credentialsPrivateKeyPath)
265+
}
264266
keyContents, err := os.ReadFile(path)
265267
if err != nil {
266268
return nil, fmt.Errorf("failed to read private key file: %w", err)
267269
}
268-
// pemBlock, _ := pem.Decode(keyContents)
269-
// if pemBlock == nil {
270-
// return nil, fmt.Errorf("failed to decode PEM block")
271-
// }
272-
// if _, err := x509.ParsePKCS1PrivateKey(pemBlock.Bytes); err != nil {
273-
// return nil, fmt.Errorf("failed to parse private key: %w", err)
274-
// }
270+
pemBlock, _ := pem.Decode(keyContents)
271+
if pemBlock == nil {
272+
return nil, fmt.Errorf("failed to decode PEM block")
273+
}
274+
if _, err := x509.ParsePKCS1PrivateKey(pemBlock.Bytes); err != nil {
275+
return nil, fmt.Errorf("failed to parse private key: %w", err)
276+
}
275277
return keyContents, nil
276278
}
277279

test/integration/e2e/credentials.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func TestGithubCredentialsFailWhenEndpointDoesntExist() {
170170
slog.Info("Testing error when endpoint doesn't exist")
171171
createCredsParams := params.CreateGithubCredentialsParams{
172172
Name: dummyCredentialsName,
173-
Endpoint: defaultEndpointName,
173+
Endpoint: "iDontExist.example.com",
174174
Description: "GARM test credentials",
175175
AuthType: params.GithubAuthTypePAT,
176176
PAT: params.GithubPAT{

0 commit comments

Comments
 (0)