CodeSampleX

Beispiel

github.com/envoyproxy/go-control-plane/envoy v1.32.2: v3.DiscoveryRequest

Verifiziertes Beispiel für golang github.com/envoyproxy/go-control-plane/envoy v1.32.2: v3.DiscoveryRequest. Der Vertrag lief auf go 1.26 · linux debian/x64…

sha256:d938d9d4bd97427eecdc15d177032fd6a93c39b5c32e2d28b51c202e4ee92423

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 go

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a…
2026-10-15

Fall

HOW
Ziel
verify github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryRequest in pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2
Pakete
Symbole
  • github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryRequest
Erstellt
2026-10-15T03:06:10Z

Contract

  1. Constructing &discoveryv3.DiscoveryRequest with VersionInfo, Node, ResourceNames, TypeUrl, and ResponseNonce exposes exact values through GetVersionInfo(), GetNode(), GetResourceNames(), GetTypeUrl(), and GetResponseNonce().
  2. Calling ValidateAll() on a populated DiscoveryRequest succeeds with a nil error.
  3. Calling getter methods on a nil *discoveryv3.DiscoveryRequest returns zero values without panicking, and Reset() clears all populated fields.

Dateien

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • spec.json
  • test/contract.go

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryRequest in pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2
Demonstrate these symbols/APIs:
  - github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryRequest

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:478c3f9a80ad85072ddcdef772a8d14114b898d1650cc62a642d5a0f4df8cb21","contract":["Constructing \u0026discoveryv3.DiscoveryRequest with VersionInfo, Node, ResourceNames, TypeUrl, and ResponseNonce exposes exact values through GetVersionInfo(), GetNode(), GetResourceNames(), GetTypeUrl(), and GetResponseNonce().","Calling ValidateAll() on a populated DiscoveryRequest succeeds with a nil error.","Calling getter methods on a nil *discoveryv3.DiscoveryRequest returns zero values without panicking, and Reset() clears all populated fields."],"goal":"verify github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryRequest in pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2","kind":"HOW","packages":["pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2"],"schemaVersion":1,"symbols":["github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryRequest"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2"],"schemaVersion":1,"subject":"pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2","symbols":["github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryRequest"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.22

require github.com/envoyproxy/go-control-plane/envoy v1.32.2

require (
	github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 // indirect
	github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
	github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
	golang.org/x/net v0.28.0 // indirect
	golang.org/x/sys v0.24.0 // indirect
	golang.org/x/text v0.17.0 // indirect
	google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
	google.golang.org/grpc v1.67.1 // indirect
	google.golang.org/protobuf v1.35.2 // indirect
)
go.sum
github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 h1:N+3sFI5GUjRKBi+i0TxYVST9h4Ie192jJWpHvthBBgg=
github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/envoyproxy/go-control-plane/envoy v1.32.2 h1:zidqwmijfcbyKqVxjQDFx042PgX+p9U+/fu/f9VtSk8=
github.com/envoyproxy/go-control-plane/envoy v1.32.2/go.mod h1:eR2SOX2IedqlPvmiKjUH7Wu//S602JKI7HPC/L3SRq8=
github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6Uu2PdjCQwWCJ3bM=
github.com/envoyproxy/protoc-gen-validate v1.1.0/go.mod h1:sXRDRVmzEbkM7CVcM06s9shE/m23dg3wzjl0UWqJ2q4=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo=
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryRequest in pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/envoyproxy/go-control-plane/envoy@v1.32.2"
  ],
  "symbols": [
    "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3.DiscoveryRequest"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
	discoveryv3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
)

func main() {
	req := &discoveryv3.DiscoveryRequest{
		VersionInfo:   "1",
		Node:          &corev3.Node{Id: "node-1", Cluster: "cluster-a"},
		ResourceNames: []string{"listener-0", "listener-1"},
		TypeUrl:       "type.googleapis.com/envoy.config.listener.v3.Listener",
		ResponseNonce: "nonce-123",
	}

	if req.GetVersionInfo() != "1" {
		fmt.Fprintln(os.Stderr, "unexpected VersionInfo:", req.GetVersionInfo())
		os.Exit(1)
	}
	if req.GetNode().GetId() != "node-1" || req.GetNode().GetCluster() != "cluster-a" {
		fmt.Fprintln(os.Stderr, "unexpected Node:", req.GetNode())
		os.Exit(1)
	}
	if len(req.GetResourceNames()) != 2 || req.GetResourceNames()[0] != "listener-0" {
		fmt.Fprintln(os.Stderr, "unexpected ResourceNames:", req.GetResourceNames())
		os.Exit(1)
	}
	if req.GetTypeUrl() != "type.googleapis.com/envoy.config.listener.v3.Listener" {
		fmt.Fprintln(os.Stderr, "unexpected TypeUrl:", req.GetTypeUrl())
		os.Exit(1)
	}
	if req.GetResponseNonce() != "nonce-123" {
		fmt.Fprintln(os.Stderr, "unexpected ResponseNonce:", req.GetResponseNonce())
		os.Exit(1)
	}
	if err := req.ValidateAll(); err != nil {
		fmt.Fprintln(os.Stderr, "unexpected validation error:", err)
		os.Exit(1)
	}

	var nilReq *discoveryv3.DiscoveryRequest
	if nilReq.GetVersionInfo() != "" || nilReq.GetNode() != nil || nilReq.GetResourceNames() != nil {
		fmt.Fprintln(os.Stderr, "expected zero values on nil receiver")
		os.Exit(1)
	}

	req.Reset()
	if req.GetVersionInfo() != "" || req.GetNode() != nil || len(req.GetResourceNames()) != 0 {
		fmt.Fprintln(os.Stderr, "expected cleared fields after Reset")
		os.Exit(1)
	}
}

Ursprungs-Seeder

anonym