샘플
github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5: v3.ResourceLocator
검증된 샘플 — golang github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5: v3.ResourceLocator. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:9fde4f31cf98f9549e178e1603f698684f784a61892aa00b6cd89f2960bedf00
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify github.com/cncf/xds/go/xds/core/v3.ResourceLocator in pkg:golang/github.com/cncf/xds/go@v0.0.0-20251210132809-ee656c7534f5
- 심벌
-
- github.com/cncf/xds/go/xds/core/v3.ResourceLocator
- 생성일
- 2026-10-15T01:36:14Z
컨트랙트
- ResourceLocator initializes with scheme, id, authority, resource type, exact context, and directives
- ResourceLocator getters safely return default values on nil and empty receivers without panic
- ResourceLocator validation passes for valid XDSTP, HTTP, and FILE schemes with non-empty resource type and nested alt directives
- ResourceLocator validation returns an error when resource type is empty or scheme is out of range
- ResourceLocator round-trips through Protobuf binary wire format preserving equality
- proto.Clone creates an independent deep copy of ResourceLocator
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/main.go
소스
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/cncf/xds/go/xds/core/v3.ResourceLocator in pkg:golang/github.com/cncf/xds/go@v0.0.0-20251210132809-ee656c7534f5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/cncf/xds/go@v0.0.0-20251210132809-ee656c7534f5
Demonstrate these symbols/APIs:
- github.com/cncf/xds/go/xds/core/v3.ResourceLocator
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.
{"case":{"caseId":"case:sha256:5dc9dd00707e3d49b55da02a65b6a553e012b6a322b31000aac408f7680718a1","contract":["ResourceLocator initializes with scheme, id, authority, resource type, exact context, and directives","ResourceLocator getters safely return default values on nil and empty receivers without panic","ResourceLocator validation passes for valid XDSTP, HTTP, and FILE schemes with non-empty resource type and nested alt directives","ResourceLocator validation returns an error when resource type is empty or scheme is out of range","ResourceLocator round-trips through Protobuf binary wire format preserving equality","proto.Clone creates an independent deep copy of ResourceLocator"],"goal":"verify github.com/cncf/xds/go/xds/core/v3.ResourceLocator in pkg:golang/github.com/cncf/xds/go@v0.0.0-20251210132809-ee656c7534f5","kind":"HOW","packages":["pkg:golang/github.com/cncf/xds/go@v0.0.0-20251210132809-ee656c7534f5"],"schemaVersion":1,"symbols":["github.com/cncf/xds/go/xds/core/v3.ResourceLocator"]},"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/cncf/xds/go@v0.0.0-20251210132809-ee656c7534f5"],"schemaVersion":1,"subject":"pkg:golang/github.com/cncf/xds/go@v0.0.0-20251210132809-ee656c7534f5","symbols":["github.com/cncf/xds/go/xds/core/v3.ResourceLocator"],"verifierAdapter":"golang@1"}
module example.com/resourcelocator
go 1.24
require (
github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5
google.golang.org/protobuf v1.36.10
)
require github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 h1:6xNmx7iTtyBRev0+D/Tv1FZd4SCg8axKApyNyRsAt/w=
github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5/go.mod h1:KdCmV+x/BuvyMxRnYBlmVaq4OLiKW6iRQfvC62cvdkI=
github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8=
github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
{
"schemaVersion": 1,
"goal": "verify github.com/cncf/xds/go/xds/core/v3.ResourceLocator in pkg:golang/github.com/cncf/xds/go@v0.0.0-20251210132809-ee656c7534f5",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/cncf/xds/go@v0.0.0-20251210132809-ee656c7534f5"
],
"symbols": [
"github.com/cncf/xds/go/xds/core/v3.ResourceLocator"
]
}
package main
import (
"fmt"
"os"
corev3 "github.com/cncf/xds/go/xds/core/v3"
"google.golang.org/protobuf/proto"
)
func check(ok bool, msg string) {
if !ok {
fmt.Fprintf(os.Stderr, "contract failed: %s\n", msg)
os.Exit(1)
}
}
func main() {
// 1. ResourceLocator initializes with scheme, id, authority, resource type, exact context, and directives
{
loc := &corev3.ResourceLocator{
Scheme: corev3.ResourceLocator_XDSTP,
Id: "route-primary",
Authority: "example.com",
ResourceType: "envoy.config.route.v3.RouteConfiguration",
ContextParamSpecifier: &corev3.ResourceLocator_ExactContext{
ExactContext: &corev3.ContextParams{
Params: map[string]string{
"region": "us-east",
},
},
},
Directives: []*corev3.ResourceLocator_Directive{
{
Directive: &corev3.ResourceLocator_Directive_Entry{
Entry: "main-entry",
},
},
},
}
check(loc.GetScheme() == corev3.ResourceLocator_XDSTP, "GetScheme mismatch")
check(loc.GetId() == "route-primary", "GetId mismatch")
check(loc.GetAuthority() == "example.com", "GetAuthority mismatch")
check(loc.GetResourceType() == "envoy.config.route.v3.RouteConfiguration", "GetResourceType mismatch")
check(loc.GetExactContext() != nil, "GetExactContext nil")
check(loc.GetExactContext().GetParams()["region"] == "us-east", "ExactContext param mismatch")
check(len(loc.GetDirectives()) == 1, "GetDirectives length mismatch")
check(loc.GetDirectives()[0].GetEntry() == "main-entry", "Directive entry mismatch")
}
// 2. ResourceLocator getters safely return default values on nil and empty receivers without panic
{
var nilLoc *corev3.ResourceLocator
check(nilLoc.GetScheme() == corev3.ResourceLocator_XDSTP, "nil GetScheme should be XDSTP")
check(nilLoc.GetId() == "", "nil GetId should be empty")
check(nilLoc.GetAuthority() == "", "nil GetAuthority should be empty")
check(nilLoc.GetResourceType() == "", "nil GetResourceType should be empty")
check(nilLoc.GetContextParamSpecifier() == nil, "nil GetContextParamSpecifier should be nil")
check(nilLoc.GetExactContext() == nil, "nil GetExactContext should be nil")
check(nilLoc.GetDirectives() == nil, "nil GetDirectives should be nil")
check(nilLoc.Validate() == nil, "nil Validate should return nil")
check(nilLoc.ValidateAll() == nil, "nil ValidateAll should return nil")
emptyLoc := &corev3.ResourceLocator{}
check(emptyLoc.GetScheme() == corev3.ResourceLocator_XDSTP, "empty GetScheme should be XDSTP")
check(emptyLoc.GetId() == "", "empty GetId should be empty")
check(emptyLoc.GetAuthority() == "", "empty GetAuthority should be empty")
check(emptyLoc.GetResourceType() == "", "empty GetResourceType should be empty")
check(emptyLoc.GetExactContext() == nil, "empty GetExactContext should be nil")
check(emptyLoc.GetDirectives() == nil, "empty GetDirectives should be nil")
}
// 3. ResourceLocator validation passes for valid XDSTP, HTTP, and FILE schemes with non-empty resource type and nested alt directives
{
validXdstp := &corev3.ResourceLocator{
Scheme: corev3.ResourceLocator_XDSTP,
ResourceType: "envoy.config.listener.v3.Listener",
}
check(validXdstp.Validate() == nil, "validXdstp Validate failed")
check(validXdstp.ValidateAll() == nil, "validXdstp ValidateAll failed")
validWithAlt := &corev3.ResourceLocator{
Scheme: corev3.ResourceLocator_HTTP,
Authority: "example.com",
ResourceType: "envoy.config.cluster.v3.Cluster",
Directives: []*corev3.ResourceLocator_Directive{
{
Directive: &corev3.ResourceLocator_Directive_Alt{
Alt: &corev3.ResourceLocator{
Scheme: corev3.ResourceLocator_FILE,
ResourceType: "envoy.config.cluster.v3.Cluster",
},
},
},
},
}
check(validWithAlt.Validate() == nil, "validWithAlt Validate failed")
check(validWithAlt.ValidateAll() == nil, "validWithAlt ValidateAll failed")
}
// 4. ResourceLocator validation returns an error when resource type is empty or scheme is out of range
{
missingType := &corev3.ResourceLocator{
Scheme: corev3.ResourceLocator_XDSTP,
ResourceType: "",
}
check(missingType.Validate() != nil, "expected error for empty ResourceType")
badScheme := &corev3.ResourceLocator{
Scheme: corev3.ResourceLocator_Scheme(42),
ResourceType: "envoy.config.listener.v3.Listener",
}
check(badScheme.Validate() != nil, "expected error for invalid Scheme")
check(badScheme.ValidateAll() != nil, "expected ValidateAll error for invalid Scheme")
}
// 5. ResourceLocator round-trips through Protobuf binary wire format preserving equality
{
original := &corev3.ResourceLocator{
Scheme: corev3.ResourceLocator_XDSTP,
Id: "listener-01",
Authority: "example.com",
ResourceType: "envoy.config.listener.v3.Listener",
ContextParamSpecifier: &corev3.ResourceLocator_ExactContext{
ExactContext: &corev3.ContextParams{
Params: map[string]string{"zone": "az1"},
},
},
}
data, err := proto.Marshal(original)
check(err == nil && len(data) > 0, "proto.Marshal failed")
decoded := &corev3.ResourceLocator{}
err = proto.Unmarshal(data, decoded)
check(err == nil, "proto.Unmarshal failed")
check(proto.Equal(original, decoded), "proto.Equal failed after round-trip")
}
// 6. proto.Clone creates an independent deep copy of ResourceLocator
{
src := &corev3.ResourceLocator{
Scheme: corev3.ResourceLocator_XDSTP,
Id: "src-id",
Authority: "example.com",
ResourceType: "envoy.config.listener.v3.Listener",
ContextParamSpecifier: &corev3.ResourceLocator_ExactContext{
ExactContext: &corev3.ContextParams{
Params: map[string]string{"tier": "frontend"},
},
},
}
dst := proto.Clone(src).(*corev3.ResourceLocator)
check(proto.Equal(src, dst), "cloned message not equal to source")
dst.Id = "modified-id"
dst.GetExactContext().GetParams()["tier"] = "backend"
check(src.GetId() == "src-id", "mutating clone affected source Id")
check(src.GetExactContext().GetParams()["tier"] == "frontend", "mutating clone affected source ExactContext")
}
fmt.Println("PASS")
}
오리진 시더
익명