package cert import ( "context" "os" "envoy-control-plane/internal/config" internallog "envoy-control-plane/internal/log" ) const defaultFileMode = 0755 // RunCertIssuance handles the conditional logic and argument validation for cert issuance. func RunCertIssuance(ctx context.Context) { log := internallog.LogFromContext(ctx) cfg := config.GetConfig() if !cfg.EnableCertIssuance { return } log.Infof("Certificate issuance enabled. Validating arguments...") if cfg.WebrootPath == "" { log.Errorf("Webroot path is required for certificate issuance") return } // 1. Ensure webroot path exists if _, err := os.Stat(cfg.WebrootPath); os.IsNotExist(err) { log.Warnf("Webroot path '%s' does not exist. Creating it.", cfg.WebrootPath) if err := os.MkdirAll(cfg.WebrootPath, defaultFileMode); err != nil { log.Errorf("Failed to create webroot path: %v", err) } } // NOTE: The commented-out code for starting the HTTP-01 server on :80 should // be placed here if you implement it fully. }