remove duplicate tempdir pkg
This commit is contained in:
parent
88fe584fe1
commit
d815419c7b
@ -12,7 +12,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"fmt"
|
||||
"decl/tests/tempdir"
|
||||
"decl/internal/tempdir"
|
||||
"archive/tar"
|
||||
"io"
|
||||
"log"
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"testing"
|
||||
"decl/tests/tempdir"
|
||||
"decl/internal/tempdir"
|
||||
"decl/internal/folio"
|
||||
"errors"
|
||||
)
|
||||
|
@ -153,9 +153,14 @@ func (d *Declaration) Resource() data.Resource {
|
||||
func (d *Declaration) Apply(stateTransition string) (result error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
slog.Info("Declaration.Apply()", "error", r, "stacktrace", string(debug.Stack()))
|
||||
slog.Debug("Declaration.Apply()", "stacktrace", string(debug.Stack()))
|
||||
slog.Info("Declaration.Apply()", "error", r, "resourceerror", d.Error)
|
||||
if d.Error != "" {
|
||||
result = fmt.Errorf("%s - %s", r, d.Error)
|
||||
} else {
|
||||
result = fmt.Errorf("%s", r)
|
||||
}
|
||||
}
|
||||
if result != nil {
|
||||
d.Error = result.Error()
|
||||
}
|
||||
@ -192,12 +197,13 @@ func (d *Declaration) Apply(stateTransition string) (result error) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
result = stater.Trigger("read")
|
||||
currentState := stater.CurrentState()
|
||||
switch currentState {
|
||||
case "create", "present":
|
||||
default:
|
||||
return fmt.Errorf("Failed to create resource: %s - state: %s, err: %s", d.URI(), currentState, result)
|
||||
return fmt.Errorf("Failed to create resource: %s - state: %s, err: %s", d.URI(), currentState, d.Error)
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
"io"
|
||||
"io/fs"
|
||||
_ "os"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"github.com/sters/yaml-diff/yamldiff"
|
||||
@ -275,9 +276,11 @@ func (d *Document) Apply(state string) error {
|
||||
|
||||
if d.ResourceDeclarations[idx].Requires.Check() {
|
||||
|
||||
if e := d.ResourceDeclarations[idx].Apply(state); e != nil {
|
||||
slog.Error("Document.Apply() error applying resource", "index", idx, "uri", d.ResourceDeclarations[idx].Resource().URI())
|
||||
// fmt.Fprintf(os.Stderr, "%s: ", d.ResourceDeclarations[idx].Resource().URI())
|
||||
|
||||
if e := d.ResourceDeclarations[idx].Apply(state); e != nil {
|
||||
// slog.Error("Document.Apply() error applying resource", "index", idx, "uri", d.ResourceDeclarations[idx].Resource().URI(), "error", e)
|
||||
// fmt.Fprintf(os.Stderr, "%s\n", "error")
|
||||
d.ResourceDeclarations[idx].Error = e.Error()
|
||||
switch d.ResourceDeclarations[idx].OnError.GetStrategy() {
|
||||
case OnErrorStop:
|
||||
@ -285,6 +288,8 @@ func (d *Document) Apply(state string) error {
|
||||
case OnErrorFail:
|
||||
d.failedResources++
|
||||
}
|
||||
} else {
|
||||
// fmt.Fprintf(os.Stderr, "%s\n", state)
|
||||
}
|
||||
} else {
|
||||
d.ResourceDeclarations[idx].Error = fmt.Sprintf("Constraint failure: %s", d.ResourceDeclarations[idx].Requires)
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
"os"
|
||||
"log/slog"
|
||||
"decl/tests/tempdir"
|
||||
"decl/internal/tempdir"
|
||||
_ "path/filepath"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user