Skip to content

Commit dda29e9

Browse files
Sara Elzayatfoot
andauthored
Update endpoint naming in cluster-service API (#3304)
* Update endpoint naming "pull-request" / "deletion-pull-request" * Group endpoints in the API docs * Tidy up comments --------- Co-authored-by: Simon Howe <[email protected]> Co-authored-by: Simon <[email protected]>
1 parent fb3f5bb commit dda29e9

File tree

16 files changed

+1314
-1217
lines changed

16 files changed

+1314
-1217
lines changed

cmd/clusters-service/api/cluster_services.proto

Lines changed: 128 additions & 98 deletions
Large diffs are not rendered by default.

cmd/clusters-service/api/cluster_services.swagger.json

Lines changed: 185 additions & 171 deletions
Large diffs are not rendered by default.

cmd/clusters-service/pkg/protos/cluster_services.pb.go

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

cmd/clusters-service/pkg/protos/cluster_services.pb.gw.go

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

cmd/clusters-service/pkg/protos/cluster_services_grpc.pb.go

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

cmd/clusters-service/pkg/server/clusters.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func (s *server) CreatePullRequest(ctx context.Context, msg *capiv1_proto.Create
278278
}, nil
279279
}
280280

281-
func (s *server) DeleteClustersPullRequest(ctx context.Context, msg *capiv1_proto.DeleteClustersPullRequestRequest) (*capiv1_proto.DeleteClustersPullRequestResponse, error) {
281+
func (s *server) CreateDeletionPullRequest(ctx context.Context, msg *capiv1_proto.CreateDeletionPullRequestRequest) (*capiv1_proto.CreateDeletionPullRequestResponse, error) {
282282
gp, err := getGitProvider(ctx, msg.RepositoryUrl)
283283
if err != nil {
284284
return nil, grpcStatus.Errorf(codes.Unauthenticated, "error creating pull request: %s", err.Error())
@@ -395,7 +395,7 @@ func (s *server) DeleteClustersPullRequest(ctx context.Context, msg *capiv1_prot
395395
return nil, err
396396
}
397397

398-
return &capiv1_proto.DeleteClustersPullRequestResponse{
398+
return &capiv1_proto.CreateDeletionPullRequestResponse{
399399
WebUrl: res.WebURL,
400400
}, nil
401401
}
@@ -880,7 +880,7 @@ func validateCreateClusterPR(msg *capiv1_proto.CreatePullRequestRequest) error {
880880
return err
881881
}
882882

883-
func validateDeleteClustersPR(msg *capiv1_proto.DeleteClustersPullRequestRequest) error {
883+
func validateDeleteClustersPR(msg *capiv1_proto.CreateDeletionPullRequestRequest) error {
884884
var err error
885885

886886
if len(msg.ClusterNamespacedNames) == 0 && len(msg.ClusterNames) == 0 {

cmd/clusters-service/pkg/server/clusters_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,21 +1823,21 @@ func TestDeleteClustersPullRequest(t *testing.T) {
18231823
testCases := []struct {
18241824
name string
18251825
provider csgit.Provider
1826-
req *capiv1_protos.DeleteClustersPullRequestRequest
1826+
req *capiv1_protos.CreateDeletionPullRequestRequest
18271827
CommittedFiles []*capiv1_protos.CommitFile
18281828
expected string
18291829
err error
18301830
}{
18311831
{
18321832
name: "validation errors",
1833-
req: &capiv1_protos.DeleteClustersPullRequestRequest{},
1833+
req: &capiv1_protos.CreateDeletionPullRequestRequest{},
18341834
err: errors.New(deleteClustersRequiredErr),
18351835
},
18361836

18371837
{
18381838
name: "create delete pull request",
18391839
provider: gitfakes.NewFakeGitProvider("https://github.com/org/repo/pull/1", nil, nil, nil, nil),
1840-
req: &capiv1_protos.DeleteClustersPullRequestRequest{
1840+
req: &capiv1_protos.CreateDeletionPullRequestRequest{
18411841
ClusterNames: []string{"foo", "bar"},
18421842
RepositoryUrl: "https://github.com/org/repo.git",
18431843
HeadBranch: "feature-02",
@@ -1854,7 +1854,7 @@ func TestDeleteClustersPullRequest(t *testing.T) {
18541854
"clusters/default/foo/kustomization.yaml",
18551855
"clusters/management/clusters/default/foo.yaml",
18561856
}, nil),
1857-
req: &capiv1_protos.DeleteClustersPullRequestRequest{
1857+
req: &capiv1_protos.CreateDeletionPullRequestRequest{
18581858
ClusterNames: []string{"foo"},
18591859
RepositoryUrl: "https://github.com/org/repo.git",
18601860
HeadBranch: "feature-02",
@@ -1868,7 +1868,7 @@ func TestDeleteClustersPullRequest(t *testing.T) {
18681868
{
18691869
name: "create delete pull request with namespaced cluster names",
18701870
provider: gitfakes.NewFakeGitProvider("https://github.com/org/repo/pull/1", nil, nil, nil, nil),
1871-
req: &capiv1_protos.DeleteClustersPullRequestRequest{
1871+
req: &capiv1_protos.CreateDeletionPullRequestRequest{
18721872
ClusterNamespacedNames: []*capiv1_protos.ClusterNamespacedName{
18731873
testNewClusterNamespacedName(t, "foo", "ns-foo"),
18741874
testNewClusterNamespacedName(t, "bar", "ns-bar"),
@@ -1888,7 +1888,7 @@ func TestDeleteClustersPullRequest(t *testing.T) {
18881888
"clusters/ns-foo/foo/kustomization.yaml",
18891889
"clusters/management/clusters/ns-foo/foo.yaml",
18901890
}, nil),
1891-
req: &capiv1_protos.DeleteClustersPullRequestRequest{
1891+
req: &capiv1_protos.CreateDeletionPullRequestRequest{
18921892
ClusterNamespacedNames: []*capiv1_protos.ClusterNamespacedName{
18931893
{
18941894
Name: "foo",
@@ -1915,7 +1915,7 @@ func TestDeleteClustersPullRequest(t *testing.T) {
19151915
})
19161916

19171917
// delete request
1918-
deletePullRequestResponse, err := s.DeleteClustersPullRequest(context.Background(), tt.req)
1918+
deletePullRequestResponse, err := s.CreateDeletionPullRequest(context.Background(), tt.req)
19191919

19201920
// Check the response looks good
19211921
if err != nil {

cmd/gitops/app/add/clusters/cmd_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestGitProviderToken(t *testing.T) {
153153

154154
httpmock.RegisterResponder(
155155
http.MethodPost,
156-
"http://localhost:8000/v1/clusters",
156+
"http://localhost:8000/v1/templates/pull-request",
157157
func(r *http.Request) (*http.Response, error) {
158158
h, ok := r.Header["Git-Provider-Token"]
159159
assert.True(t, ok)
@@ -226,7 +226,7 @@ func TestParseProfiles_ValidRequest(t *testing.T) {
226226

227227
httpmock.RegisterResponder(
228228
http.MethodPost,
229-
"http://localhost:8000/v1/clusters",
229+
"http://localhost:8000/v1/templates/pull-request",
230230
func(r *http.Request) (*http.Response, error) {
231231
h, ok := r.Header["Git-Provider-Token"]
232232
assert.True(t, ok)
@@ -263,7 +263,7 @@ func TestParseProfiles_InvalidKey(t *testing.T) {
263263

264264
httpmock.RegisterResponder(
265265
http.MethodPost,
266-
"http://localhost:8000/v1/clusters",
266+
"http://localhost:8000/v1/templates/pull-request",
267267
func(r *http.Request) (*http.Response, error) {
268268
h, ok := r.Header["Git-Provider-Token"]
269269
assert.True(t, ok)
@@ -300,7 +300,7 @@ func TestParseProfiles_InvalidValue(t *testing.T) {
300300

301301
httpmock.RegisterResponder(
302302
http.MethodPost,
303-
"http://localhost:8000/v1/clusters",
303+
"http://localhost:8000/v1/templates/pull-request",
304304
func(r *http.Request) (*http.Response, error) {
305305
h, ok := r.Header["Git-Provider-Token"]
306306
assert.True(t, ok)

cmd/gitops/app/delete/clusters/cmd_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestPayload(t *testing.T) {
3333
defer httpmock.DeactivateAndReset()
3434
httpmock.RegisterResponder(
3535
http.MethodDelete,
36-
"http://localhost:8000/v1/clusters",
36+
"http://localhost:8000/v1/templates/deletion-pull-request",
3737
func(r *http.Request) (*http.Response, error) {
3838
var f interface{}
3939
err := json.NewDecoder(r.Body).Decode(&f)
@@ -75,7 +75,7 @@ func TestGitProviderToken(t *testing.T) {
7575

7676
httpmock.RegisterResponder(
7777
http.MethodDelete,
78-
"http://localhost:8000/v1/clusters",
78+
"http://localhost:8000/v1/templates/deletion-pull-request",
7979
func(r *http.Request) (*http.Response, error) {
8080
h, ok := r.Header["Git-Provider-Token"]
8181
assert.True(t, ok)

cmd/gitops/app/get/clusters/cmd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestGetCluster(t *testing.T) {
2222
}{
2323
{
2424
name: "cluster kubeconfig",
25-
url: "http://localhost:8000/v1/clusters/dev-cluster/kubeconfig",
25+
url: "http://localhost:8000/v1/namespaces/default/clusters/dev-cluster/kubeconfig",
2626
status: http.StatusOK,
2727
response: httpmock.File("../../../pkg/adapters/testdata/cluster_kubeconfig.json"),
2828
args: []string{

0 commit comments

Comments
 (0)