Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
rverdile committed Jan 21, 2025
1 parent ae1b9f1 commit e4fa89d
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 14 deletions.
8 changes: 8 additions & 0 deletions configs/config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ clients:
rbac: 1m
pulp_content_path: 1h
subscription_check: 1h
feature_service:
server: https://subscription.stage.api.redhat.com/svcrest/subscription/v5/features
client_cert:
client_key:
ca_cert:
client_cert_path:
client_key_path:
ca_cert_path:

# Configuration for the mocks
mocks:
Expand Down
40 changes: 40 additions & 0 deletions deployments/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ objects:
name: content-sources-candlepin
key: ca
optional: true
- name: CLIENTS_FEATURE_SERVICE_SERVER
value: ${CLIENTS_FEATURE_SERVICE_SERVER}
- name: CLIENTS_FEATURE_SERVICE_CLIENT_CERT
valueFrom:
secretKeyRef:
name: content-sources-candlepin
key: cert
optional: true
- name: CLIENTS_FEATURE_SERVICE_CLIENT_KEY
valueFrom:
secretKeyRef:
name: content-sources-candlepin
key: key
optional: true
- name: CLIENTS_FEATURE_SERVICE_CA_CERT
valueFrom:
secretKeyRef:
name: content-sources-candlepin
key: ca
optional: true
resources:
limits:
cpu: ${CPU_LIMIT_CS_WORKER}
Expand Down Expand Up @@ -316,6 +336,26 @@ objects:
name: content-sources-candlepin
key: ca
optional: true
- name: CLIENTS_FEATURE_SERVICE_SERVER
value: ${CLIENTS_FEATURE_SERVICE_SERVER}
- name: CLIENTS_FEATURE_SERVICE_CLIENT_CERT
valueFrom:
secretKeyRef:
name: content-sources-candlepin
key: cert
optional: true
- name: CLIENTS_FEATURE_SERVICE_CLIENT_KEY
valueFrom:
secretKeyRef:
name: content-sources-candlepin
key: key
optional: true
- name: CLIENTS_FEATURE_SERVICE_CA_CERT
valueFrom:
secretKeyRef:
name: content-sources-candlepin
key: ca
optional: true
resources:
limits:
cpu: ${CPU_LIMIT_CS_API}
Expand Down
2 changes: 1 addition & 1 deletion pkg/admin_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (ac adminClientImpl) ListFeatures(ctx context.Context) (FeaturesResponse, i
statusCode := http.StatusInternalServerError
var err error

req, err := http.NewRequestWithContext(ctx, http.MethodGet, config.Get().Clients.SubsAsFeatures.Server, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, config.Get().Clients.FeatureService.Server, nil)
if err != nil {
return FeaturesResponse{}, 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/admin_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type pulpProgressReportResponse struct {
Suffix zest.NullableString `json:"suffix,omitempty"`
}

type SubsAsFeaturesResponse struct {
type ListFeaturesResponse struct {
Features []string `json:"features"`
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/config/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func certPool(caCert []byte) (*x509.CertPool, error) {
pool := x509.NewCertPool()
ok := pool.AppendCertsFromPEM(caCert)
if !ok {
return nil, fmt.Errorf("could not parse candlepin ca cert")
return nil, fmt.Errorf("could not parse ca cert")
}
return pool, nil
}
Expand All @@ -100,27 +100,27 @@ type SubsAsFeatsCertUser struct {
}

func (c *SubsAsFeatsCertUser) ClientCert() string {
return Get().Clients.SubsAsFeatures.ClientCert
return Get().Clients.FeatureService.ClientCert
}

func (c *SubsAsFeatsCertUser) ClientKey() string {
return Get().Clients.SubsAsFeatures.ClientKey
return Get().Clients.FeatureService.ClientKey
}

func (c *SubsAsFeatsCertUser) CACert() string {
return Get().Clients.SubsAsFeatures.CACert
return Get().Clients.FeatureService.CACert
}

func (c *SubsAsFeatsCertUser) CACertPath() string {
return Get().Clients.SubsAsFeatures.CACertPath
return Get().Clients.FeatureService.CACertPath
}

func (c *SubsAsFeatsCertUser) ClientCertPath() string {
return Get().Clients.SubsAsFeatures.ClientCertPath
return Get().Clients.FeatureService.ClientCertPath
}

func (c *SubsAsFeatsCertUser) ClientKeyPath() string {
return Get().Clients.SubsAsFeatures.ClientKeyPath
return Get().Clients.FeatureService.ClientKeyPath
}

type CandlepinCertUser struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Clients struct {
Pulp Pulp `mapstructure:"pulp"`
Redis Redis `mapstructure:"redis"`
Candlepin Candlepin `mapstructure:"candlepin"`
SubsAsFeatures SubsAsFeatures `mapstructure:"subs_as_features"`
FeatureService FeatureService `mapstructure:"feature_service"`
}

type Mocks struct {
Expand Down Expand Up @@ -97,7 +97,7 @@ type Candlepin struct {
DevelOrg bool `mapstructure:"devel_org"` // For use only in dev envs
}

type SubsAsFeatures struct {
type FeatureService struct {
Server string
ClientCert string `mapstructure:"client_cert"`
ClientKey string `mapstructure:"client_key"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/handler/admin_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (adminTaskHandler *AdminTaskHandler) listFeatures(c echo.Context) error {
return ce.NewErrorResponse(statusCode, "Error listing features", err.Error())
}

subsAsFeatResp := api.SubsAsFeaturesResponse{}
subsAsFeatResp := api.ListFeaturesResponse{}
for _, content := range resp.Content {
subsAsFeatResp.Features = append(subsAsFeatResp.Features, content.Name)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/handler/admin_tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ func (suite *AdminTasksSuite) TestListFeatures() {
req.Header.Set(api.IdentityHeader, test_handler.EncodedIdentity(t))

listFeaturesExpected := admin_client.FeaturesResponse{Content: []admin_client.Content{{Name: "test_feature"}}}
expected := api.SubsAsFeaturesResponse{Features: []string{"test_feature"}}
expected := api.ListFeaturesResponse{Features: []string{"test_feature"}}
suite.clientMock.On("ListFeatures", test.MockCtx()).Return(listFeaturesExpected, http.StatusOK, nil)

code, body, err := suite.serveAdminTasksRouter(req, true, true)
assert.NoError(t, err)

var response api.SubsAsFeaturesResponse
var response api.ListFeaturesResponse
err = json.Unmarshal(body, &response)
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, code)
Expand Down

0 comments on commit e4fa89d

Please sign in to comment.