Skip to content

Commit

Permalink
Revert "Remove unused func in claimhelper (#2306)" (#2309)
Browse files Browse the repository at this point in the history
This reverts commit 05862a9.
  • Loading branch information
sebrandon1 authored Aug 1, 2024
1 parent 05862a9 commit f0faa5d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/claimhelper/claimhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ func UnmarshalConfigurations(configurations []byte, claimConfigurations map[stri
}
}

// UnmarshalClaim unmarshals the claim file
func UnmarshalClaim(claimFile []byte, claimRoot *claim.Root) {
err := j.Unmarshal(claimFile, &claimRoot)
if err != nil {
log.Fatal("error unmarshalling claim file: %v", err)
}
}

// ReadClaimFile writes the output payload to the claim file. In the event of an error, this method fatally fails.
func ReadClaimFile(claimFileName string) (data []byte, err error) {
data, err = os.ReadFile(claimFileName)
Expand All @@ -300,6 +308,24 @@ func ReadClaimFile(claimFileName string) (data []byte, err error) {
return data, nil
}

// GetConfigurationFromClaimFile retrieves configuration details from claim file
func GetConfigurationFromClaimFile(claimFileName string) (env *provider.TestEnvironment, err error) {
data, err := ReadClaimFile(claimFileName)
if err != nil {
log.Error("ReadClaimFile failed with err: %v", err)
return env, err
}
var aRoot claim.Root
fmt.Printf("%s", data)
UnmarshalClaim(data, &aRoot)
configJSON, err := j.Marshal(aRoot.Claim.Configurations)
if err != nil {
return nil, fmt.Errorf("cannot convert config to json")
}
err = j.Unmarshal(configJSON, &env)
return env, err
}

// MarshalClaimOutput is a helper function to serialize a claim as JSON for output. In the event of an error, this
// method fatally fails.
func MarshalClaimOutput(claimRoot *claim.Root) []byte {
Expand Down

0 comments on commit f0faa5d

Please sign in to comment.