78 lines
1.6 KiB
Go
78 lines
1.6 KiB
Go
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
package data
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"decl/internal/codec"
|
|
"io"
|
|
"decl/internal/mapper"
|
|
"net/url"
|
|
)
|
|
|
|
var (
|
|
ErrEmptyDocument error = errors.New("Document contains no resources")
|
|
)
|
|
|
|
type Serializer interface {
|
|
JSON() ([]byte, error)
|
|
YAML() ([]byte, error)
|
|
PB() ([]byte, error)
|
|
Generate(w io.Writer) (error)
|
|
}
|
|
|
|
type Loader interface {
|
|
LoadString(string, codec.Format) (error)
|
|
Load([]byte, codec.Format) (error)
|
|
LoadReader(io.ReadCloser, codec.Format) (error)
|
|
}
|
|
|
|
type DocumentGetter interface {
|
|
GetDocument() Document
|
|
}
|
|
|
|
type DocumentStateTransformer interface {
|
|
Apply(overrideState string) error
|
|
}
|
|
|
|
type Document interface {
|
|
GetURI() string
|
|
Serializer
|
|
Loader
|
|
Validator
|
|
mapper.Mapper
|
|
|
|
NewResource(uri string) (Resource, error)
|
|
NewResourceFromParsedURI(uri *url.URL) (Resource, error)
|
|
AddDeclaration(Declaration)
|
|
AddResourceDeclaration(resourceType string, resourceDeclaration Resource)
|
|
|
|
Types() (TypesRegistry[Resource])
|
|
// Resources() []Declaration
|
|
|
|
SetConfig(config Document)
|
|
ConfigDoc() Document
|
|
|
|
HasConfig(string) bool
|
|
GetConfig(string) Block
|
|
|
|
Apply(state string) error
|
|
Len() int
|
|
ResolveIds(ctx context.Context)
|
|
Filter(filter DeclarationSelector) []Declaration
|
|
Declarations() []Declaration
|
|
|
|
CheckConstraints() bool
|
|
Failures() int
|
|
|
|
ImportedDocuments() []Document
|
|
|
|
ConfigFilter(filter BlockSelector) []Block
|
|
AppendConfigurations([]Document)
|
|
Diff(with Document, output io.Writer) (returnOutput string, diffErr error)
|
|
DiffState(output io.Writer) (returnOutput string, diffErr error)
|
|
Clone() Document
|
|
AddError(error)
|
|
}
|