Ver código fonte

Add more docstrings

Mauricio Araujo 2 anos atrás
pai
commit
776e4dfe08

+ 2 - 0
api/server/handlers/billing/create.go

@@ -12,10 +12,12 @@ import (
 	"github.com/porter-dev/porter/internal/models"
 )
 
+// CreateBillingHandler is a handler for creating payment methods
 type CreateBillingHandler struct {
 	handlers.PorterHandlerWriter
 }
 
+// NewCreateBillingCustomerIfNotExists will create a new CreateBillingHandler
 func NewCreateBillingHandler(
 	config *config.Config,
 	decoderValidator shared.RequestDecoderValidator,

+ 7 - 4
api/server/handlers/billing/customer.go

@@ -12,21 +12,24 @@ import (
 	"github.com/porter-dev/porter/internal/models"
 )
 
-type CreateBillingCustomerIfNotExists struct {
+// CreateBillingCustomerIfNotExistsHandler will create a new handler
+// for creating customers in the billing provider
+type CreateBillingCustomerIfNotExistsHandler struct {
 	handlers.PorterHandlerReadWriter
 }
 
+// NewCreateBillingCustomerIfNotExists will create a new CreateBillingCustomerIfNotExists
 func NewCreateBillingCustomerIfNotExists(
 	config *config.Config,
 	decoderValidator shared.RequestDecoderValidator,
 	writer shared.ResultWriter,
-) *CreateBillingCustomerIfNotExists {
-	return &CreateBillingCustomerIfNotExists{
+) *CreateBillingCustomerIfNotExistsHandler {
+	return &CreateBillingCustomerIfNotExistsHandler{
 		PorterHandlerReadWriter: handlers.NewDefaultPorterHandler(config, decoderValidator, writer),
 	}
 }
 
-func (c *CreateBillingCustomerIfNotExists) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+func (c *CreateBillingCustomerIfNotExistsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	proj, _ := r.Context().Value(types.ProjectScope).(*models.Project)
 
 	request := &types.CreateBillingCustomerRequest{}

+ 2 - 0
api/server/handlers/billing/delete.go

@@ -12,10 +12,12 @@ import (
 	"github.com/porter-dev/porter/api/types"
 )
 
+// DeleteBillingHandler is a handler for deleting payment methods
 type DeleteBillingHandler struct {
 	handlers.PorterHandlerWriter
 }
 
+// NewDeleteBillingHandler will create a new DeleteBillingHandler
 func NewDeleteBillingHandler(
 	config *config.Config,
 	writer shared.ResultWriter,

+ 2 - 0
api/server/handlers/billing/list.go

@@ -12,10 +12,12 @@ import (
 	"github.com/porter-dev/porter/internal/models"
 )
 
+// ListBillingHandler is a handler for listing payment methods
 type ListBillingHandler struct {
 	handlers.PorterHandlerWriter
 }
 
+// NewListBillingHandler will create a new ListBillingHandler
 func NewListBillingHandler(
 	config *config.Config,
 	writer shared.ResultWriter,

+ 9 - 0
internal/billing/billing.go

@@ -44,38 +44,47 @@ type BillingManager interface {
 // NoopBillingManager performs no billing operations
 type NoopBillingManager struct{}
 
+// CreateCustomer is a no-op
 func (s *NoopBillingManager) CreateCustomer(userEmail string, proj *models.Project) (customerID string, err error) {
 	return "", nil
 }
 
+// ListPaymentMethod is a no-op
 func (s *NoopBillingManager) ListPaymentMethod(proj *models.Project) (paymentMethods []types.PaymentMethod, err error) {
 	return []types.PaymentMethod{}, nil
 }
 
+// CreatePaymentMethod is a no-op
 func (s *NoopBillingManager) CreatePaymentMethod(proj *models.Project) (clientSecret string, err error) {
 	return "", nil
 }
 
+// DeletePaymentMethod is a no-op
 func (s *NoopBillingManager) DeletePaymentMethod(paymentMethodID string) (err error) {
 	return nil
 }
 
+// CreateTeam is a no-op
 func (n *NoopBillingManager) CreateTeam(user *models.User, proj *models.Project) (teamID string, err error) {
 	return fmt.Sprintf("%d", proj.ID), nil
 }
 
+// DeleteTeam is a no-op
 func (n *NoopBillingManager) DeleteTeam(user *models.User, proj *models.Project) (err error) {
 	return nil
 }
 
+// GetRedirectURI is a no-op
 func (n *NoopBillingManager) GetRedirectURI(user *models.User, proj *models.Project) (url string, err error) {
 	return "", nil
 }
 
+// ParseProjectUsageFromWebhook is a no-op
 func (n *NoopBillingManager) ParseProjectUsageFromWebhook(payload []byte) (*models.ProjectUsage, *types.FeatureFlags, error) {
 	return nil, nil, nil
 }
 
+// VerifySignature is a no-op
 func (n *NoopBillingManager) VerifySignature(signature string, body []byte) bool {
 	return false
 }

+ 1 - 4
internal/billing/stripe..go

@@ -89,30 +89,27 @@ func (s *StripeBillingManager) DeletePaymentMethod(paymentMethodID string) (err
 }
 
 // TODO: remove these methods when the billing tech-debt is cleaned
+
 // CreateTeam
 func (s *StripeBillingManager) CreateTeam(user *models.User, proj *models.Project) (teamID string, err error) {
 	return fmt.Sprintf("%d", proj.ID), nil
 }
 
-// TODO: remove these methods when the billing tech-debt is cleaned
 // DeleteTeam
 func (s *StripeBillingManager) DeleteTeam(user *models.User, proj *models.Project) (err error) {
 	return nil
 }
 
-// TODO: remove these methods when the billing tech-debt is cleaned
 // GetRedirectURI
 func (s *StripeBillingManager) GetRedirectURI(user *models.User, proj *models.Project) (url string, err error) {
 	return "", nil
 }
 
-// TODO: remove these methods when the billing tech-debt is cleaned
 // ParseProjectUsageFromWebhook
 func (s *StripeBillingManager) ParseProjectUsageFromWebhook(payload []byte) (*models.ProjectUsage, *types.FeatureFlags, error) {
 	return nil, nil, nil
 }
 
-// TODO: remove these methods when the billing tech-debt is cleaned
 // VerifySignature
 func (s *StripeBillingManager) VerifySignature(signature string, body []byte) bool {
 	return false