Merge pull request #1779 from entireio/repo-clone-pull-gated-discovery · Entire

Home

Log in

Merge pull request #1779 from entireio/repo-clone-pull-gated-discovery

6ff2fe1→main·

matthiaswenz·21h ago·12 files·+1,245 added/-39 removed

repo clone: resolve /gh/ shorthand via pull-gated placement lookup

Changes

12

106 unmodified lines

107
108
109
110
110
111
112
113
114
115
116
115
117
118
117
119
120
121
122
121
123
124
125
126
17 unmodified lines

144
145
146
145
147
148
149
150
149
151
152
153
154
51 unmodified lines

206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
211
237
238
239
240
241
242
217
218
219
220
243
244
245
246
247
248
249
224
250
251
252
253
254
255
230
256
257
232
258
259
234
260
261
262
263
1 unmodified line

265
266
267
242
268
269
270
271
15 unmodified lines

287
288
289
264
290
291
266
292
293
268
294
295
270
296
297
272
298
299
300
301
302
303
278
279
280
304
305
306
307
308
283
309
310
285
311
312
287
313
314
315
316

106 unmodified lines

return runGitClone(cmd.Context(), cmd, ref, targetDir)
            }

provider, owner, repo, err := parseMirrorCloneRef(ref)
            // provider is always "github" for the /gh/ shorthand; the pull-gated
            // resolver pins the provider itself, so it's not threaded through.
            _, owner, repo, err := parseMirrorCloneRef(ref)
            if err != nil {
                return fmt.Errorf("invalid <repo>: %w", err)
            }

var mirrors []coreapi.Mirror
            var placements []coreapi.ResolvedPlacement
            lister := func(ctx context.Context, c *coreapi.Client) error {
                ms, err := listMirrorsForRepo(ctx, c, provider, owner, repo)
                ps, err := resolvePullablePlacements(ctx, c, owner, repo)
                if err != nil {
                    return err
                }
                mirrors = ms
                placements = ps
                return nil
            }
            // An explicit --cluster may name a cluster in a different federation
17 unmodified lines

return err
            }

if len(mirrors) == 0 {
            if len(placements) == 0 {
                return fmt.Errorf("no mirror found for /gh/%s/%s; run 'entire repo mirror create github.com/%s/%s' to onboard it", owner, repo, owner, repo)
            }

chosen, err := selectCloneTarget(cmd, mirrors, cluster)
            chosen, err := selectCloneTarget(cmd, placements, cluster)
            if err != nil {
                return err
            }
51 unmodified lines

return matched, nil
}

// resolvePullablePlacements returns every cluster placement of one GitHub
// upstream the caller may pull (clone). It backs `repo clone /gh/<owner>/<repo>`
// and deliberately differs from listMirrorsForRepo: that reads the
// affiliation-scoped mirror list (repo#list), which omits public mirrors the
// caller holds no grant on, so the shorthand used to fail on a public repo that
// clones fine by full entire:// URL. This hits the pull-gated /mirrors/placements
// endpoint instead — the same authority the clone's STS exchange enforces — so
// anything clonable resolves, public or private-with-grant.
//
// owner/repo arrive already lowercased from parseMirrorCloneRef; the server
// matches case-insensitively regardless. An empty result means not mirrored or
// not pullable, and the caller surfaces that.
func resolvePullablePlacements(ctx context.Context, c *coreapi.Client, owner, repo string) ([]coreapi.ResolvedPlacement, error) {
    out, err := c.ResolveMirrorPlacements(ctx, coreapi.ResolveMirrorPlacementsParams{
        Provider: coreapi.ResolveMirrorPlacementsProviderGithub,
        Owner:    owner,
        Repo:     repo,
    })
    if err != nil {
        return nil, fmt.Errorf("resolve mirror placements: %w", err)
    }
    return out.Placements, nil
}

// selectCloneTarget resolves which mirror placement to clone from. With one
// placement it returns it directly. With --cluster it picks the matching one (or
// errors listing the available hosts). With more than one and no flag it prompts
// interactively, failing fast with a --cluster pointer when there's no terminal.
func selectCloneTarget(cmd *cobra.Command, mirrors []coreapi.Mirror, clusterFlag string) (coreapi.Mirror, error) {
func selectCloneTarget(cmd *cobra.Command, placements []coreapi.ResolvedPlacement, clusterFlag string) (coreapi.ResolvedPlacement, error) {
    // Dedupe by cluster host: one placement per cluster is what a clone targets,
    // and the same host appearing twice would only confuse the picker. Key on the
    // case-folded host — DNS is case-insensitive, so a --cluster value differing
    // only in case from the API's ClusterHost must still match (the alternative is
    // a misleading "not mirrored on ..." after a successful lookup + dial).
    byHost := make(map[string]coreapi.Mirror, len(mirrors))
    hosts := make([]string, 0, len(mirrors))
    for _, m := range mirrors {
        key := strings.ToLower(m.ClusterHost)
    byHost := make(map[string]coreapi.ResolvedPlacement, len(placements))
    hosts := make([]string, 0, len(placements))
    for _, p := range placements {
        key := strings.ToLower(p.ClusterHost)
        if _, seen := byHost[key]; seen {
            continue
        }
        byHost[key] = m
        byHost[key] = p
        hosts = append(hosts, key)
    }
    sort.Strings(hosts)

if clusterFlag != "" {
        m, ok := byHost[strings.ToLower(strings.TrimSpace(clusterFlag))]
        p, ok := byHost[strings.ToLower(strings.TrimSpace(clusterFlag))]
        if !ok {
            return coreapi.Mirror{}, fmt.Errorf("repo is not mirrored on %q; available: %s", clusterFlag, strings.Join(hosts, ", "))
            return coreapi.ResolvedPlacement{}, fmt.Errorf("repo is not mirrored on %q; available: %s", clusterFlag, strings.Join(hosts, ", "))
        }
        return m, nil
        return p, nil
    }

if len(hosts) == 1 {
1 unmodified line

}

if !interactive.CanPromptInteractively() {
        return coreapi.Mirror{}, fmt.Errorf("repo is mirrored on %d clusters; pass --cluster to choose one of: %s", len(hosts), strings.Join(hosts, ", "))
        return coreapi.ResolvedPlacement{}, fmt.Errorf("repo is mirrored on %d clusters; pass --cluster to choose one of: %s", len(hosts), strings.Join(hosts, ", "))
    }

options := make([]huh.Option[string], len(hosts))
15 unmodified lines

// caller stops instead of falling through to clone a zero-value target
        // (the `entire:///gh/...` empty-host bug); a real form error propagates.
        if cerr := handleFormCancellation(cmd.ErrOrStderr(), "Clone", err); cerr != nil {
            return coreapi.Mirror{}, cerr
            return coreapi.ResolvedPlacement{}, cerr
        }
        return coreapi.Mirror{}, NewSilentError(errors.New("clone cancelled"))
        return coreapi.ResolvedPlacement{}, NewSilentError(errors.New("clone cancelled"))
    }
    m, ok := byHost[selected]
    p, ok := byHost[selected]
    if !ok {
        return coreapi.Mirror{}, NewSilentError(errors.New("clone cancelled"))
        return coreapi.ResolvedPlacement{}, NewSilentError(errors.New("clone cancelled"))
    }
    return m, nil
    return p, nil
}

// mirrorCellLabel is the human label for a mirror placement in the clone picker:
// the physical cell and jurisdiction when known, always anchored by the cluster
// host that goes into the clone URL.
func mirrorCellLabel(m coreapi.Mirror) string {
    cell := strings.TrimSpace(m.Cell.Or(""))
    jur := strings.TrimSpace(m.Jurisdiction.Or(""))
func mirrorCellLabel(p coreapi.ResolvedPlacement) string {
    cell := strings.TrimSpace(p.Cell.Or(""))
    jur := strings.TrimSpace(p.Jurisdiction.Or(""))
    switch {
    case cell != "" && jur != "":
        return fmt.Sprintf("%s (%s) — %s", cell, jur, m.ClusterHost)
        return fmt.Sprintf("%s (%s) — %s", cell, jur, p.ClusterHost)
    case cell != "":
        return fmt.Sprintf("%s — %s", cell, m.ClusterHost)
        return fmt.Sprintf("%s — %s", cell, p.ClusterHost)
    default:
        return m.ClusterHost
        return p.ClusterHost
    }
}

Mcmd/entire/cli/repo_clone.go+53/-27

76 unmodified lines

77
78
79
80
80
81
82
83
84
85
85
86
87
88
89
90
90
91
92
93
2 unmodified lines

96
97
98
99
99
100
101
102
36 unmodified lines

139
140
141
142
143
142
143
144
145
146
147
147
148
149
150
151
152
153
154
154
155
156
157
158
159
160
161
161
162
163
164
2 unmodified lines

167
168
169
170
170
171
172
173
174
175
176
177
177
178
179
180
2 unmodified lines

183
184
185
186
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236

76 unmodified lines

t.Parallel()
    tests := []struct {
        name   string
        mirror coreapi.Mirror
        mirror coreapi.ResolvedPlacement
        want   string
    }{
        {
            name:   "host only",
            mirror: coreapi.Mirror{ClusterHost: "aws-us-east-2.entire.io"},
            mirror: coreapi.ResolvedPlacement{ClusterHost: "aws-us-east-2.entire.io"},
            want:   "aws-us-east-2.entire.io",
        },
        {
            name: "cell and jurisdiction",
            mirror: coreapi.Mirror{
            mirror: coreapi.ResolvedPlacement{
                ClusterHost:  "aws-us-east-2.entire.io",
                Cell:         coreapi.NewOptString("aws-us-east-2"),
                Jurisdiction: coreapi.NewOptString("us"),
2 unmodified lines

},
        {
            name: "cell without jurisdiction",
            mirror: coreapi.Mirror{
            mirror: coreapi.ResolvedPlacement{
                ClusterHost: "aws-us-east-2.entire.io",
                Cell:        coreapi.NewOptString("aws-us-east-2"),
            },
36 unmodified lines

func TestSelectCloneTarget(t *testing.T) {
    t.Parallel()

usEast := coreapi.Mirror{Repo: "entire-api", ClusterHost: "aws-us-east-2.entire.io"}
    euWest := coreapi.Mirror{Repo: "entire-api", ClusterHost: "aws-eu-west-1.entire.io"}
    usEast := coreapi.ResolvedPlacement{ClusterHost: "aws-us-east-2.entire.io"}
    euWest := coreapi.ResolvedPlacement{ClusterHost: "aws-eu-west-1.entire.io"}

t.Run("single placement returns directly", func(t *testing.T) {
        t.Parallel()
        got, err := selectCloneTarget(newCloneTestCmd(), []coreapi.Mirror{usEast}, "")
        got, err := selectCloneTarget(newCloneTestCmd(), []coreapi.ResolvedPlacement{usEast}, "")
        require.NoError(t, err)
        require.Equal(t, "aws-us-east-2.entire.io", got.ClusterHost)
    })

t.Run("dedupes repeated host to a single placement", func(t *testing.T) {
        t.Parallel()
        got, err := selectCloneTarget(newCloneTestCmd(), []coreapi.Mirror{usEast, usEast}, "")
        got, err := selectCloneTarget(newCloneTestCmd(), []coreapi.ResolvedPlacement{usEast, usEast}, "")
        require.NoError(t, err)
        require.Equal(t, "aws-us-east-2.entire.io", got.ClusterHost)
    })

t.Run("--cluster picks the matching placement", func(t *testing.T) {
        t.Parallel()
        got, err := selectCloneTarget(newCloneTestCmd(), []coreapi.Mirror{usEast, euWest}, "aws-eu-west-1.entire.io")
        got, err := selectCloneTarget(newCloneTestCmd(), []coreapi.ResolvedPlacement{usEast, euWest}, "aws-eu-west-1.entire.io")
        require.NoError(t, err)
        require.Equal(t, "aws-eu-west-1.entire.io", got.ClusterHost)
    })
2 unmodified lines

t.Parallel()
        // DNS hosts are case-insensitive: a mixed-case --cluster must still match
        // the API's lowercase ClusterHost rather than falsely "not mirrored".
        got, err := selectCloneTarget(newCloneTestCmd(), []coreapi.Mirror{usEast, euWest}, "AWS-EU-West-1.Entire.IO")
        got, err := selectCloneTarget(newCloneTestCmd(), []coreapi.ResolvedPlacement{usEast, euWest}, "AWS-EU-West-1.Entire.IO")
        require.NoError(t, err)
        require.Equal(t, "aws-eu-west-1.entire.io", got.ClusterHost)
    })

t.Run("--cluster with no match errors and lists hosts", func(t *testing.T) {
        t.Parallel()
        _, err := selectCloneTarget(newCloneTestCmd(), []coreapi.Mirror{usEast, euWest}, "aws-ap-south-1.entire.io")
        _, err := selectCloneTarget(newCloneTestCmd(), []coreapi.ResolvedPlacement{usEast, euWest}, "aws-ap-south-1.entire.io")
        require.Error(t, err)
        require.Contains(t, err.Error(), "aws-us-east-2.entire.io")
        require.Contains(t, err.Error(), "aws-eu-west-1.entire.io")
2 unmodified lines

t.Run("multiple placements with no terminal errors with a --cluster pointer", func(t *testing.T) {
        t.Parallel()
        // go test is non-interactive, so the picker path is unreachable here.
        _, err := selectCloneTarget(newCloneTestCmd(), []coreapi.Mirror{usEast, euWest}, "")
        _, err := selectCloneTarget(newCloneTestCmd(), []coreapi.ResolvedPlacement{usEast, euWest}, "")
        require.Error(t, err)
        require.Contains(t, err.Error(), "--cluster")
    })
}

// TestResolvePullablePlacements_ReturnsPlacements verifies the clone-discovery
// resolver hits the pull-gated /mirrors/placements endpoint with the upstream
// coords and returns every placement (host + cell + jurisdiction) for the
// picker. A public mirror the caller holds no grant on resolves here even
// though it never would via the affiliation-scoped list — the whole point of
// the endpoint.
func TestResolvePullablePlacements_ReturnsPlacements(t *testing.T) {
    t.Parallel()
    var gotPath, gotQuery string
    srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        gotPath = r.URL.Path
        gotQuery = r.URL.RawQuery
        w.Header().Set("Content-Type", "application/json")
        body := &coreapi.ResolvePlacementsOutputBody{Placements: []coreapi.ResolvedPlacement{
            {MirrorId: "01AAA", ClusterHost: "aws-us-east-2.entire.io", Cell: coreapi.NewOptString("aws-us-east-2"), Jurisdiction: coreapi.NewOptString("us")},
            {MirrorId: "01BBB", ClusterHost: "aws-eu-west-1.entire.io", Cell: coreapi.NewOptString("aws-eu-west-1"), Jurisdiction: coreapi.NewOptString("eu")},
        }}
        if err := printJSON(w, body); err != nil {
            t.Errorf("encode response: %v", err)
        }
    }))
    t.Cleanup(srv.Close)

c, err := coreapi.NewWithBearer(srv.URL, "tok")
    require.NoError(t, err)

got, err := resolvePullablePlacements(t.Context(), c, "karthik-rameshkumar", "my-entire")
    require.NoError(t, err)

require.Equal(t, "/api/v1/mirrors/placements", gotPath)
    require.Contains(t, gotQuery, "provider=github")
    require.Contains(t, gotQuery, "owner=karthik-rameshkumar")
    require.Contains(t, gotQuery, "repo=my-entire")

require.Len(t, got, 2)
    require.Equal(t, "aws-us-east-2.entire.io", got[0].ClusterHost)
    require.Equal(t, "aws-us-east-2", got[0].Cell.Or(""))
    require.Equal(t, "us", got[0].Jurisdiction.Or(""))
    require.Equal(t, "01AAA", got[0].MirrorId)
    require.Equal(t, "aws-eu-west-1.entire.io", got[1].ClusterHost)
}

// TestListMirrorsForRepo_FiltersByRepo verifies the client-side repo filter:
// the list API filters provider+owner server-side, but the repo match (which
// the API has no param for) is applied locally.

Mcmd/entire/cli/repo_clone_test.go+54/-12

362 unmodified lines

363
364
365
366
367
368
369
370
371
372
373
374
6352 unmodified lines

6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859

362 unmodified lines

//
    // GET /identity/handles/{provider}/{handle}
    ResolveHandle(ctx context.Context, params ResolveHandleParams) (*ResolvedIdentity, error)
    // ResolveMirrorPlacements invokes resolveMirrorPlacements operation.
    //
    // Resolve the pullable cluster placements of a mirrored upstream (clone discovery).
    //
    // GET /mirrors/placements
    ResolveMirrorPlacements(ctx context.Context, params ResolveMirrorPlacementsParams) (*ResolvePlacementsOutputBody, error)
    // RevokeProjectAccess invokes revokeProjectAccess operation.
    //
    // Revoke project access by grantee id.
6352 unmodified lines

return result, nil
}

// ResolveMirrorPlacements invokes resolveMirrorPlacements operation.
//
// Resolve the pullable cluster placements of a mirrored upstream (clone discovery).
//
// GET /mirrors/placements
func (c *Client) ResolveMirrorPlacements(ctx context.Context, params ResolveMirrorPlacementsParams) (*ResolvePlacementsOutputBody, error) {
    res, err := c.sendResolveMirrorPlacements(ctx, params)
    return res, err
}

func (c *Client) sendResolveMirrorPlacements(ctx context.Context, params ResolveMirrorPlacementsParams) (res *ResolvePlacementsOutputBody, err error) {

u := uri.Clone(c.requestURL(ctx))
    var pathParts [1]string
    pathParts[0] = "/mirrors/placements"
    uri.AddPathParts(u, pathParts[:]...)

q := uri.NewQueryEncoder()
    {
        // Encode "provider" parameter.
        cfg := uri.QueryParameterEncodingConfig{
            Name:    "provider",
            Style:   uri.QueryStyleForm,
            Explode: false,
        }

if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
            return e.EncodeValue(conv.StringToString(string(params.Provider)))
        }); err != nil {
            return res, errors.Wrap(err, "encode query")
        }
    }
    {
        // Encode "owner" parameter.
        cfg := uri.QueryParameterEncodingConfig{
            Name:    "owner",
            Style:   uri.QueryStyleForm,
            Explode: false,
        }

if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
            return e.EncodeValue(conv.StringToString(params.Owner))
        }); err != nil {
            return res, errors.Wrap(err, "encode query")
        }
    }
    {
        // Encode "repo" parameter.
        cfg := uri.QueryParameterEncodingConfig{
            Name:    "repo",
            Style:   uri.QueryStyleForm,
            Explode: false,
        }

if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
            return e.EncodeValue(conv.StringToString(params.Repo))
        }); err != nil {
            return res, errors.Wrap(err, "encode query")
        }
    }
    u.RawQuery = q.Values().Encode()

r, err := ht.NewRequest(ctx, "GET", u)
    if err != nil {
        return res, errors.Wrap(err, "create request")
    }

{
        type bitset = [1]uint8
        var satisfied bitset
        {

switch err := c.securityBearerAuth(ctx, ResolveMirrorPlacementsOperation, r); {
            case err == nil: // if NO error
                satisfied[0] |= 1 << 0
            case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
                // Skip this security.
            default:
                return res, errors.Wrap(err, "security \"BearerAuth\"")
            }
        }
        {

switch err := c.securitySessionAuth(ctx, ResolveMirrorPlacementsOperation, r); {
            case err == nil: // if NO error
                satisfied[0] |= 1 << 1
            case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
                // Skip this security.
            default:
                return res, errors.Wrap(err, "security \"SessionAuth\"")
            }
        }

if ok := func() bool {
        nextRequirement:
            for _, requirement := range []bitset{
                {0b00000001},
                {0b00000010},
            } {
                for i, mask := range requirement {
                    if satisfied[i]&mask != mask {
                        continue nextRequirement
                    }
                }
                return true
            }
            return false
        }(); !ok {
            return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
        }
    }

resp, err := c.cfg.Client.Do(r)
    if err != nil {
        return res, errors.Wrap(err, "do request")
    }
    body := resp.Body
    defer body.Close()

result, err := decodeResolveMirrorPlacementsResponse(resp)
    if err != nil {
        return res, errors.Wrap(err, "decode response")
    }

return result, nil
}

// RevokeProjectAccess invokes revokeProjectAccess operation.
//
// Revoke project access by grantee id.

Minternal/coreapi/oas_client_gen.go+133

20014 unmodified lines

20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
235 unmodified lines

20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685

20014 unmodified lines

return s.Decode(d)
}

// Encode implements json.Marshaler.
func (s *ResolvePlacementsOutputBody) Encode(e *jx.Encoder) {
    e.ObjStart()
    s.encodeFields(e)
    e.ObjEnd()
}

// encodeFields encodes fields.
func (s *ResolvePlacementsOutputBody) encodeFields(e *jx.Encoder) {
    {
        if s.Schema.Set {
            e.FieldStart("$schema")
            s.Schema.Encode(e)
        }
    }
    {
        e.FieldStart("placements")
        e.ArrStart()
        for _, elem := range s.Placements {
            elem.Encode(e)
        }
        e.ArrEnd()
    }
    for k, elem := range s.AdditionalProps {
        e.FieldStart(k)

if len(elem) != 0 {
            e.Raw(elem)
        }
    }
}

var jsonFieldsNameOfResolvePlacementsOutputBody = [2]string{
    0: "$schema",
    1: "placements",
}

// Decode decodes ResolvePlacementsOutputBody from json.
func (s *ResolvePlacementsOutputBody) Decode(d *jx.Decoder) error {
    if s == nil {
        return errors.New("invalid: unable to decode ResolvePlacementsOutputBody to nil")
    }
    var requiredBitSet [1]uint8
    s.AdditionalProps = map[string]jx.Raw{}

if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
        switch string(k) {
        case "$schema":
            if err := func() error {
                s.Schema.Reset()
                if err := s.Schema.Decode(d); err != nil {
                    return err
                }
                return nil
            }(); err != nil {
                return errors.Wrap(err, "decode field \"$schema\"")
            }
        case "placements":
            requiredBitSet[0] |= 1 << 1
            if err := func() error {
                s.Placements = make([]ResolvedPlacement, 0)
                if err := d.Arr(func(d *jx.Decoder) error {
                    var elem ResolvedPlacement
                    if err := elem.Decode(d); err != nil {
                        return err
                    }
                    s.Placements = append(s.Placements, elem)
                    return nil
                }); err != nil {
                    return err
                }
                return nil
            }(); err != nil {
                return errors.Wrap(err, "decode field \"placements\"")
            }
        default:
            var elem jx.Raw
            if err := func() error {
                v, err := d.RawAppend(nil)
                elem = jx.Raw(v)
                if err != nil {
                    return err
                }
                return nil
            }(); err != nil {
                return errors.Wrapf(err, "decode field %q", k)
            }
            s.AdditionalProps[string(k)] = elem
        }
        return nil
    }); err != nil {
        return errors.Wrap(err, "decode ResolvePlacementsOutputBody")
    }
    // Validate required fields.
    var failures []validate.FieldError
    for i, mask := range [1]uint8{
        0b00000010,
    } {
        if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
            // Mask only required fields and check equality to mask using XOR.
            //
            // If XOR result is not zero, result is not equal to expected, so some fields are missed.
            // Bits of fields which would be set are actually bits of missed fields.
            missed := bits.OnesCount8(result)
            for bitN := 0; bitN < missed; bitN++ {
                bitIdx := bits.TrailingZeros8(result)
                fieldIdx := i*8 + bitIdx
                var name string
                if fieldIdx < len(jsonFieldsNameOfResolvePlacementsOutputBody) {
                    name = jsonFieldsNameOfResolvePlacementsOutputBody[fieldIdx]
                } else {
                    name = strconv.Itoa(fieldIdx)
                }
                failures = append(failures, validate.FieldError{
                    Name:  name,
                    Error: validate.ErrFieldRequired,
                })
                // Reset bit.
                result &^= 1 << bitIdx
            }
        }
    }
    if len(failures) > 0 {
        return &validate.Error{Fields: failures}
    }

return nil
}

// MarshalJSON implements stdjson.Marshaler.
func (s *ResolvePlacementsOutputBody) MarshalJSON() ([]byte, error) {
    e := jx.Encoder{}
    s.Encode(&e)
    return e.Bytes(), nil
}

// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ResolvePlacementsOutputBody) UnmarshalJSON(data []byte) error {
    d := jx.DecodeBytes(data)
    return s.Decode(d)
}

// Encode implements json.Marshaler.
func (s ResolvePlacementsOutputBodyAdditional) Encode(e *jx.Encoder) {
    e.ObjStart()
    s.encodeFields(e)
    e.ObjEnd()
}

// encodeFields implements json.Marshaler.
func (s ResolvePlacementsOutputBodyAdditional) encodeFields(e *jx.Encoder) {
    for k, elem := range s {
        e.FieldStart(k)

if len(elem) != 0 {
            e.Raw(elem)
        }
    }
}

// Decode decodes ResolvePlacementsOutputBodyAdditional from json.
func (s *ResolvePlacementsOutputBodyAdditional) Decode(d *jx.Decoder) error {
    if s == nil {
        return errors.New("invalid: unable to decode ResolvePlacementsOutputBodyAdditional to nil")
    }
    m := s.init()
    if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
        var elem jx.Raw
        if err := func() error {
            v, err := d.RawAppend(nil)
            elem = jx.Raw(v)
            if err != nil {
                return err
            }
            return nil
        }(); err != nil {
            return errors.Wrapf(err, "decode field %q", k)
        }
        m[string(k)] = elem
        return nil
    }); err != nil {
        return errors.Wrap(err, "decode ResolvePlacementsOutputBodyAdditional")
    }

return nil
}

// MarshalJSON implements stdjson.Marshaler.
func (s ResolvePlacementsOutputBodyAdditional) MarshalJSON() ([]byte, error) {
    e := jx.Encoder{}
    s.Encode(&e)
    return e.Bytes(), nil
}

// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ResolvePlacementsOutputBodyAdditional) UnmarshalJSON(data []byte) error {
    d := jx.DecodeBytes(data)
    return s.Decode(d)
}

// Encode implements json.Marshaler.
func (s *ResolvedIdentity) Encode(e *jx.Encoder) {
    e.ObjStart()
235 unmodified lines

return s.Decode(d)
}

// Encode implements json.Marshaler.
func (s *ResolvedPlacement) Encode(e *jx.Encoder) {
    e.ObjStart()
    s.encodeFields(e)
    e.ObjEnd()
}

// encodeFields encodes fields.
func (s *ResolvedPlacement) encodeFields(e *jx.Encoder) {
    {
        if s.Cell.Set {
            e.FieldStart("cell")
            s.Cell.Encode(e)
        }
    }
    {
        e.FieldStart("clusterHost")
        e.Str(s.ClusterHost)
    }
    {
        if s.Jurisdiction.Set {
            e.FieldStart("jurisdiction")
            s.Jurisdiction.Encode(e)
        }
    }
    {
        e.FieldStart("mirrorId")
        e.Str(s.MirrorId)
    }
    for k, elem := range s.AdditionalProps {
        e.FieldStart(k)

if len(elem) != 0 {
            e.Raw(elem)
        }
    }
}

var jsonFieldsNameOfResolvedPlacement = [4]string{
    0: "cell",
    1: "clusterHost",
    2: "jurisdiction",
    3: "mirrorId",
}

// Decode decodes ResolvedPlacement from json.
func (s *ResolvedPlacement) Decode(d *jx.Decoder) error {
    if s == nil {
        return errors.New("invalid: unable to decode ResolvedPlacement to nil")
    }
    var requiredBitSet [1]uint8
    s.AdditionalProps = map[string]jx.Raw{}

if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
        switch string(k) {
        case "cell":
            if err := func() error {
                s.Cell.Reset()
                if err := s.Cell.Decode(d); err != nil {
                    return err
                }
                return nil
            }(); err != nil {
                return errors.Wrap(err, "decode field \"cell\"")
            }
        case "clusterHost":
            requiredBitSet[0] |= 1 << 1
            if err := func() error {
                v, err := d.Str()
                s.ClusterHost = string(v)
                if err != nil {
                    return err
                }
                return nil
            }(); err != nil {
                return errors.Wrap(err, "decode field \"clusterHost\"")
            }
        case "jurisdiction":
            if err := func() error {
                s.Jurisdiction.Reset()
                if err := s.Jurisdiction.Decode(d); err != nil {
                    return err
                }
                return nil
            }(); err != nil {
                return errors.Wrap(err, "decode field \"jurisdiction\"")
            }
        case "mirrorId":
            requiredBitSet[0] |= 1 << 3
            if err := func() error {
                v, err := d.Str()
                s.MirrorId = string(v)
                if err != nil {
                    return err
                }
                return nil
            }(); err != nil {
                return errors.Wrap(err, "decode field \"mirrorId\"")
            }
        default:
            var elem jx.Raw
            if err := func() error {
                v, err := d.RawAppend(nil)
                elem = jx.Raw(v)
                if err != nil {
                    return err
                }
                return nil
            }(); err != nil {
                return errors.Wrapf(err, "decode field %q", k)
            }
            s.AdditionalProps[string(k)] = elem
        }
        return nil
    }); err != nil {
        return errors.Wrap(err, "decode ResolvedPlacement")
    }
    // Validate required fields.
    var failures []validate.FieldError
    for i, mask := range [1]uint8{
        0b00001010,
    } {
        if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
            // Mask only required fields and check equality to mask using XOR.
            //
            // If XOR result is not zero, result is not equal to expected, so some fields are missed.
            // Bits of fields which would be set are actually bits of missed fields.
            missed := bits.OnesCount8(result)
            for bitN := 0; bitN < missed; bitN++ {
                bitIdx := bits.TrailingZeros8(result)
                fieldIdx := i*8 + bitIdx
                var name string
                if fieldIdx < len(jsonFieldsNameOfResolvedPlacement) {
                    name = jsonFieldsNameOfResolvedPlacement[fieldIdx]
                } else {
                    name = strconv.Itoa(fieldIdx)
                }
                failures = append(failures, validate.FieldError{
                    Name:  name,
                    Error: validate.ErrFieldRequired,
                })
                // Reset bit.
                result &^= 1 << bitIdx
            }
        }
    }
    if len(failures) > 0 {
        return &validate.Error{Fields: failures}
    }

return nil
}

// MarshalJSON implements stdjson.Marshaler.
func (s *ResolvedPlacement) MarshalJSON() ([]byte, error) {
    e := jx.Encoder{}
    s.Encode(&e)
    return e.Bytes(), nil
}

// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ResolvedPlacement) UnmarshalJSON(data []byte) error {
    d := jx.DecodeBytes(data)
    return s.Decode(d)
}

// Encode implements json.Marshaler.
func (s ResolvedPlacementAdditional) Encode(e *jx.Encoder) {
    e.ObjStart()
    s.encodeFields(e)
    e.ObjEnd()
}

// encodeFields implements json.Marshaler.
func (s ResolvedPlacementAdditional) encodeFields(e *jx.Encoder) {
    for k, elem := range s {
        e.FieldStart(k)

if len(elem) != 0 {
            e.Raw(elem)
        }
    }
}

// Decode decodes ResolvedPlacementAdditional from json.
func (s *ResolvedPlacementAdditional) Decode(d *jx.Decoder) error {
    if s == nil {
        return errors.New("invalid: unable to decode ResolvedPlacementAdditional to nil")
    }
    m := s.init()
    if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
        var elem jx.Raw
        if err := func() error {
            v, err := d.RawAppend(nil)
            elem = jx.Raw(v)
            if err != nil {
                return err
            }
            return nil
        }(); err != nil {
            return errors.Wrapf(err, "decode field %q", k)
        }
        m[string(k)] = elem
        return nil
    }); err != nil {
        return errors.Wrap(err, "decode ResolvedPlacementAdditional")
    }

return nil
}

// MarshalJSON implements stdjson.Marshaler.
func (s ResolvedPlacementAdditional) MarshalJSON() ([]byte, error) {
    e := jx.Encoder{}
    s.Encode(&e)
    return e.Bytes(), nil
}

// UnmarshalJSON implements stdjson.Unmarshaler.
func (s *ResolvedPlacementAdditional) UnmarshalJSON(data []byte) error {
    d := jx.DecodeBytes(data)
    return s.Decode(d)
}

// Encode implements json.Marshaler.
func (s *ResourceAccess) Encode(e *jx.Encoder) {
    e.ObjStart()

Minternal/coreapi/oas_json_gen.go+424

62 unmodified lines

63
64
65
66
67
68
69

62 unmodified lines

PatchRepoCIWebhookOperation            OperationName = "PatchRepoCIWebhook"
    RemoveOrgMemberOperation               OperationName = "RemoveOrgMember"
    ResolveHandleOperation                 OperationName = "ResolveHandle"
    ResolveMirrorPlacementsOperation       OperationName = "ResolveMirrorPlacements"
    RevokeProjectAccessOperation           OperationName = "RevokeProjectAccess"
    RevokeProjectAccessByProviderOperation OperationName = "RevokeProjectAccessByProvider"
    RevokeRepoAccessOperation              OperationName = "RevokeRepoAccess"

Minternal/coreapi/oas_operations_gen.go+1

312 unmodified lines

313
314
315
316
317
318
319
320
321
322
323
324
325
326
327

312 unmodified lines

Handle string
}

// ResolveMirrorPlacementsParams is parameters of resolveMirrorPlacements operation.
type ResolveMirrorPlacementsParams struct {
    Provider ResolveMirrorPlacementsProvider
    // Upstream owner login (case-insensitive).
    Owner string
    // Upstream repo name (case-insensitive).
    Repo string
}

// RevokeProjectAccessParams is parameters of revokeProjectAccess operation.
type RevokeProjectAccessParams struct {
    ProjectId   string

Minternal/coreapi/oas_parameters_gen.go+9

4791 unmodified lines

4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889

4791 unmodified lines

return res, errors.Wrap(defRes, "error")
}

func decodeResolveMirrorPlacementsResponse(resp *http.Response) (res *ResolvePlacementsOutputBody, _ error) {
    switch resp.StatusCode {
    case 200:
        // Code 200.
        ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
        if err != nil {
            return res, errors.Wrap(err, "parse media type")
        }
        switch {
        case ct == "application/json":
            buf, err := io.ReadAll(resp.Body)
            if err != nil {
                return res, err
            }
            d := jx.DecodeBytes(buf)

var response ResolvePlacementsOutputBody
            if err := func() error {
                if err := response.Decode(d); err != nil {
                    return err
                }
                if err := d.Skip(); err != io.EOF {
                    return errors.New("unexpected trailing data")
                }
                return nil
            }(); err != nil {
                err = &ogenerrors.DecodeBodyError{
                    ContentType: ct,
                    Body:        buf,
                    Err:         err,
                }
                return res, err
            }
            // Validate response.
            if err := func() error {
                if err := response.Validate(); err != nil {
                    return err
                }
                return nil
            }(); err != nil {
                return res, errors.Wrap(err, "validate")
            }
            return &response, nil
        default:
            return res, validate.InvalidContentType(ct)
        }
    }
    // Convenient error response.
    defRes, err := func() (res *ErrorModelStatusCode, err error) {
        ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
        if err != nil {
            return res, errors.Wrap(err, "parse media type")
        }
        switch {
        case ct == "application/problem+json":
            buf, err := io.ReadAll(resp.Body)
            if err != nil {
                return res, err
            }
            d := jx.DecodeBytes(buf)

var response ErrorModel
            if err := func() error {
                if err := response.Decode(d); err != nil {
                    return err
                }
                if err := d.Skip(); err != io.EOF {
                    return errors.New("unexpected trailing data")
                }
                return nil
            }(); err != nil {
                err = &ogenerrors.DecodeBodyError{
                    ContentType: ct,
                    Body:        buf,
                    Err:         err,
                }
                return res, err
            }
            return &ErrorModelStatusCode{
                StatusCode: resp.StatusCode,
                Response:   response,
            }, nil
        default:
            return res, validate.InvalidContentType(ct)
        }
    }()
    if err != nil {
        return res, errors.Wrapf(err, "default (code %d)", resp.StatusCode)
    }
    return res, errors.Wrap(defRes, "error")
}

func decodeRevokeProjectAccessResponse(resp *http.Response) (res *RevokeProjectAccessNoContent, _ error) {
    switch resp.StatusCode {
    case 204:

Minternal/coreapi/oas_response_decoders_gen.go+92

8481 unmodified lines

8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
76 unmodified lines

8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724

8481 unmodified lines

return m
}

type ResolveMirrorPlacementsProvider string

const (
    ResolveMirrorPlacementsProviderGithub ResolveMirrorPlacementsProvider = "github"
)

// AllValues returns all ResolveMirrorPlacementsProvider values.
func (ResolveMirrorPlacementsProvider) AllValues() []ResolveMirrorPlacementsProvider {
    return []ResolveMirrorPlacementsProvider{
        ResolveMirrorPlacementsProviderGithub,
    }
}

// MarshalText implements encoding.TextMarshaler.
func (s ResolveMirrorPlacementsProvider) MarshalText() ([]byte, error) {
    switch s {
    case ResolveMirrorPlacementsProviderGithub:
        return []byte(s), nil
    default:
        return nil, errors.Errorf("invalid value: %q", s)
    }
}

// UnmarshalText implements encoding.TextUnmarshaler.
func (s *ResolveMirrorPlacementsProvider) UnmarshalText(data []byte) error {
    switch ResolveMirrorPlacementsProvider(data) {
    case ResolveMirrorPlacementsProviderGithub:
        *s = ResolveMirrorPlacementsProviderGithub
        return nil
    default:
        return errors.Errorf("invalid value: %q", data)
    }
}

// Ref: #/components/schemas/ResolvePlacementsOutputBody
type ResolvePlacementsOutputBody struct {
    // A URL to the JSON Schema for this object.
    Schema          OptURI              `json:"$schema"`
    Placements      []ResolvedPlacement `json:"placements"`
    AdditionalProps ResolvePlacementsOutputBodyAdditional
}

// GetSchema returns the value of Schema.
func (s *ResolvePlacementsOutputBody) GetSchema() OptURI {
    return s.Schema
}

// GetPlacements returns the value of Placements.
func (s *ResolvePlacementsOutputBody) GetPlacements() []ResolvedPlacement {
    return s.Placements
}

// GetAdditionalProps returns the value of AdditionalProps.
func (s *ResolvePlacementsOutputBody) GetAdditionalProps() ResolvePlacementsOutputBodyAdditional {
    return s.AdditionalProps
}

// SetSchema sets the value of Schema.
func (s *ResolvePlacementsOutputBody) SetSchema(val OptURI) {
    s.Schema = val
}

// SetPlacements sets the value of Placements.
func (s *ResolvePlacementsOutputBody) SetPlacements(val []ResolvedPlacement) {
    s.Placements = val
}

// SetAdditionalProps sets the value of AdditionalProps.
func (s *ResolvePlacementsOutputBody) SetAdditionalProps(val ResolvePlacementsOutputBodyAdditional) {
    s.AdditionalProps = val
}

type ResolvePlacementsOutputBodyAdditional map[string]jx.Raw

func (s *ResolvePlacementsOutputBodyAdditional) init() ResolvePlacementsOutputBodyAdditional {
    m := *s
    if m == nil {
        m = map[string]jx.Raw{}
        *s = m
    }
    return m
}

// Ref: #/components/schemas/ResolvedIdentity
type ResolvedIdentity struct {
    // A URL to the JSON Schema for this object.
76 unmodified lines

return m
}

// Ref: #/components/schemas/ResolvedPlacement
type ResolvedPlacement struct {
    // Physical cell the mirror's cluster runs in, e.g. aws-us-east-2.
    Cell OptString `json:"cell"`
    // Public host of the cluster serving this mirror.
    ClusterHost     string    `json:"clusterHost"`
    Jurisdiction    OptString `json:"jurisdiction"`
    MirrorId        string    `json:"mirrorId"`
    AdditionalProps ResolvedPlacementAdditional
}

// GetCell returns the value of Cell.
func (s *ResolvedPlacement) GetCell() OptString {
    return s.Cell
}

// GetClusterHost returns the value of ClusterHost.
func (s *ResolvedPlacement) GetClusterHost() string {
    return s.ClusterHost
}

// GetJurisdiction returns the value of Jurisdiction.
func (s *ResolvedPlacement) GetJurisdiction() OptString {
    return s.Jurisdiction
}

// GetMirrorId returns the value of MirrorId.
func (s *ResolvedPlacement) GetMirrorId() string {
    return s.MirrorId
}

// GetAdditionalProps returns the value of AdditionalProps.
func (s *ResolvedPlacement) GetAdditionalProps() ResolvedPlacementAdditional {
    return s.AdditionalProps
}

// SetCell sets the value of Cell.
func (s *ResolvedPlacement) SetCell(val OptString) {
    s.Cell = val
}

// SetClusterHost sets the value of ClusterHost.
func (s *ResolvedPlacement) SetClusterHost(val string) {
    s.ClusterHost = val
}

// SetJurisdiction sets the value of Jurisdiction.
func (s *ResolvedPlacement) SetJurisdiction(val OptString) {
    s.Jurisdiction = val
}

// SetMirrorId sets the value of MirrorId.
func (s *ResolvedPlacement) SetMirrorId(val string) {
    s.MirrorId = val
}

// SetAdditionalProps sets the value of AdditionalProps.
func (s *ResolvedPlacement) SetAdditionalProps(val ResolvedPlacementAdditional) {
    s.AdditionalProps = val
}

type ResolvedPlacementAdditional map[string]jx.Raw

func (s *ResolvedPlacementAdditional) init() ResolvedPlacementAdditional {
    m := *s
    if m == nil {
        m = map[string]jx.Raw{}
        *s = m
    }
    return m
}

// Ref: #/components/schemas/ResourceAccess
type ResourceAccess struct {
    Permissions     []string `json:"permissions"`

Minternal/coreapi/oas_schemas_gen.go+155

75 unmodified lines

76
77
78
79
80
81
82
80 unmodified lines

163
164
165
166
167
168
169

75 unmodified lines

PatchRepoCIWebhookOperation:            {},
    RemoveOrgMemberOperation:               {},
    ResolveHandleOperation:                 {},
    ResolveMirrorPlacementsOperation:       {},
    RevokeProjectAccessOperation:           {},
    RevokeProjectAccessByProviderOperation: {},
    RevokeRepoAccessOperation:              {},
80 unmodified lines

PatchRepoCIWebhookOperation:            {},
    RemoveOrgMemberOperation:               {},
    ResolveHandleOperation:                 {},
    ResolveMirrorPlacementsOperation:       {},
    RevokeProjectAccessOperation:           {},
    RevokeProjectAccessByProviderOperation: {},
    RevokeRepoAccessOperation:              {},

Minternal/coreapi/oas_security_gen.go+2

2308 unmodified lines

2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346

2308 unmodified lines

}
}

func (s ResolveMirrorPlacementsProvider) Validate() error {
    switch s {
    case "github":
        return nil
    default:
        return errors.Errorf("invalid value: %v", s)
    }
}

func (s *ResolvePlacementsOutputBody) Validate() error {
    if s == nil {
        return validate.ErrNilPointer
    }

var failures []validate.FieldError
    if err := func() error {
        if s.Placements == nil {
            return errors.New("nil is invalid value")
        }
        return nil
    }(); err != nil {
        failures = append(failures, validate.FieldError{
            Name:  "placements",
            Error: err,
        })
    }
    if len(failures) > 0 {
        return &validate.Error{Fields: failures}
    }
    return nil
}

func (s *ResourceAccess) Validate() error {
    if s == nil {
        return validate.ErrNilPointer

Minternal/coreapi/oas_validators_gen.go+32

2499 unmodified lines

2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
27 unmodified lines

2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
1254 unmodified lines

3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923

2499 unmodified lines

],
        "type": "object"
      },
      "ResolvePlacementsOutputBody": {
        "additionalProperties": true,
        "properties": {
          "$schema": {
            "description": "A URL to the JSON Schema for this object.",
            "examples": [\
              "/api/v1/schemas/ResolvePlacementsOutputBody.json"\
            ],
            "format": "uri",
            "readOnly": true,
            "type": "string"
          },
          "placements": {
            "items": {
              "$ref": "#/components/schemas/ResolvedPlacement"
            },
            "type": "array"
          }
        },
        "required": [\
          "placements"\
        ],
        "type": "object"
      },
      "ResolvedIdentity": {
        "additionalProperties": true,
        "properties": {
27 unmodified lines

],
        "type": "object"
      },
      "ResolvedPlacement": {
        "additionalProperties": true,
        "properties": {
          "cell": {
            "description": "Physical cell the mirror's cluster runs in, e.g. aws-us-east-2.",
            "type": "string"
          },
          "clusterHost": {
            "description": "Public host of the cluster serving this mirror.",
            "type": "string"
          },
          "jurisdiction": {
            "type": "string"
          },
          "mirrorId": {
            "type": "string"
          }
        },
        "required": [\
          "mirrorId",\
          "clusterHost"\
        ],
        "type": "object"
      },
      "ResourceAccess": {
        "additionalProperties": true,
        "properties": {
1254 unmodified lines

]
      }
    },
    "/mirrors/placements": {
      "get": {
        "operationId": "resolveMirrorPlacements",
        "parameters": [\
          {\
            "explode": false,\
            "in": "query",\
            "name": "provider",\
            "required": true,\
            "schema": {\
              "enum": [\
                "github"\
              ],\
              "type": "string"\
            }\
          },\
          {\
            "description": "Upstream owner login (case-insensitive).",\
            "explode": false,\
            "in": "query",\
            "name": "owner",\
            "required": true,\
            "schema": {\
              "description": "Upstream owner login (case-insensitive).",\
              "minLength": 1,\
              "type": "string"\
            }\
          },\
          {\
            "description": "Upstream repo name (case-insensitive).",\
            "explode": false,\
            "in": "query",\
            "name": "repo",\
            "required": true,\
            "schema": {\
              "description": "Upstream repo name (case-insensitive).",\
              "minLength": 1,\
              "type": "string"\
            }\
          }\
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResolvePlacementsOutputBody"
                }
              }
            },
            "description": "OK"
          },
          "default": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorModel"
                }
              }
            },
            "description": "Error"
          }
        },
        "security": [\
          {\
            "bearerAuth": []\
          },\
          {\
            "sessionAuth": []\
          }\
        ],
        "summary": "Resolve the pullable cluster placements of a mirrored upstream (clone discovery)",
        "tags": [\
          "mirrors"\
        ]
      }
    },
    "/mirrors/{mirrorId}": {
      "get": {
        "operationId": "getMirror",

Minternal/coreapi/spec/core.gen.json+125

2841 unmodified lines

2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
7097 unmodified lines

9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115

2841 unmodified lines

"memberships"
        ],
        "type": "object"
      },
      "ResolvePlacementsOutputBody": {
        "additionalProperties": true,
        "properties": {
          "$schema": {
            "description": "A URL to the JSON Schema for this object.",
            "examples": [\
              "/api/v1/schemas/ResolvePlacementsOutputBody.json"\
            ],
            "format": "uri",
            "readOnly": true,
            "type": "string"
          },
          "placements": {
            "items": {
              "$ref": "#/components/schemas/ResolvedPlacement"
            },
            "type": "array"
          }
        },
        "required": [\
          "placements"\
        ],
        "type": "object"
      },
      "ResolvedPlacement": {
        "additionalProperties": true,
        "properties": {
          "cell": {
            "description": "Physical cell the mirror's cluster runs in, e.g. aws-us-east-2.",
            "type": "string"
          },
          "clusterHost": {
            "description": "Public host of the cluster serving this mirror.",
            "type": "string"
          },
          "jurisdiction": {
            "type": "string"
          },
          "mirrorId": {
            "type": "string"
          }
        },
        "required": [\
          "mirrorId",\
          "clusterHost"\
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
7097 unmodified lines

"meta"
        ]
      }
    },
    "/mirrors/placements": {
      "get": {
        "operationId": "resolveMirrorPlacements",
        "parameters": [\
          {\
            "explode": false,\
            "in": "query",\
            "name": "provider",\
            "required": true,\
            "schema": {\
              "enum": [\
                "github"\
              ],\
              "type": "string"\
            }\
          },\
          {\
            "description": "Upstream owner login (case-insensitive).",\
            "explode": false,\
            "in": "query",\
            "name": "owner",\
            "required": true,\
            "schema": {\
              "description": "Upstream owner login (case-insensitive).",\
              "minLength": 1,\
              "type": "string"\
            }\
          },\
          {\
            "description": "Upstream repo name (case-insensitive).",\
            "explode": false,\
            "in": "query",\
            "name": "repo",\
            "required": true,\
            "schema": {\
              "description": "Upstream repo name (case-insensitive).",\
              "minLength": 1,\
              "type": "string"\
            }\
          }\
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResolvePlacementsOutputBody"
                }
              }
            },
            "description": "OK"
          },
          "400": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorModel"
                }
              }
            },
            "description": "Bad Request"
          },
          "401": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorModel"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorModel"
                }
              }
            },
            "description": "Forbidden"
          },
          "422": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorModel"
                }
              }
            },
            "description": "Unprocessable Entity"
          },
          "500": {
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorModel"
                }
              }
            },
            "description": "Internal Server Error"
          }
        },
        "security": [\
          {\
            "bearerAuth": []\
          },\
          {\
            "sessionAuth": []\
          }\
        ],
        "summary": "Resolve the pullable cluster placements of a mirrored upstream (clone discovery)",
        "tags": [\
          "mirrors"\
        ]
      }
    }
  },
  "servers": [\
```\
\
Minternal/coreapi/spec/core.openapi.json+165