Переглянути джерело

feat(integrations): add the UniFi controller vendor (#1695)

Nacho 1 місяць тому
батько
коміт
39d8e3ef86

+ 10 - 0
server-go/internal/rintegration/vendors.go

@@ -49,6 +49,16 @@ var vendors = []Vendor{
 		Binary:      "asuswrt-pusher",
 		Description: "Asuswrt (Asuswrt-Merlin) external pusher",
 	},
+	{
+		ID:          "unifi",
+		Mode:        "local",
+		Repo:        "gnacho/netpulse-integrations",
+		TagPrefix:   "unifi/v",
+		AssetTmpl:   "unifi_{version}_linux_{arch}.tar.gz",
+		Arches:      []string{"amd64"},
+		Binary:      "unifi-pusher",
+		Description: "UniFi controller external pusher",
+	},
 }
 
 // Vendors returns the supported vendor manifest.

+ 16 - 2
server-go/internal/rintegration/vendors_test.go

@@ -4,8 +4,8 @@ import "testing"
 
 func TestVendorsManifest(t *testing.T) {
 	vs := Vendors()
-	if len(vs) != 2 {
-		t.Fatalf("expected 2 vendors, got %d", len(vs))
+	if len(vs) != 3 {
+		t.Fatalf("expected 3 vendors, got %d", len(vs))
 	}
 
 	r, ok := LookupVendor("routeros")
@@ -36,6 +36,20 @@ func TestVendorsManifest(t *testing.T) {
 		t.Fatalf("asuswrt asset name = %q", got)
 	}
 
+	u, ok := LookupVendor("unifi")
+	if !ok {
+		t.Fatal("unifi vendor missing")
+	}
+	if u.Mode != "local" || u.TagPrefix != "unifi/v" || u.Binary != "unifi-pusher" {
+		t.Fatalf("unifi manifest mismatch: %+v", u)
+	}
+	if len(u.Arches) != 1 || u.Arches[0] != "amd64" {
+		t.Fatalf("unifi arches = %v, want [amd64]", u.Arches)
+	}
+	if got := u.AssetName("1.0.0", "amd64"); got != "unifi_1.0.0_linux_amd64.tar.gz" {
+		t.Fatalf("unifi asset name = %q", got)
+	}
+
 	if _, ok := LookupVendor("bbox"); ok {
 		t.Fatal("bbox must not be present")
 	}