Remove unused code in marketplace API (#2124)
This commit is contained in:
@@ -359,52 +359,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Delete email registered for marketplace integration",
|
||||
"operationId": "DeleteMPIntegration",
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Update email registered for marketplace integration",
|
||||
"operationId": "PatchMPIntegration",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/mpIntegration"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/namespace": {
|
||||
@@ -5071,52 +5025,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Delete email registered for marketplace integration",
|
||||
"operationId": "DeleteMPIntegration",
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"patch": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Update email registered for marketplace integration",
|
||||
"operationId": "PatchMPIntegration",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/mpIntegration"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/namespace": {
|
||||
|
||||
@@ -54,21 +54,6 @@ func registerMarketplaceHandlers(api *operations.OperatorAPI) {
|
||||
}
|
||||
return operator_api.NewPostMPIntegrationCreated()
|
||||
})
|
||||
|
||||
api.OperatorAPIPatchMPIntegrationHandler = operator_api.PatchMPIntegrationHandlerFunc(func(params operator_api.PatchMPIntegrationParams, session *models.Principal) middleware.Responder {
|
||||
err := patchMPIntegrationResponse(session, params)
|
||||
if err != nil {
|
||||
return operator_api.NewPatchMPIntegrationDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return operator_api.NewPatchMPIntegrationOK()
|
||||
})
|
||||
|
||||
api.OperatorAPIDeleteMPIntegrationHandler = operator_api.DeleteMPIntegrationHandlerFunc(func(params operator_api.DeleteMPIntegrationParams, session *models.Principal) middleware.Responder {
|
||||
if err := deleteMPIntegrationResponse(session, params); err != nil {
|
||||
return operator_api.NewDeleteMPIntegrationDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return operator_api.NewDeleteMPIntegrationNoContent()
|
||||
})
|
||||
}
|
||||
|
||||
func getMPIntegrationResponse(session *models.Principal, params operator_api.GetMPIntegrationParams) (*models.MpIntegration, *models.Error) {
|
||||
@@ -108,37 +93,21 @@ func postMPIntegrationResponse(session *models.Principal, params operator_api.Po
|
||||
if err != nil {
|
||||
return errors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
return setMPIntegration(ctx, params.Body.Email, false, &k8sClient{client: clientSet})
|
||||
return setMPIntegration(ctx, params.Body.Email, &k8sClient{client: clientSet})
|
||||
}
|
||||
|
||||
func patchMPIntegrationResponse(session *models.Principal, params operator_api.PatchMPIntegrationParams) *models.Error {
|
||||
if true { // This block will be removed once service to register emails is deployed
|
||||
return &models.Error{Code: 501}
|
||||
}
|
||||
clientSet, err := cluster.K8sClient(session.STSSessionToken)
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
if err != nil {
|
||||
return errors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
return setMPIntegration(ctx, params.Body.Email, true, &k8sClient{client: clientSet})
|
||||
}
|
||||
|
||||
func setMPIntegration(ctx context.Context, email string, override bool, clientSet K8sClientI) *models.Error {
|
||||
func setMPIntegration(ctx context.Context, email string, clientSet K8sClientI) *models.Error {
|
||||
if email == "" {
|
||||
return errors.ErrorWithContext(ctx, errors.ErrBadRequest, fmt.Errorf(emailNotSetMsg))
|
||||
}
|
||||
if _, err := setMPEmail(ctx, email, override, clientSet); err != nil {
|
||||
if _, err := setMPEmail(ctx, email, clientSet); err != nil {
|
||||
return errors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setMPEmail(ctx context.Context, email string, override bool, clientSet K8sClientI) (*corev1.ConfigMap, error) {
|
||||
func setMPEmail(ctx context.Context, email string, clientSet K8sClientI) (*corev1.ConfigMap, error) {
|
||||
cm := createCM(email)
|
||||
if override {
|
||||
return clientSet.updateConfigMap(ctx, "default", cm, metav1.UpdateOptions{})
|
||||
}
|
||||
return clientSet.createConfigMap(ctx, "default", cm, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
@@ -156,26 +125,6 @@ func createCM(email string) *corev1.ConfigMap {
|
||||
}
|
||||
}
|
||||
|
||||
func deleteMPIntegrationResponse(session *models.Principal, params operator_api.DeleteMPIntegrationParams) *models.Error {
|
||||
if true { // This block will be removed once service to register emails is deployed
|
||||
return &models.Error{Code: 501}
|
||||
}
|
||||
clientSet, err := cluster.K8sClient(session.STSSessionToken)
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
if err != nil {
|
||||
return errors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
return deleteMPIntegration(ctx, &k8sClient{client: clientSet})
|
||||
}
|
||||
|
||||
func deleteMPIntegration(ctx context.Context, clientSet K8sClientI) *models.Error {
|
||||
if err := clientSet.deleteConfigMap(ctx, "default", getMPConfigMapKey(mpConfigMapKey), metav1.DeleteOptions{}); err != nil {
|
||||
return errors.ErrorWithContext(ctx, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getMPConfigMapKey(envVar string) string {
|
||||
if mp := os.Getenv(envVar); mp != "" {
|
||||
return mp
|
||||
|
||||
@@ -110,13 +110,9 @@ func (suite *MarketplaceTestSuite) TestRegisterMarketplaceHandlers() {
|
||||
api := &operations.OperatorAPI{}
|
||||
suite.assert.Nil(api.OperatorAPIGetMPIntegrationHandler)
|
||||
suite.assert.Nil(api.OperatorAPIPostMPIntegrationHandler)
|
||||
suite.assert.Nil(api.OperatorAPIPatchMPIntegrationHandler)
|
||||
suite.assert.Nil(api.OperatorAPIDeleteMPIntegrationHandler)
|
||||
registerMarketplaceHandlers(api)
|
||||
suite.assert.NotNil(api.OperatorAPIGetMPIntegrationHandler)
|
||||
suite.assert.NotNil(api.OperatorAPIPostMPIntegrationHandler)
|
||||
suite.assert.NotNil(api.OperatorAPIPatchMPIntegrationHandler)
|
||||
suite.assert.NotNil(api.OperatorAPIDeleteMPIntegrationHandler)
|
||||
}
|
||||
|
||||
// TODO
|
||||
@@ -134,27 +130,6 @@ func (suite *MarketplaceTestSuite) TestGetMPIntegrationHandlerWithError() {
|
||||
suite.assert.True(ok)
|
||||
}
|
||||
|
||||
func (suite *MarketplaceTestSuite) TestPatchMPIntegrationHandlerWithError() {
|
||||
api := &operations.OperatorAPI{}
|
||||
registerMarketplaceHandlers(api)
|
||||
params := operator_api.NewPatchMPIntegrationParams()
|
||||
params.HTTPRequest = &http.Request{}
|
||||
params.Body = &models.MpIntegration{Email: "mock@mock.com"}
|
||||
response := api.OperatorAPIPatchMPIntegrationHandler.Handle(params, &models.Principal{})
|
||||
_, ok := response.(*operator_api.PatchMPIntegrationDefault)
|
||||
suite.assert.True(ok)
|
||||
}
|
||||
|
||||
func (suite *MarketplaceTestSuite) TestDeleteMPIntegrationHandlerWithError() {
|
||||
api := &operations.OperatorAPI{}
|
||||
registerMarketplaceHandlers(api)
|
||||
params := operator_api.NewDeleteMPIntegrationParams()
|
||||
params.HTTPRequest = &http.Request{}
|
||||
response := api.OperatorAPIDeleteMPIntegrationHandler.Handle(params, &models.Principal{})
|
||||
_, ok := response.(*operator_api.DeleteMPIntegrationDefault)
|
||||
suite.assert.True(ok)
|
||||
}
|
||||
|
||||
func (suite *MarketplaceTestSuite) TestGetMPEmailWithError() {
|
||||
testWithError = true
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
@@ -176,7 +151,7 @@ func (suite *MarketplaceTestSuite) TestGetMPEmailNoError() {
|
||||
func (suite *MarketplaceTestSuite) TestSetMPIntegrationNoEmail() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
err := setMPIntegration(ctx, "", false, &suite.kClient)
|
||||
err := setMPIntegration(ctx, "", &suite.kClient)
|
||||
suite.assert.NotNil(err)
|
||||
}
|
||||
|
||||
@@ -184,7 +159,7 @@ func (suite *MarketplaceTestSuite) TestSetMPIntegrationWithError() {
|
||||
testWithError = true
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
err := setMPIntegration(ctx, "mock@mock.com", false, &suite.kClient)
|
||||
err := setMPIntegration(ctx, "mock@mock.com", &suite.kClient)
|
||||
suite.assert.NotNil(err)
|
||||
}
|
||||
|
||||
@@ -192,31 +167,7 @@ func (suite *MarketplaceTestSuite) TestSetMPIntegrationNoError() {
|
||||
testWithError = false
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
err := setMPIntegration(ctx, "mock@mock.com", false, &suite.kClient)
|
||||
suite.assert.Nil(err)
|
||||
}
|
||||
|
||||
func (suite *MarketplaceTestSuite) TestSetMPIntegrationOverrideNoError() {
|
||||
testWithError = false
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
err := setMPIntegration(ctx, "mock@mock.com", true, &suite.kClient)
|
||||
suite.assert.Nil(err)
|
||||
}
|
||||
|
||||
func (suite *MarketplaceTestSuite) TestDeleteMPIntegrationWithError() {
|
||||
testWithError = true
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
err := deleteMPIntegration(ctx, &suite.kClient)
|
||||
suite.assert.NotNil(err)
|
||||
}
|
||||
|
||||
func (suite *MarketplaceTestSuite) TestDeleteMPIntegrationNoError() {
|
||||
testWithError = false
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
err := deleteMPIntegration(ctx, &suite.kClient)
|
||||
err := setMPIntegration(ctx, "mock@mock.com", &suite.kClient)
|
||||
suite.assert.Nil(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -73,9 +73,6 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
|
||||
OperatorAPICreateTenantHandler: operator_api.CreateTenantHandlerFunc(func(params operator_api.CreateTenantParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.CreateTenant has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIDeleteMPIntegrationHandler: operator_api.DeleteMPIntegrationHandlerFunc(func(params operator_api.DeleteMPIntegrationParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.DeleteMPIntegration has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIDeletePVCHandler: operator_api.DeletePVCHandlerFunc(func(params operator_api.DeletePVCParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.DeletePVC has not yet been implemented")
|
||||
}),
|
||||
@@ -169,9 +166,6 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
|
||||
AuthLogoutHandler: auth.LogoutHandlerFunc(func(params auth.LogoutParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation auth.Logout has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIPatchMPIntegrationHandler: operator_api.PatchMPIntegrationHandlerFunc(func(params operator_api.PatchMPIntegrationParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.PatchMPIntegration has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIPostMPIntegrationHandler: operator_api.PostMPIntegrationHandlerFunc(func(params operator_api.PostMPIntegrationParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.PostMPIntegration has not yet been implemented")
|
||||
}),
|
||||
@@ -293,8 +287,6 @@ type OperatorAPI struct {
|
||||
OperatorAPICreateNamespaceHandler operator_api.CreateNamespaceHandler
|
||||
// OperatorAPICreateTenantHandler sets the operation handler for the create tenant operation
|
||||
OperatorAPICreateTenantHandler operator_api.CreateTenantHandler
|
||||
// OperatorAPIDeleteMPIntegrationHandler sets the operation handler for the delete m p integration operation
|
||||
OperatorAPIDeleteMPIntegrationHandler operator_api.DeleteMPIntegrationHandler
|
||||
// OperatorAPIDeletePVCHandler sets the operation handler for the delete p v c operation
|
||||
OperatorAPIDeletePVCHandler operator_api.DeletePVCHandler
|
||||
// OperatorAPIDeletePodHandler sets the operation handler for the delete pod operation
|
||||
@@ -357,8 +349,6 @@ type OperatorAPI struct {
|
||||
AuthLoginOperatorHandler auth.LoginOperatorHandler
|
||||
// AuthLogoutHandler sets the operation handler for the logout operation
|
||||
AuthLogoutHandler auth.LogoutHandler
|
||||
// OperatorAPIPatchMPIntegrationHandler sets the operation handler for the patch m p integration operation
|
||||
OperatorAPIPatchMPIntegrationHandler operator_api.PatchMPIntegrationHandler
|
||||
// OperatorAPIPostMPIntegrationHandler sets the operation handler for the post m p integration operation
|
||||
OperatorAPIPostMPIntegrationHandler operator_api.PostMPIntegrationHandler
|
||||
// OperatorAPIPutTenantYAMLHandler sets the operation handler for the put tenant y a m l operation
|
||||
@@ -493,9 +483,6 @@ func (o *OperatorAPI) Validate() error {
|
||||
if o.OperatorAPICreateTenantHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.CreateTenantHandler")
|
||||
}
|
||||
if o.OperatorAPIDeleteMPIntegrationHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.DeleteMPIntegrationHandler")
|
||||
}
|
||||
if o.OperatorAPIDeletePVCHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.DeletePVCHandler")
|
||||
}
|
||||
@@ -589,9 +576,6 @@ func (o *OperatorAPI) Validate() error {
|
||||
if o.AuthLogoutHandler == nil {
|
||||
unregistered = append(unregistered, "auth.LogoutHandler")
|
||||
}
|
||||
if o.OperatorAPIPatchMPIntegrationHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.PatchMPIntegrationHandler")
|
||||
}
|
||||
if o.OperatorAPIPostMPIntegrationHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.PostMPIntegrationHandler")
|
||||
}
|
||||
@@ -771,10 +755,6 @@ func (o *OperatorAPI) initHandlerCache() {
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/mp-integration"] = operator_api.NewDeleteMPIntegration(o.context, o.OperatorAPIDeleteMPIntegrationHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/namespaces/{namespace}/tenants/{tenant}/pvc/{PVCName}"] = operator_api.NewDeletePVC(o.context, o.OperatorAPIDeletePVCHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
@@ -896,10 +876,6 @@ func (o *OperatorAPI) initHandlerCache() {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/logout"] = auth.NewLogout(o.context, o.AuthLogoutHandler)
|
||||
if o.handlers["PATCH"] == nil {
|
||||
o.handlers["PATCH"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PATCH"]["/mp-integration"] = operator_api.NewPatchMPIntegration(o.context, o.OperatorAPIPatchMPIntegrationHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
||||
@@ -1247,18 +1247,6 @@ paths:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- OperatorAPI
|
||||
delete:
|
||||
summary: Delete email registered for marketplace integration
|
||||
operationId: DeleteMPIntegration
|
||||
responses:
|
||||
204:
|
||||
description: A successful response.
|
||||
default:
|
||||
description: Generic error response.
|
||||
schema:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- OperatorAPI
|
||||
post:
|
||||
summary: Set email to register for marketplace integration
|
||||
operationId: PostMPIntegration
|
||||
@@ -1277,24 +1265,6 @@ paths:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- OperatorAPI
|
||||
patch:
|
||||
summary: Update email registered for marketplace integration
|
||||
operationId: PatchMPIntegration
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: "#/definitions/mpIntegration"
|
||||
responses:
|
||||
200:
|
||||
description: A successful response.
|
||||
default:
|
||||
description: Generic error response.
|
||||
schema:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- OperatorAPI
|
||||
|
||||
/namespaces/{namespace}/tenants/{tenant}/pvc/{PVCName}:
|
||||
delete:
|
||||
|
||||
Reference in New Issue
Block a user