Skip to content

Commit

Permalink
skip comments when parsing the config file
Browse files Browse the repository at this point in the history
Signed-off-by: Hal Rosenberg <[email protected]>
  • Loading branch information
hrosenbe committed Jul 10, 2020
1 parent d6ec048 commit 4b90f59
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions runWeathervane.pl
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,21 @@ sub parseConfigFile {
my %topLevelStorageClassNames;
# Parsing the config file manually to avoid requiring the JSON package
while (<$configFile>) {
if ($_ =~ /^\s*"kubernetesClusters"\s*\:\s*\[/) {
if ($_ =~ /^\s*#/) {
next;
} elsif ($_ =~ /^\s*"kubernetesClusters"\s*\:\s*\[/) {
# Fill out a hash with clustername -> [kubeconfig, context])
while (<$configFile>) {
if ($_ =~ /^\s*{/) {
if ($_ =~ /^\s*#/) {
next;
} elsif ($_ =~ /^\s*{/) {
my $name = "";
my $kubeconfigFileName = "~/.kube/config";
my $kubeconfigContext = "";
while (<$configFile>) {
if ($_ =~ /^\s*"kubeconfigFile"\s*\:\s*"(.*)"\s*,/) {
if ($_ =~ /^\s*#/) {
next;
} elsif ($_ =~ /^\s*"kubeconfigFile"\s*\:\s*"(.*)"\s*,/) {
$kubeconfigFileName = $1;
if ((! -e $kubeconfigFileName) || (! -f $kubeconfigFileName)) {
print "The kubeconfigFile $kubeconfigFileName must exist and be a regular file.\n";
Expand All @@ -147,7 +153,9 @@ sub parseConfigFile {
# Don't parse inside workloads
my $numOpenBrackets = 1;
while (<$configFile>) {
if ($_ =~ /\[/) {
if ($_ =~ /^\s*#/) {
next;
} elsif ($_ =~ /\[/) {
$numOpenBrackets++;
} elsif ($_ =~ /\]/) {
$numOpenBrackets--;
Expand All @@ -160,7 +168,9 @@ sub parseConfigFile {
# Don't parse inside appInstances
my $numOpenBrackets = 1;
while (<$configFile>) {
if ($_ =~ /\[/) {
if ($_ =~ /^\s*#/) {
next;
} elsif ($_ =~ /\[/) {
$numOpenBrackets++;
} elsif ($_ =~ /\]/) {
$numOpenBrackets--;
Expand Down

0 comments on commit 4b90f59

Please sign in to comment.