All checks were successful
continuous-integration/drone/push Build is passing
Analogous to internal/provider, extract the service registry (Svc, RegisterService, FindService, ListServices, OrderedServices, FindSubService, RegisterSubServices) and the zone analyzer (ServiceAnalyzer, Analyzer, AnalyzeZone) from services/ into a new internal/service package.
76 lines
2.2 KiB
Go
76 lines
2.2 KiB
Go
// This file is part of the happyDomain (R) project.
|
|
// Copyright (c) 2020-2026 happyDomain
|
|
// Authors: Pierre-Olivier Mercier, et al.
|
|
//
|
|
// This program is offered under a commercial and under the AGPL license.
|
|
// For commercial licensing, contact us at <contact@happydomain.org>.
|
|
//
|
|
// For AGPL licensing:
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
//go:build ignore
|
|
// +build ignore
|
|
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
intsvc "git.happydns.org/happyDomain/internal/service"
|
|
"git.happydns.org/happyDomain/model"
|
|
_ "git.happydns.org/happyDomain/services"
|
|
_ "git.happydns.org/happyDomain/services/abstract"
|
|
_ "git.happydns.org/happyDomain/services/providers/google"
|
|
)
|
|
|
|
func main() {
|
|
output := flag.String("o", "", "output file path")
|
|
flag.Parse()
|
|
|
|
if *output == "" {
|
|
fmt.Fprintf(os.Stderr, "Error: output file path is required\n")
|
|
fmt.Fprintf(os.Stderr, "Usage: %s -o <output-file>\n", os.Args[0])
|
|
os.Exit(1)
|
|
}
|
|
|
|
fd, err := os.Create(*output)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer fd.Close()
|
|
|
|
// Collect ServiceSpecs
|
|
services := intsvc.ListServices()
|
|
|
|
sspecs := map[string]happydns.ServiceInfos{}
|
|
for k, service := range *services {
|
|
sspecs[k] = service.Infos
|
|
}
|
|
|
|
genspecs, err := json.MarshalIndent(sspecs, "", " ")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
fmt.Fprint(fd, "// This file is generated by go generate\n\n")
|
|
|
|
fmt.Fprintln(fd, `import type { ServiceInfos } from "$lib/model/service_specs.svelte";`)
|
|
|
|
fmt.Fprintf(fd, "export const servicesSpecs: Record<string, ServiceInfos> = %s\n", string(genspecs))
|
|
|
|
fmt.Printf("Generated %s with %d Services specifications\n", *output, len(sspecs))
|
|
}
|