MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / LoadJSONBytes

Function LoadJSONBytes

app/controlplane/pkg/unmarshal/unmarshal.go:128–147  ·  view source on GitHub ↗

LoadJSONBytes Extracts raw data in JSON format from different sources, i.e yaml or json files

(rawData []byte, extension string)

Source from the content-addressed store, hash-verified

126
127// LoadJSONBytes Extracts raw data in JSON format from different sources, i.e yaml or json files
128func LoadJSONBytes(rawData []byte, extension string) ([]byte, error) {
129 var jsonRawData []byte
130 var err error
131
132 switch extension {
133 case ".yaml", ".yml":
134 jsonRawData, err = syaml.YAMLToJSON(rawData)
135 if err != nil {
136 return nil, err
137 }
138 case ".cue":
139 return nil, errCUENotSupported
140 case ".json":
141 jsonRawData = rawData
142 default:
143 return nil, errors.New("unsupported file format")
144 }
145
146 return jsonRawData, nil
147}

Callers 6

unmarshallResourceFunction · 0.92
loadSchemaFunction · 0.92
loadSchemaV2Function · 0.92
extractOrgFunction · 0.92
extractNameFromMetadataFunction · 0.92
TestCUEIsRejectedFunction · 0.85

Calls

no outgoing calls

Tested by 3

loadSchemaFunction · 0.74
loadSchemaV2Function · 0.74
TestCUEIsRejectedFunction · 0.68