mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 22:06:38 +08:00
63cd906cfc
- Merge all files inside openflare-server to the repository root directory. - Relocate agent, relay, and flared subprojects from internal/ to internal/apps/. - Combine docker-compose files and update build context paths to root. - Update GitHub workflows and Dockerfiles to refer to new directories and package names. - Rewrite Go package imports across all files. - Resolve database renew test race condition and clean up docs.
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package config_version
|
|
|
|
import (
|
|
openrestyrender "github.com/Rain-kl/Wavelet/pkg/render/openresty"
|
|
)
|
|
|
|
// SupportFile is a rendered configuration support artifact.
|
|
type SupportFile struct {
|
|
Path string `json:"path"`
|
|
Content string `json:"content"`
|
|
}
|
|
|
|
func renderSnapshotConfig(sourceJSON string, certificateFiles []SupportFile) (*openrestyrender.Result, error) {
|
|
return openrestyrender.RenderJSON(sourceJSON, toOpenRestySupportFiles(certificateFiles))
|
|
}
|
|
|
|
func toOpenRestySupportFiles(files []SupportFile) []openrestyrender.SupportFile {
|
|
if len(files) == 0 {
|
|
return nil
|
|
}
|
|
result := make([]openrestyrender.SupportFile, 0, len(files))
|
|
for _, file := range files {
|
|
result = append(result, openrestyrender.SupportFile{
|
|
Path: file.Path,
|
|
Content: file.Content,
|
|
})
|
|
}
|
|
return result
|
|
}
|
|
|
|
func fromOpenRestySupportFiles(files []openrestyrender.SupportFile) []SupportFile {
|
|
if len(files) == 0 {
|
|
return nil
|
|
}
|
|
result := make([]SupportFile, 0, len(files))
|
|
for _, file := range files {
|
|
result = append(result, SupportFile{
|
|
Path: file.Path,
|
|
Content: file.Content,
|
|
})
|
|
}
|
|
return result
|
|
}
|
|
|
|
func renderPlaceholderConfig(snapshotJSON string) (mainConfig, routeConfig, checksum string) {
|
|
mainConfig = `{"placeholder":"main_config"}`
|
|
routeConfig = snapshotJSON
|
|
checksum = openrestyrender.ChecksumBundle(mainConfig, routeConfig, nil)
|
|
return mainConfig, routeConfig, checksum
|
|
}
|