Skip to content

Commit

Permalink
Disable seats apis (RedHatInsights#167)
Browse files Browse the repository at this point in the history
* disable seats apis by default
* only instaniate seats related clients if seats apis are enabled
* update readme to mention seats apis are disabled
  • Loading branch information
dagbay-rh authored Mar 6, 2024
1 parent 17776ed commit 4bbd2e5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Entitlements service serves as a proxy to various backend Red Hat IT services. It performs the following functions:
* `/subscriptions`: query IT for a list of subscriptions that a user is entitled to
* `/compliance`: query IT for user compliance checks
* `/seats`: query AMS from OCM to read, assign, and delete user subscriptions (a seat is considered an Openshift subscription assignable to a user)
* ~~`/seats`~~: query AMS from OCM to read, assign, and delete user subscriptions (a seat is considered an Openshift subscription assignable to a user)
* __OBSOLETE__ - these apis are no longer enabled in prod

## SKU/Bundle changes
- The `/bundles/bundles.example.yml` file in this repo is for **local testing only**
Expand Down
1 change: 1 addition & 0 deletions config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func initialize() {
options.SetDefault(Keys.SubsCacheItemPrune, 50)
options.SetDefault(Keys.AMSAcctMgmt11Msg, "Please have this user log into \"https://console.redhat.com/openshift\" to grant their account the required permissions, or try again later.")
options.SetDefault(Keys.ITServicesTimeoutSeconds, 10)
options.SetDefault(Keys.DisableSeatManager, true) // this feature is obsolete, see https://issues.redhat.com/browse/RHCLOUD-30697

options.SetEnvPrefix("ENT")
options.AutomaticEnv()
Expand Down
23 changes: 12 additions & 11 deletions server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,24 @@ func DoRoutes() chi.Router {
r.Use(sentryMiddleware.Handle)

configOptions := config.GetConfig().Options
debug := configOptions.GetBool(config.Keys.Debug)
amsClient, err := ams.NewClient(debug)

if err != nil {
panic(fmt.Sprintf("Error constructing ams client: [%s]", err))
}

bopClient, err := bop.NewClient(debug)
if err != nil {
panic(fmt.Sprintf("Error constructing bop client: [%s]", err))
}

// This is odd, but the generated code will register handlers
// and return a http.Handler. This is normally used with .Mount,
// but since only part of the server is using code gen this is
// a way to hack it in
if !configOptions.GetBool(config.Keys.DisableSeatManager) {
debug := configOptions.GetBool(config.Keys.Debug)

amsClient, err := ams.NewClient(debug)
if err != nil {
panic(fmt.Sprintf("Error constructing ams client: [%s]", err))
}

bopClient, err := bop.NewClient(debug)
if err != nil {
panic(fmt.Sprintf("Error constructing bop client: [%s]", err))
}

seatManagerApi := controllers.NewSeatManagerApi(amsClient, bopClient)
api.HandlerFromMuxWithBaseURL(seatManagerApi, r.With(identity.EnforceIdentity), "/api/entitlements/v1")
}
Expand Down

0 comments on commit 4bbd2e5

Please sign in to comment.