Files
OpenFlare/internal/apps/openflare/config_version/renderer.go
T
ryan 63cd906cfc refactor(repo): consolidate openflare-server to root and move subprojects to internal/apps
- 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.
2026-06-19 14:23:29 +08:00

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
}