Skip to content

Commit da7d014

Browse files
authored
feat!: Fix meta service domains schema structure (#3249)
Fixes: #3248. BREAKING CHANGE: `APIMeta.Domains` changed from `map` to `struct`.
1 parent 882755a commit da7d014

File tree

4 files changed

+85
-9
lines changed

4 files changed

+85
-9
lines changed

github/github-accessors.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/meta.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,25 @@ type APIMeta struct {
7070
// which serve GitHub APIs.
7171
API []string `json:"api,omitempty"`
7272

73-
// A map of GitHub services and their associated domains. Note that many
74-
// of these domains are represented as wildcards (e.g. "*.github.com").
75-
Domains map[string][]string `json:"domains,omitempty"`
73+
// GitHub services and their associated domains. Note that many of these domains
74+
// are represented as wildcards (e.g. "*.github.com").
75+
Domains *APIMetaDomains `json:"domains,omitempty"`
76+
}
77+
78+
// APIMetaDomains represents the domains associated with GitHub services.
79+
type APIMetaDomains struct {
80+
Website []string `json:"website,omitempty"`
81+
Codespaces []string `json:"codespaces,omitempty"`
82+
Copilot []string `json:"copilot,omitempty"`
83+
Packages []string `json:"packages,omitempty"`
84+
Actions []string `json:"actions,omitempty"`
85+
ArtifactAttestations *APIMetaArtifactAttestations `json:"artifact_attestations,omitempty"`
86+
}
87+
88+
// APIMetaArtifactAttestations represents the artifact attestation services domains.
89+
type APIMetaArtifactAttestations struct {
90+
TrustDomain string `json:"trust_domain,omitempty"`
91+
Services []string `json:"services,omitempty"`
7692
}
7793

7894
// Get returns information about GitHub.com, the service. Or, if you access

github/meta_test.go

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,23 @@ func TestAPIMeta_Marshal(t *testing.T) {
3030
SSHKeys: []string{"k"},
3131
API: []string{"a"},
3232
Web: []string{"w"},
33-
Domains: map[string][]string{
34-
"example": {"example.com", "*.example.com"},
33+
Domains: &APIMetaDomains{
34+
Website: []string{
35+
"*.github.com",
36+
"*.github.dev",
37+
"*.github.io",
38+
"*.githubassets.com",
39+
"*.githubusercontent.com",
40+
},
41+
ArtifactAttestations: &APIMetaArtifactAttestations{
42+
TrustDomain: "",
43+
Services: []string{
44+
"*.actions.githubusercontent.com",
45+
"tuf-repo.github.com",
46+
"fulcio.githubapp.com",
47+
"timestamp.githubapp.com",
48+
},
49+
},
3550
},
3651
}
3752
want := `{
@@ -47,7 +62,7 @@ func TestAPIMeta_Marshal(t *testing.T) {
4762
"ssh_keys":["k"],
4863
"api":["a"],
4964
"web":["w"],
50-
"domains":{"example":["example.com","*.example.com"]}
65+
"domains":{"website":["*.github.com","*.github.dev","*.github.io","*.githubassets.com","*.githubusercontent.com"],"artifact_attestations":{"trust_domain":"","services":["*.actions.githubusercontent.com","tuf-repo.github.com","fulcio.githubapp.com","timestamp.githubapp.com"]}}
5166
}`
5267

5368
testJSONMarshal(t, a, want)
@@ -59,7 +74,7 @@ func TestMetaService_Get(t *testing.T) {
5974

6075
mux.HandleFunc("/meta", func(w http.ResponseWriter, r *http.Request) {
6176
testMethod(t, r, "GET")
62-
fmt.Fprint(w, `{"web":["w"],"api":["a"],"hooks":["h"], "git":["g"], "pages":["p"], "importer":["i"], "github_enterprise_importer": ["gei"], "actions":["a"], "dependabot":["d"], "verifiable_password_authentication": true, "domains":{"example":["example.com","*.example.com"]}}`)
77+
fmt.Fprint(w, `{"web":["w"],"api":["a"],"hooks":["h"], "git":["g"], "pages":["p"], "importer":["i"], "github_enterprise_importer": ["gei"], "actions":["a"], "dependabot":["d"], "verifiable_password_authentication": true, "domains":{"website":["*.github.com","*.github.dev","*.github.io","*.githubassets.com","*.githubusercontent.com"],"artifact_attestations":{"trust_domain":"","services":["*.actions.githubusercontent.com","tuf-repo.github.com","fulcio.githubapp.com","timestamp.githubapp.com"]}}}`)
6378
})
6479

6580
ctx := context.Background()
@@ -78,8 +93,23 @@ func TestMetaService_Get(t *testing.T) {
7893
Dependabot: []string{"d"},
7994
API: []string{"a"},
8095
Web: []string{"w"},
81-
Domains: map[string][]string{
82-
"example": {"example.com", "*.example.com"},
96+
Domains: &APIMetaDomains{
97+
Website: []string{
98+
"*.github.com",
99+
"*.github.dev",
100+
"*.github.io",
101+
"*.githubassets.com",
102+
"*.githubusercontent.com",
103+
},
104+
ArtifactAttestations: &APIMetaArtifactAttestations{
105+
TrustDomain: "",
106+
Services: []string{
107+
"*.actions.githubusercontent.com",
108+
"tuf-repo.github.com",
109+
"fulcio.githubapp.com",
110+
"timestamp.githubapp.com",
111+
},
112+
},
83113
},
84114

85115
VerifiablePasswordAuthentication: Bool(true),

0 commit comments

Comments
 (0)