54 lines
1.0 KiB
Go
54 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"code.gitea.io/sdk/gitea"
|
|
"fmt"
|
|
"git.nevets.tech/Steven/ezconf"
|
|
"github.com/google/go-github/v55/github"
|
|
"os"
|
|
)
|
|
|
|
type Domain struct {
|
|
name *string
|
|
config *ezconf.Configuration
|
|
description *string
|
|
ghClient *github.Client
|
|
gtClient *gitea.Client
|
|
}
|
|
|
|
func createFile(fileName string, data []byte) {
|
|
fileInfo, err := os.Stat(fileName)
|
|
if err != nil {
|
|
if os.IsNotExist(err) {
|
|
file, err := os.Create(fileName)
|
|
if err != nil {
|
|
fmt.Println("Error creating configuration file:", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
_, err = file.Write(data)
|
|
if err != nil {
|
|
fmt.Println("Error writing to file;", err)
|
|
os.Exit(1)
|
|
}
|
|
} else {
|
|
fmt.Println("Error opening configuration file:", err)
|
|
os.Exit(1)
|
|
}
|
|
} else {
|
|
if fileInfo.Size() == 0 {
|
|
file, err := os.Create(fileName)
|
|
if err != nil {
|
|
fmt.Println("Error creating configuration file:", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
_, err = file.Write(data)
|
|
if err != nil {
|
|
fmt.Println("Error writing to file:", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
}
|
|
}
|