Skip to content

Commit

Permalink
remove EnableServerEnroll flag (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alva8756 authored Dec 1, 2023
1 parent 61f3e13 commit 92bf7b4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 34 deletions.
1 change: 0 additions & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ var cmdServer = &cobra.Command{
server.WithListenAddress(app.Config.ListenAddress),
server.WithStore(repository),
server.WithFleetDBClient(fleetDBClient),
server.EnableServerEnroll(app.Config.EnableServerEnroll),
server.WithStreamBroker(streamBroker),
server.WithConditionDefinitions(app.Config.ConditionDefinitions),
}
Expand Down
7 changes: 0 additions & 7 deletions internal/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ type Configuration struct {

// Notifications defines the properties for alerting external parties
Notifications notify.Configuration `mapstructure:"notifications"`

// EnableServerEnroll enables the server enrollment API.
EnableServerEnroll bool `mapstructure:"enable_server_enroll"`
}

// https://github.com/metal-toolbox/hollow-serverservice
Expand Down Expand Up @@ -140,10 +137,6 @@ func (a *App) envVarOverrides() error {
a.Config.Notifications.Token = a.v.GetString("notifications.token")
}

if a.v.GetString("fleetdb.enable.server.enroll") != "" {
a.Config.EnableServerEnroll = a.v.GetBool("fleetdb.enable.server.enroll")
}

if err := a.envVarServerserviceOverrides(); err != nil {
return err
}
Expand Down
9 changes: 0 additions & 9 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type Server struct {
conditionDefinitions rctypes.Definitions
repository store.Repository
fleetDBClient fleetdb.FleetDB
enableServerEnroll bool
}

// Option type sets a parameter on the Server type.
Expand All @@ -59,13 +58,6 @@ func WithFleetDBClient(client fleetdb.FleetDB) Option {
}
}

// EnableServerEnroll enables server enroll API.
func EnableServerEnroll(enable bool) Option {
return func(s *Server) {
s.enableServerEnroll = enable
}
}

// WithLogger sets the logger on the Server type.
func WithLogger(logger *logrus.Logger) Option {
return func(s *Server) {
Expand Down Expand Up @@ -117,7 +109,6 @@ func New(opts ...Option) *http.Server {
routes.WithLogger(s.logger),
routes.WithStore(s.repository),
routes.WithFleetDBClient(s.fleetDBClient),
routes.EnableServerEnroll(s.enableServerEnroll),
routes.WithStreamBroker(s.streamBroker),
routes.WithConditionDefinitions(s.conditionDefinitions),
}
Expand Down
1 change: 0 additions & 1 deletion pkg/api/v1/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func newTester(t *testing.T) (*integrationTester, finalizer) {
server.WithStore(repository),
server.WithFleetDBClient(fleetDBClient),
server.WithStreamBroker(stream),
server.EnableServerEnroll(true),
server.WithConditionDefinitions(
[]*rctypes.Definition{
{Kind: rctypes.FirmwareInstall},
Expand Down
1 change: 0 additions & 1 deletion pkg/api/v1/routes/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func mockserver(t *testing.T, logger *logrus.Logger, fleetDBClient fleetdb.Fleet
WithLogger(logger),
WithStore(repository),
WithFleetDBClient(fleetDBClient),
EnableServerEnroll(true),
WithConditionDefinitions(
[]*rctypes.Definition{
{Kind: rctypes.FirmwareInstall},
Expand Down
21 changes: 6 additions & 15 deletions pkg/api/v1/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type Routes struct {
streamBroker events.Stream
conditionDefinitions rctypes.Definitions
logger *logrus.Logger
enableServerEnroll bool
}

// Option type sets a parameter on the Routes type.
Expand All @@ -55,13 +54,6 @@ func WithFleetDBClient(client fleetdb.FleetDB) Option {
}
}

// EnableServerEnroll enables server enroll API.
func EnableServerEnroll(enable bool) Option {
return func(r *Routes) {
r.enableServerEnroll = enable
}
}

// WithStreamBroker sets the event stream broker.
func WithStreamBroker(broker events.Stream) Option {
return func(r *Routes) {
Expand Down Expand Up @@ -137,13 +129,12 @@ func (r *Routes) composeAuthHandler(scopes []string) gin.HandlerFunc {

func (r *Routes) Routes(g *gin.RouterGroup) {
servers := g.Group("/servers/:uuid")
if r.enableServerEnroll {
serverEnroll := g.Group("/serverEnroll")
serverEnroll.POST("/:uuid", r.composeAuthHandler(createScopes("server")), wrapAPICall(r.serverEnroll))
// Create a new server ID when uuid is not provided.
serverEnroll.POST("/", r.composeAuthHandler(createScopes("server")), wrapAPICall(r.serverEnroll))
servers.DELETE("", r.composeAuthHandler(createScopes("server")), wrapAPICall(r.serverDelete))
}

serverEnroll := g.Group("/serverEnroll")
serverEnroll.POST("/:uuid", r.composeAuthHandler(createScopes("server")), wrapAPICall(r.serverEnroll))
// Create a new server ID when uuid is not provided.
serverEnroll.POST("/", r.composeAuthHandler(createScopes("server")), wrapAPICall(r.serverEnroll))
servers.DELETE("", r.composeAuthHandler(createScopes("server")), wrapAPICall(r.serverDelete))

{
// Combined API for firmwareInstall
Expand Down

0 comments on commit 92bf7b4

Please sign in to comment.