Add Markdown HTML publication
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"gitea.maximumdirect.net/eric/distributor/internal/config"
|
||||
"gitea.maximumdirect.net/eric/distributor/internal/state"
|
||||
"gitea.maximumdirect.net/eric/distributor/internal/storage"
|
||||
"gitea.maximumdirect.net/eric/distributor/internal/transform"
|
||||
markdowntransform "gitea.maximumdirect.net/eric/distributor/internal/transform/markdown"
|
||||
)
|
||||
|
||||
type Action string
|
||||
@@ -29,6 +31,7 @@ type Request struct {
|
||||
DestinationBackend storage.Backend
|
||||
DestinationBundlePath string
|
||||
Publish config.PublishPolicy
|
||||
Transform config.Transform
|
||||
Transfer config.TransferPolicy
|
||||
DistributorVersion string
|
||||
}
|
||||
@@ -48,6 +51,9 @@ type Plan struct {
|
||||
type Output struct {
|
||||
SourcePath string
|
||||
DestinationPath string
|
||||
Kind string
|
||||
Transform string
|
||||
Data []byte
|
||||
SHA256 string
|
||||
Size int64
|
||||
}
|
||||
@@ -56,7 +62,7 @@ func Build(ctx context.Context, req Request) (Plan, error) {
|
||||
if err := validateRequest(req); err != nil {
|
||||
return Plan{}, err
|
||||
}
|
||||
outputs, err := PlanSourceOutputs(req)
|
||||
outputs, err := PlanOutputs(ctx, req)
|
||||
if err != nil {
|
||||
return Plan{}, err
|
||||
}
|
||||
@@ -96,15 +102,21 @@ func validateRequest(req Request) error {
|
||||
if req.DestinationBackend == nil {
|
||||
return fmt.Errorf("destination backend is required")
|
||||
}
|
||||
if req.Publish.HTML {
|
||||
return fmt.Errorf("publish html is not implemented")
|
||||
if !req.Publish.Source && !req.Publish.HTML {
|
||||
return fmt.Errorf("publish source or html must be enabled")
|
||||
}
|
||||
if !req.Publish.Source {
|
||||
return fmt.Errorf("publish source must be enabled")
|
||||
if req.Publish.HTML {
|
||||
if req.Transform.MarkdownToHTML == nil || !req.Transform.MarkdownToHTML.Enabled || req.Transform.MarkdownToHTML.Mode != config.TransformModeSidecar {
|
||||
return fmt.Errorf("publish html requires markdown_to_html transform enabled with sidecar mode")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func markdownTransformer() transform.Transformer {
|
||||
return markdowntransform.New()
|
||||
}
|
||||
|
||||
func actionForComparison(comparison state.Comparison, transfer config.TransferPolicy) (Action, string) {
|
||||
switch comparison.Outcome {
|
||||
case state.OutcomeDestinationAbsent:
|
||||
|
||||
Reference in New Issue
Block a user