MCPcopy Index your code
hub / github.com/helm/helm / createProvFile

Function createProvFile

pkg/cmd/plugin_verify_test.go:214–249  ·  view source on GitHub ↗
(t *testing.T, provFile, pluginTgz, hash string)

Source from the content-addressed store, hash-verified

212}
213
214func createProvFile(t *testing.T, provFile, pluginTgz, hash string) {
215 t.Helper()
216
217 var hashStr string
218 if hash == "" {
219 // Calculate actual hash of the tarball
220 data, err := os.ReadFile(pluginTgz)
221 if err != nil {
222 t.Fatalf("Failed to read tarball for hashing: %v", err)
223 }
224 hashSum := sha256.Sum256(data)
225 hashStr = fmt.Sprintf("sha256:%x", hashSum)
226 } else {
227 // Use provided hash
228 hashStr = hash
229 }
230
231 // Create properly formatted provenance file with specified hash
232 provContent := fmt.Sprintf(`-----BEGIN PGP SIGNED MESSAGE-----
233Hash: SHA256
234
235name: test-plugin
236version: 1.0.0
237description: Test plugin for verification
238files:
239 test-plugin-1.0.0.tgz: %s
240-----BEGIN PGP SIGNATURE-----
241Version: GnuPG v1
242
243iQEcBAEBCAAGBQJktest...
244-----END PGP SIGNATURE-----
245`, hashStr)
246 if err := os.WriteFile(provFile, []byte(provContent), 0644); err != nil {
247 t.Fatalf("Failed to create provenance file: %v", err)
248 }
249}
250
251func createTestKeyring(t *testing.T) string {
252 t.Helper()

Callers 1

Calls 3

HelperMethod · 0.80
FatalfMethod · 0.80
WriteFileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…