aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-03-03 11:10:29 +1300
committerArslaan Pathan <[email protected]>2026-03-03 11:10:29 +1300
commit50e6213fed138fff57e4d206caa109a9f8fc1961 (patch)
treedddf61320d67731787ec1f3a8c3187de5ac23489 /internal
parenta2138c2aeb636f408d866e046e7b00c011192942 (diff)
downloadkiiro-50e6213fed138fff57e4d206caa109a9f8fc1961.tar.xz
kiiro-50e6213fed138fff57e4d206caa109a9f8fc1961.zip
Rename repos to sources for less confusion + add FetchPackageListing
Diffstat (limited to 'internal')
-rw-r--r--internal/repo/repo.go10
-rw-r--r--internal/sources/sources.go46
2 files changed, 46 insertions, 10 deletions
diff --git a/internal/repo/repo.go b/internal/repo/repo.go
deleted file mode 100644
index 3f12223..0000000
--- a/internal/repo/repo.go
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright (c) 2026 Arslaan Pathan
-// This software is licensed under the ARPL. See LICENSE for details.
-
-package repo
-
-type PackageListing struct {
- Repository string `json:"repo"`
- KiirofileOverride *string `json:"kiirofile_override"`
- KiirotomlOverride *string `json:"kiirotoml_override"`
-}
diff --git a/internal/sources/sources.go b/internal/sources/sources.go
new file mode 100644
index 0000000..3b82c5c
--- /dev/null
+++ b/internal/sources/sources.go
@@ -0,0 +1,46 @@
+// Copyright (c) 2026 Arslaan Pathan
+// This software is licensed under the ARPL. See LICENSE for details.
+
+package sources
+
+import (
+ "fmt"
+ "encoding/json"
+ "net/http"
+)
+
+type PackageListing struct {
+ Repository string `json:"repo"`
+ KiirofileOverride *string `json:"kiirofile_override"`
+ KiirotomlOverride *string `json:"kiirotoml_override"`
+}
+
+func FetchPackageListing(url string) (*PackageListing, error) {
+ fmt.Println("Fetching package listing...")
+
+ resp, err := http.Get(url)
+ if err != nil {
+ log.Fatal(err)
+ return nil, err
+ }
+
+ body, err := io.ReadAll(res.Body)
+ res.Body.Close()
+
+ if res.StatusCode > 299 {
+ log.Fatalf("Response failed with status code: %d", res.StatusCode)
+ return nil, err
+ }
+ if err != nil {
+ log.Fatal(err)
+ return nil, err
+ }
+
+ var packageListing PackageListing
+ err := json.Unmarshal(body, &packageListing)
+ if err != nil {
+ return nil, err
+ }
+ fmt.Println("Fetched package listing!")
+ return &packageListing, nil
+}