Skip to content

Commit

Permalink
#1 Add blueprint v1 parsing from cesapp v7
Browse files Browse the repository at this point in the history
  • Loading branch information
ppxl committed Jan 27, 2025
1 parent 237d438 commit b325f7a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions json/blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/pkg/errors"
)

// BlueprintApi is a string that contains a Blueprint API version identifier.
Expand Down Expand Up @@ -138,3 +139,14 @@ type TargetPackage struct {
// TargetState defines a state of installation of this package. Optional field, but defaults to "TargetStatePresent"
TargetState TargetState `json:"targetState"`
}

// ParseBlueprint parses a given byte slice to a GeneralBlueprint so the blueprint version can be determined.
func ParseBlueprint(rawBlueprint []byte) (GeneralBlueprint, error) {
var preparsedBlueprint GeneralBlueprint
err := json.Unmarshal(rawBlueprint, &preparsedBlueprint)
if err != nil {
return GeneralBlueprint{}, errors.Wrap(err, "could not parse blueprint. Please check the blueprint for validity")
}

return preparsedBlueprint, nil
}

0 comments on commit b325f7a

Please sign in to comment.