forked from vscode-kubernetes-tools/vscode-kubernetes-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding status icons for Helm release status (vscode-kubernetes-tools#318
- Loading branch information
Showing
8 changed files
with
47 additions
and
33 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Parse column based output which is seperated by whitespace(s) from kubectl or similar sources | ||
* for example, kubectl get po | ||
* @param lineOutput raw output with headers from kubectl or similar sources | ||
* @param columnSeparator a regex for the column separators | ||
* @return array of objects with key as column header and value | ||
*/ | ||
export function parseLineOutput(lineOutput: string[], columnSeparator: RegExp): { [key: string]: string }[] { | ||
const headers = lineOutput.shift(); | ||
if (!headers) { | ||
return []; | ||
} | ||
const parsedHeaders = headers.toLowerCase().replace(columnSeparator, '|').split('|'); | ||
return lineOutput.map((line) => { | ||
const lineInfoObject = {}; | ||
const bits = line.replace(columnSeparator, '|').split('|'); | ||
bits.forEach((columnValue, index) => { | ||
lineInfoObject[parsedHeaders[index].trim()] = columnValue.trim(); | ||
}); | ||
return lineInfoObject; | ||
}); | ||
} |