Files
zeekay 4e3a8ef9ca merge: upstream/main (preserve Hanzo brand, 50 commits)
# Conflicts:
#	api/v1alpha1/casting.go
#	api/v1alpha1/installation/signoz.go
#	docs/casting.md
#	docs/examples/docker/compose/pours/deployment/configs/ingester/opamp.yaml
#	docs/examples/systemd/binary/pours/deployment/signoz-ingester.service
#	docs/examples/systemd/binary/pours/deployment/signoz-signoz.service
#	docs/examples/systemd/binary/pours/deployment/signoz-telemetrystore-migrator.service
#	docs/schemas/v1alpha1.yaml
#	internal/foundry/registry.go
#	internal/instrumentation/handler.go
#	internal/molding/signozmolding/signoz.go
2026-06-02 09:59:25 -07:00

51 lines
1.5 KiB
Go

package main
import (
"context"
"log/slog"
"os"
"path/filepath"
foundryerrors "github.com/hanzoai/o11y-foundry/internal/errors"
"github.com/hanzoai/o11y-foundry/internal/foundry"
"github.com/hanzoai/o11y-foundry/internal/instrumentation"
"github.com/hanzoai/o11y-foundry/internal/writer"
"github.com/spf13/cobra"
)
func registerForgeCmd(rootCmd *cobra.Command) {
forgeCmd := &cobra.Command{
Use: "forge",
Short: "Forge Configuration and Deployment Files",
Long: "Generate deployment configuration files from casting.yaml",
RunE: recoverRunE(domain.EventForge, func(cmd *cobra.Command, args []string) (domain.Properties, error) {
return runForge(cmd.Context(), rootLogger, commonCfg.File, poursCfg.Path)
}),
}
rootCmd.AddCommand(forgeCmd)
}
func runForge(ctx context.Context, logger *slog.Logger, path string, poursPath string) (domain.Properties, error) {
foundry, err := foundry.New(logger)
if err != nil {
logger.ErrorContext(ctx, "failed to create foundry, please report this issues to developers at https://github.com/hanzoai/o11y-foundry/issues", foundryerrors.LogAttr(err))
return err
}
machinery, err := foundry.Config.GetV1Alpha1(ctx, path)
if err != nil {
return domain.NewProperties(), err
}
props := machinery.TrackableProperties()
poursAbsPath, err := filepath.Abs(poursPath)
if err != nil {
return props, err
}
err = foundry.Forge(ctx, machinery, path, &writer.Options{Output: &os.File{}, TargetDirectory: poursAbsPath})
return props, err
}