Skip to content

Commit

Permalink
Handle git credential lookup for undefined repo value (#634)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Sundberg <[email protected]>
  • Loading branch information
seansund authored Jul 14, 2023
1 parent 1bd88e9 commit 6923904
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion src/util/gitops-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class GitopsUtil {

lookupGitCredential(credentials: GitOpsCredentials, repo: string): GitOpsCredential {
const filteredCredentials: GitOpsCredential[] = credentials
.filter(c => c.repo === repo || c.url === repo || c.repo === '*')
.filter(c => !repo || c.repo === repo || c.url === repo || c.repo === '*')
.sort((a: GitOpsCredential, b: GitOpsCredential) => {
return a.repo === '*' ? 1 : (b.repo === '*' ? -1 : a.repo.localeCompare(b.repo));
});
Expand Down
2 changes: 0 additions & 2 deletions src/util/string-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ export async function parseString<T = any>(contents: string): Promise<T> {
const firstChar = contents.charAt(0)

if (firstChar === '{' || firstChar === '[') {
console.log('Parsing as json', {contents})
return parsers.json(contents)
} else {
console.log('Parsing as yaml', {contents})
return parsers.yaml(contents)
}
}

0 comments on commit 6923904

Please sign in to comment.