Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Connection to EventDataPlatform #1212

Merged
merged 7 commits into from
Apr 27, 2020
Merged

Conversation

jasiu001
Copy link
Contributor

Description

Changes proposed in this pull request:

  • Add EventDataPlatform client
  • Implement EDP registration step
  • Implement EDP deregistration step

@jasiu001 jasiu001 added kind/feature Categorizes issue or PR as related to a new feature. area/management-plane Related to all activities around Management Plane labels Apr 22, 2020
@jasiu001 jasiu001 added this to the Sprint_Gopher_41 milestone Apr 22, 2020
@ksputo ksputo self-assigned this Apr 23, 2020
namespace: "kyma-dev"
environment: "dev"
required: false
disabled: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should have this set to true by default, because we use overrides with other necessary values anyway

@@ -197,6 +202,11 @@ func main() {
step: provisioning.NewProvideLmsTenantStep(lmsTenantManager, db.Operations()),
disabled: cfg.LMS.Disabled,
},
{
weight: 1,
step: provisioning.NewEDPRegistration(db.Operations(), edpClient, cfg.EDP),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to rename it to be consistent with convention

Suggested change
step: provisioning.NewEDPRegistration(db.Operations(), edpClient, cfg.EDP),
step: provisioning.NewEDPRegistrationStep(db.Operations(), edpClient, cfg.EDP),

}{
{
weight: 1,
step: deprovisioning.NewAvsEvaluationsRemovalStep(avsDel, db.Operations(), externalEvalAssistant, internalEvalAssistant),
},
{
weight: 1,
step: deprovisioning.NewEDPDeregistration(edpClient, cfg.EDP),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above:

Suggested change
step: deprovisioning.NewEDPDeregistration(edpClient, cfg.EDP),
step: deprovisioning.NewEDPDeregistrationStep(edpClient, cfg.EDP),

if err != nil {
return []MetadataItem{}, errors.Wrap(err, "while requesting about dataTenant metadata")
}
defer c.closeResponseBody(response)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the same pattern as used in this PR: #1190

same suggestion for other occurrences

return kebError.NewTemporaryError("EDP server returns failed status %s", responseLog(response))
}

c.log.Errorf("EDP server notsupported response %s: %s", responseLog(response), body)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
c.log.Errorf("EDP server notsupported response %s: %s", responseLog(response), body)
c.log.Errorf("EDP server not supported response %s: %s", responseLog(response), body)

Disabled bool
}

func CreateEDPAdminClient(config Config, log logrus.FieldLogger) *Client {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot we make it simpler and just do that in NewClient method? because for me it's not a builder but normal constructor 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to avoid creating oAuth client inside EDP client constructor, thanks DI I can simply in test inject client from httptest.NewServer, I couldn't find oAuth client test. If you see any simple solution about how to create oAuth inside EDP client and easily handle it in the test not implement all oAuth paths then I am open to suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss that f2f. I know some trick for such tests :)


func CreateEDPAdminClient(config Config, log logrus.FieldLogger) *Client {
data := url.Values{}
data.Add("grant_type", "client_credentials")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed - it is already set by clientcredentials client

func CreateEDPAdminClient(config Config, log logrus.FieldLogger) *Client {
data := url.Values{}
data.Add("grant_type", "client_credentials")
data.Add("scope", "edp-namespace.read edp-namespace.update")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use Scope field on clientcredentials.Config

client := NewClient(config, testServer.Client(), logrus.New())

// when
err := client.CreateDataTenant(DataTenantPayload{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing impl to

func (c *Client) CreateDataTenant(data DataTenantPayload) error {
	return nil
}

and test still green :/

same problems with other tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed TestClient_CreateDataTenant and TestClient_DeleteDataTenant

AdminURL: testServer.URL,
Namespace: testNamespace,
}
client := NewClient(config, testServer.Client(), logrus.New())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use logger.NewLogDummy(). Because right now it produces logs which only mess the test output. If you want to assert that given msg was logged then use logger.NewLogSpy(). The same suggestion for all others occurrences

var metadata []MetadataItem
err = json.NewDecoder(response.Body).Decode(&metadata)
if err != nil {
return metadata, errors.Wrap(err, "while decoding dataTenant metadata response")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the best practice is to return zero-value in case of error

func (c *Client) processResponse(response *http.Response) error {
byteBody, err := ioutil.ReadAll(response.Body)
if err != nil {
return errors.Wrapf(err, "while reading response body")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add also info about status code as this can be helpful

Comment on lines 43 to 44
labels:
{{ include "kyma-env-broker.labels" . | indent 4 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
labels:
{{ include "kyma-env-broker.labels" . | indent 4 }}
labels: {{ include "kyma-env-broker.labels" . | nindent 4 }}

IMO it's better because thanks to the nindent we do not need to take care of the proper indent before the {{

and we had already a few problems with wrong indent in past.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/management-plane Related to all activities around Management Plane kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants