Skip to content

Commit 7ace254

Browse files
Get last usns from a filepath (#1029)
* feat: getting last usns from a filepath * Fix typo --------- Co-authored-by: Nicolas Bender <nicolas.bender@sap.com>
1 parent 376cde1 commit 7ace254

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

actions/stack/get-usns/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ inputs:
1717
description: 'JSON array of last known USNs'
1818
required: false
1919
default: '[]'
20+
last_usns_filepath:
21+
description: 'Similar to last_usns, but instead of pointing into a variable, it points to a file'
22+
required: false
2023
packages:
2124
description: 'JSON array of stack package names'
2225
required: false
@@ -39,6 +42,8 @@ runs:
3942
- "${{ inputs.feed_url }}"
4043
- "--last-usns"
4144
- "${{ inputs.last_usns }}"
45+
- "--last-usns-filepath"
46+
- "${{ inputs.last_usns_filepath }}"
4247
- "--packages"
4348
- "${{ inputs.packages }}"
4449
- "--packages-filepath"

actions/stack/get-usns/entrypoint/main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func main() {
4848
var config struct {
4949
Distro string
5050
LastUSNsJSON string
51+
LastUSNsJSONFilepath string
5152
Output string
5253
PackagesJSON string
5354
PackagesJSONFilepath string
@@ -59,6 +60,10 @@ func main() {
5960
"last-usns",
6061
"",
6162
"JSON array of last known USNs")
63+
flag.StringVar(&config.LastUSNsJSONFilepath,
64+
"last-usns-filepath",
65+
"",
66+
"Filepath that points to the JSON array of last known USNs")
6267
flag.StringVar(&config.RSSURL,
6368
"feed-url",
6469
"https://ubuntu.com/security/notices/rss.xml",
@@ -108,6 +113,19 @@ func main() {
108113
log.Fatal(err)
109114
}
110115

116+
if config.LastUSNsJSONFilepath != "" {
117+
118+
lastUSNsFilepath, err := os.ReadFile(config.LastUSNsJSONFilepath)
119+
if err != nil {
120+
log.Fatal(err)
121+
}
122+
123+
err = json.Unmarshal(lastUSNsFilepath, &lastUSNs)
124+
if err != nil {
125+
log.Fatal(err)
126+
}
127+
}
128+
111129
var packages []string
112130
err = json.Unmarshal([]byte(config.PackagesJSON), &packages)
113131
if err != nil {

0 commit comments

Comments
 (0)