Skip to content

Commit 2018c8b

Browse files
committed
refactor(subscr): move to pro dir
1 parent 586888b commit 2018c8b

File tree

8 files changed

+46
-31
lines changed

8 files changed

+46
-31
lines changed

api/router.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"embed"
66
"fmt"
7-
"github.com/semaphoreui/semaphore/services/interfaces"
7+
"github.com/semaphoreui/semaphore/pro_interfaces"
88
"net/http"
99
"os"
1010
"path"
@@ -18,7 +18,6 @@ import (
1818

1919
"github.com/semaphoreui/semaphore/api/debug"
2020
"github.com/semaphoreui/semaphore/pkg/tz"
21-
proSubscriptions "github.com/semaphoreui/semaphore/pro/api/subscriptions"
2221
log "github.com/sirupsen/logrus"
2322

2423
"github.com/semaphoreui/semaphore/api/runners"
@@ -92,7 +91,7 @@ func Route(
9291
secretStorageService server.SecretStorageService,
9392
accessKeyService server.AccessKeyService,
9493
environmentService server.EnvironmentService,
95-
subscriptionService interfaces.SubscriptionService,
94+
subscriptionService pro_interfaces.SubscriptionService,
9695
) *mux.Router {
9796

9897
projectController := &projects.ProjectController{ProjectService: projectService}
@@ -106,6 +105,7 @@ func Route(
106105
terraformController := proApi.NewTerraformController(encryptionService, terraformStore)
107106
userController := NewUserController(subscriptionService)
108107
usersController := NewUsersController(subscriptionService)
108+
subscriptionController := proApi.NewSubscriptionController()
109109

110110
r := mux.NewRouter()
111111
r.NotFoundHandler = http.HandlerFunc(servePublic)
@@ -177,8 +177,8 @@ func Route(
177177

178178
authenticatedAPI.Path("/info").HandlerFunc(getSystemInfo).Methods("GET", "HEAD")
179179

180-
authenticatedAPI.Path("/subscription").HandlerFunc(proSubscriptions.Activate).Methods("POST")
181-
authenticatedAPI.Path("/subscription").HandlerFunc(proSubscriptions.GetSubscription).Methods("GET")
180+
authenticatedAPI.Path("/subscription").HandlerFunc(subscriptionController.Activate).Methods("POST")
181+
authenticatedAPI.Path("/subscription").HandlerFunc(subscriptionController.GetSubscription).Methods("GET")
182182

183183
authenticatedAPI.Path("/projects").HandlerFunc(projects.GetProjects).Methods("GET", "HEAD")
184184
authenticatedAPI.Path("/projects").HandlerFunc(projectsController.AddProject).Methods("POST")

api/user.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import (
66
"github.com/gorilla/mux"
77
"github.com/semaphoreui/semaphore/api/helpers"
88
"github.com/semaphoreui/semaphore/db"
9-
"github.com/semaphoreui/semaphore/services/interfaces"
9+
"github.com/semaphoreui/semaphore/pro_interfaces"
1010
"github.com/semaphoreui/semaphore/util"
1111
"io"
1212
"net/http"
1313
"strings"
1414
)
1515

1616
type UserController struct {
17-
subscriptionService interfaces.SubscriptionService
17+
subscriptionService pro_interfaces.SubscriptionService
1818
}
1919

20-
func NewUserController(subscriptionService interfaces.SubscriptionService) *UserController {
20+
func NewUserController(subscriptionService pro_interfaces.SubscriptionService) *UserController {
2121
return &UserController{
2222
subscriptionService: subscriptionService,
2323
}

api/users.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/pquerna/otp/totp"
88
"github.com/semaphoreui/semaphore/api/helpers"
99
"github.com/semaphoreui/semaphore/db"
10-
"github.com/semaphoreui/semaphore/services/interfaces"
10+
"github.com/semaphoreui/semaphore/pro_interfaces"
1111
log "github.com/sirupsen/logrus"
1212
"image/png"
1313
"net/http"
@@ -16,10 +16,10 @@ import (
1616
)
1717

1818
type UsersController struct {
19-
subscriptionService interfaces.SubscriptionService
19+
subscriptionService pro_interfaces.SubscriptionService
2020
}
2121

22-
func NewUsersController(subscriptionService interfaces.SubscriptionService) *UsersController {
22+
func NewUsersController(subscriptionService pro_interfaces.SubscriptionService) *UsersController {
2323
return &UsersController{
2424
subscriptionService: subscriptionService,
2525
}

pro/api/subscriptions.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package api
2+
3+
import (
4+
"github.com/semaphoreui/semaphore/pro_interfaces"
5+
"net/http"
6+
)
7+
8+
func NewSubscriptionController() pro_interfaces.SubscriptionController {
9+
return &subscriptionControllerImpl{}
10+
}
11+
12+
type subscriptionControllerImpl struct {
13+
}
14+
15+
func (ctrl *subscriptionControllerImpl) Activate(w http.ResponseWriter, r *http.Request) {}
16+
17+
func (ctrl *subscriptionControllerImpl) GetSubscription(w http.ResponseWriter, r *http.Request) {}

pro/api/subscriptions/subscriptions.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

pro/services/server/subscription_svc.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package server
22

33
import (
4-
"github.com/semaphoreui/semaphore/services/interfaces"
4+
"github.com/semaphoreui/semaphore/db"
5+
"github.com/semaphoreui/semaphore/pro_interfaces"
56
)
67

7-
func NewSubscriptionService() interfaces.SubscriptionService {
8-
return nil
8+
func NewSubscriptionService(userRepo db.UserManager, optionsRepo db.OptionsManager) pro_interfaces.SubscriptionService {
9+
return &SubscriptionServiceImpl{}
910
}
1011

1112
type SubscriptionServiceImpl struct {
@@ -18,3 +19,7 @@ func (s *SubscriptionServiceImpl) HasActiveSubscription() bool {
1819
func (s *SubscriptionServiceImpl) CanAddProUser() (ok bool, err error) {
1920
return false, nil
2021
}
22+
23+
func (s *SubscriptionServiceImpl) StartValidationCron() {
24+
25+
}

pro_interfaces/subscription_ctl.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package pro_interfaces
2+
3+
import "net/http"
4+
5+
type SubscriptionController interface {
6+
GetSubscription(w http.ResponseWriter, r *http.Request)
7+
Activate(w http.ResponseWriter, r *http.Request)
8+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package interfaces
1+
package pro_interfaces
22

33
type SubscriptionService interface {
44
HasActiveSubscription() bool
55
CanAddProUser() (ok bool, err error)
6+
StartValidationCron()
67
}

0 commit comments

Comments
 (0)