From 8dbbd62c1074d9e52245115ff3df830dede94d93 Mon Sep 17 00:00:00 2001 From: Jan Kubalek Date: Thu, 4 Apr 2024 22:30:25 +0200 Subject: [PATCH 1/3] Fix lsb_release test data --- tools/lsb_release/test_data/lsb_release_ubuntu1804.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tools/lsb_release/test_data/lsb_release_ubuntu1804.txt diff --git a/tools/lsb_release/test_data/lsb_release_ubuntu1804.txt b/tools/lsb_release/test_data/lsb_release_ubuntu1804.txt new file mode 100644 index 0000000..3e6268d --- /dev/null +++ b/tools/lsb_release/test_data/lsb_release_ubuntu1804.txt @@ -0,0 +1,4 @@ +Distributor ID: Ubuntu +Description: Ubuntu GNU/Linux 18.04 (Bionic Beaver) +Release: 18.04 +Codename: Bionic Beaver \ No newline at end of file From 028ebdd5e09ec21b1bf4dcdc7734ff5d092765d4 Mon Sep 17 00:00:00 2001 From: Jan Kubalek Date: Thu, 4 Apr 2024 22:38:50 +0200 Subject: [PATCH 2/3] Fix lsb_release error reporting --- tools/lsb_release/main.go | 12 ++++++------ tools/lsb_release/test_data/lsb_release_1804.txt | 4 ---- 2 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 tools/lsb_release/test_data/lsb_release_1804.txt diff --git a/tools/lsb_release/main.go b/tools/lsb_release/main.go index 1f27178..b6099ec 100644 --- a/tools/lsb_release/main.go +++ b/tools/lsb_release/main.go @@ -85,28 +85,28 @@ func (data *DataStruct) ReadFromFile(filePath string, validate bool) { scanner := bufio.NewScanner(file) keys := reflect.ValueOf(parseStruct).MapKeys() + handled := 0 for scanner.Scan() { line := scanner.Text() - handled := false for _, key := range keys { keyString := key.String() data := parseLine(line, keyString) if data != "" { parseStruct[keyString](data) - handled = true + handled++ break } } - if validate && !handled { - log.Fatalf("Cannot parse line '%s'", line) - } + } + if validate && len(keys) != handled { + log.Panicf("Not all needed values were extracted!") } } func parseLine(line string, regexpStr string) string { regex, err := regexp.Compile(regexpStr) if err != nil { - log.Fatalf("Cannot compile regex '%s'", regexpStr) + log.Panicf("Cannot compile regex '%s'", regexpStr) } subMatch := regex.FindStringSubmatch(line) if subMatch == nil { diff --git a/tools/lsb_release/test_data/lsb_release_1804.txt b/tools/lsb_release/test_data/lsb_release_1804.txt deleted file mode 100644 index 3e6268d..0000000 --- a/tools/lsb_release/test_data/lsb_release_1804.txt +++ /dev/null @@ -1,4 +0,0 @@ -Distributor ID: Ubuntu -Description: Ubuntu GNU/Linux 18.04 (Bionic Beaver) -Release: 18.04 -Codename: Bionic Beaver \ No newline at end of file From 99481ff135ce330f42aa7ff626d246dfae05ca15 Mon Sep 17 00:00:00 2001 From: Jan Kubalek Date: Thu, 4 Apr 2024 22:39:28 +0200 Subject: [PATCH 3/3] Version pushed to v0.3.2 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 320f703..a5d34d7 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -version=0.3.1 \ No newline at end of file +version=0.3.2 \ No newline at end of file