From bfebbe80b05e6bec5c52f5b0bcf52c8ed303be65 Mon Sep 17 00:00:00 2001 From: Juldrixx <31806759+juldrixx@users.noreply.github.com> Date: Thu, 4 May 2023 18:15:43 +0200 Subject: [PATCH] Upgrade nigoapi to v0.0.8 (#263) * feature/upgrade_nigoapi_v0.0.8 * Update changelog --- CHANGELOG.md | 2 ++ go.mod | 2 +- go.sum | 2 ++ .../registryclient/registryclient.go | 12 ++++++------ pkg/nificlient/client.go | 8 ++++---- pkg/nificlient/registryclient.go | 18 +++++++++--------- pkg/nificlient/registryclient_test.go | 14 +++++++------- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6010a2273..85d1a3fec4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,13 @@ ## Unreleased ### Added + - [PR #258](https://github.com/konpyutaika/nifikop/pull/141) - **[Helm Chart]** Upgraded helm-deployed HPA to v2 and added flowPosition to NiFiDataflow ### Changed - [PR #257](https://github.com/konpyutaika/nifikop/pull/257) - **[Operator]** Updated the operator-sdk to 1.28.0. +- [PR #263](https://github.com/konpyutaika/nifikop/pull/263) - **[NiGoApi]** Upgrade nigoapi to v0.0.8. ### Fixed Bugs diff --git a/go.mod b/go.mod index 416660d1c0..71481eb6d9 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/golang-jwt/jwt/v4 v4.5.0 github.com/imdario/mergo v0.3.14 github.com/jarcoal/httpmock v1.3.0 - github.com/konpyutaika/nigoapi v0.0.6 + github.com/konpyutaika/nigoapi v0.0.8 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.27.4 github.com/pavel-v-chernykh/keystore-go v2.1.0+incompatible diff --git a/go.sum b/go.sum index 49a1c31469..2318924014 100644 --- a/go.sum +++ b/go.sum @@ -142,6 +142,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konpyutaika/nigoapi v0.0.6 h1:tyzs05rJ1DVbwb3zhdtV/T4k8tfRkAPaydZOGfQFSL0= github.com/konpyutaika/nigoapi v0.0.6/go.mod h1:ylinFOIwDzQvM+BbiDFWmr6l2Lexs2pg/jb9znIVAv4= +github.com/konpyutaika/nigoapi v0.0.8 h1:eOp5Bj7v3PStEqmQrqETncyi5ZRg9k0ooEIZAp71GbU= +github.com/konpyutaika/nigoapi v0.0.8/go.mod h1:ylinFOIwDzQvM+BbiDFWmr6l2Lexs2pg/jb9znIVAv4= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= diff --git a/pkg/clientwrappers/registryclient/registryclient.go b/pkg/clientwrappers/registryclient/registryclient.go index 5f39a23f57..af4f43524e 100644 --- a/pkg/clientwrappers/registryclient/registryclient.go +++ b/pkg/clientwrappers/registryclient/registryclient.go @@ -1,7 +1,7 @@ package registryclient import ( - "github.com/konpyutaika/nifikop/api/v1" + v1 "github.com/konpyutaika/nifikop/api/v1" "github.com/konpyutaika/nifikop/pkg/clientwrappers" "github.com/konpyutaika/nifikop/pkg/common" "github.com/konpyutaika/nifikop/pkg/nificlient" @@ -40,7 +40,7 @@ func CreateRegistryClient(registryClient *v1.NifiRegistryClient, return nil, err } - scratchEntity := nigoapi.RegistryClientEntity{} + scratchEntity := nigoapi.FlowRegistryClientEntity{} updateRegistryClientEntity(registryClient, &scratchEntity) entity, err := nClient.CreateRegistryClient(scratchEntity) @@ -103,18 +103,18 @@ func RemoveRegistryClient(registryClient *v1.NifiRegistryClient, return clientwrappers.ErrorRemoveOperation(log, err, "Remove registry-client") } -func registryClientIsSync(registryClient *v1.NifiRegistryClient, entity *nigoapi.RegistryClientEntity) bool { +func registryClientIsSync(registryClient *v1.NifiRegistryClient, entity *nigoapi.FlowRegistryClientEntity) bool { return registryClient.Name == entity.Component.Name && registryClient.Spec.Description == entity.Component.Description && registryClient.Spec.Uri == entity.Component.Uri } -func updateRegistryClientEntity(registryClient *v1.NifiRegistryClient, entity *nigoapi.RegistryClientEntity) { +func updateRegistryClientEntity(registryClient *v1.NifiRegistryClient, entity *nigoapi.FlowRegistryClientEntity) { var defaultVersion int64 = 0 if entity == nil { - entity = &nigoapi.RegistryClientEntity{} + entity = &nigoapi.FlowRegistryClientEntity{} } if entity.Component == nil { @@ -124,7 +124,7 @@ func updateRegistryClientEntity(registryClient *v1.NifiRegistryClient, entity *n } if entity.Component == nil { - entity.Component = &nigoapi.RegistryDto{} + entity.Component = &nigoapi.FlowRegistryClientDto{} } entity.Component.Name = registryClient.Name diff --git a/pkg/nificlient/client.go b/pkg/nificlient/client.go index 20b162d158..2ae531a8e8 100644 --- a/pkg/nificlient/client.go +++ b/pkg/nificlient/client.go @@ -52,10 +52,10 @@ type NifiClient interface { RemoveClusterNodeFromClusterNodeId(nId string) error // Registry client func - GetRegistryClient(id string) (*nigoapi.RegistryClientEntity, error) - CreateRegistryClient(entity nigoapi.RegistryClientEntity) (*nigoapi.RegistryClientEntity, error) - UpdateRegistryClient(entity nigoapi.RegistryClientEntity) (*nigoapi.RegistryClientEntity, error) - RemoveRegistryClient(entity nigoapi.RegistryClientEntity) error + GetRegistryClient(id string) (*nigoapi.FlowRegistryClientEntity, error) + CreateRegistryClient(entity nigoapi.FlowRegistryClientEntity) (*nigoapi.FlowRegistryClientEntity, error) + UpdateRegistryClient(entity nigoapi.FlowRegistryClientEntity) (*nigoapi.FlowRegistryClientEntity, error) + RemoveRegistryClient(entity nigoapi.FlowRegistryClientEntity) error // Flow client func GetFlow(id string) (*nigoapi.ProcessGroupFlowEntity, error) diff --git a/pkg/nificlient/registryclient.go b/pkg/nificlient/registryclient.go index 0e312aad54..62caf80d1a 100644 --- a/pkg/nificlient/registryclient.go +++ b/pkg/nificlient/registryclient.go @@ -8,7 +8,7 @@ import ( "go.uber.org/zap" ) -func (n *nifiClient) GetRegistryClient(id string) (*nigoapi.RegistryClientEntity, error) { +func (n *nifiClient) GetRegistryClient(id string) (*nigoapi.FlowRegistryClientEntity, error) { // Get nigoapi client, favoring the one associated to the coordinator node. client, context := n.privilegeCoordinatorClient() if client == nil { @@ -17,7 +17,7 @@ func (n *nifiClient) GetRegistryClient(id string) (*nigoapi.RegistryClientEntity } // Request on Nifi Rest API to get the registy client informations - regCliEntity, rsp, body, err := client.ControllerApi.GetRegistryClient(context, id) + regCliEntity, rsp, body, err := client.ControllerApi.GetFlowRegistryClient(context, id) if err := errorGetOperation(rsp, body, err, n.log); err != nil { return nil, err @@ -26,7 +26,7 @@ func (n *nifiClient) GetRegistryClient(id string) (*nigoapi.RegistryClientEntity return ®CliEntity, nil } -func (n *nifiClient) CreateRegistryClient(entity nigoapi.RegistryClientEntity) (*nigoapi.RegistryClientEntity, error) { +func (n *nifiClient) CreateRegistryClient(entity nigoapi.FlowRegistryClientEntity) (*nigoapi.FlowRegistryClientEntity, error) { // Get nigoapi client, favoring the one associated to the coordinator node. client, context := n.privilegeCoordinatorClient() if client == nil { @@ -35,7 +35,7 @@ func (n *nifiClient) CreateRegistryClient(entity nigoapi.RegistryClientEntity) ( } // Request on Nifi Rest API to create the registry client - regCliEntity, rsp, body, err := client.ControllerApi.CreateRegistryClient(context, entity) + regCliEntity, rsp, body, err := client.ControllerApi.CreateFlowRegistryClient(context, entity) if err := errorCreateOperation(rsp, body, err, n.log); err != nil { return nil, err } @@ -43,7 +43,7 @@ func (n *nifiClient) CreateRegistryClient(entity nigoapi.RegistryClientEntity) ( return ®CliEntity, nil } -func (n *nifiClient) UpdateRegistryClient(entity nigoapi.RegistryClientEntity) (*nigoapi.RegistryClientEntity, error) { +func (n *nifiClient) UpdateRegistryClient(entity nigoapi.FlowRegistryClientEntity) (*nigoapi.FlowRegistryClientEntity, error) { // Get nigoapi client, favoring the one associated to the coordinator node. client, context := n.privilegeCoordinatorClient() if client == nil { @@ -52,7 +52,7 @@ func (n *nifiClient) UpdateRegistryClient(entity nigoapi.RegistryClientEntity) ( } // Request on Nifi Rest API to update the registry client - regCliEntity, rsp, body, err := client.ControllerApi.UpdateRegistryClient(context, entity.Id, entity) + regCliEntity, rsp, body, err := client.ControllerApi.UpdateFlowRegistryClient(context, entity.Id, entity) if err := errorUpdateOperation(rsp, body, err, n.log); err != nil { return nil, err } @@ -60,7 +60,7 @@ func (n *nifiClient) UpdateRegistryClient(entity nigoapi.RegistryClientEntity) ( return ®CliEntity, nil } -func (n *nifiClient) RemoveRegistryClient(entity nigoapi.RegistryClientEntity) error { +func (n *nifiClient) RemoveRegistryClient(entity nigoapi.FlowRegistryClientEntity) error { // Get nigoapi client, favoring the one associated to the coordinator node. client, context := n.privilegeCoordinatorClient() if client == nil { @@ -69,8 +69,8 @@ func (n *nifiClient) RemoveRegistryClient(entity nigoapi.RegistryClientEntity) e } // Request on Nifi Rest API to remove the registry client - _, rsp, body, err := client.ControllerApi.DeleteRegistryClient(context, entity.Id, - &nigoapi.ControllerApiDeleteRegistryClientOpts{ + _, rsp, body, err := client.ControllerApi.DeleteFlowRegistryClient(context, entity.Id, + &nigoapi.ControllerApiDeleteFlowRegistryClientOpts{ Version: optional.NewString(strconv.FormatInt(*entity.Revision.Version, 10)), }) diff --git a/pkg/nificlient/registryclient_test.go b/pkg/nificlient/registryclient_test.go index a9d36ee68c..b25b93e296 100644 --- a/pkg/nificlient/registryclient_test.go +++ b/pkg/nificlient/registryclient_test.go @@ -28,7 +28,7 @@ func TestGetRegistryClient(t *testing.T) { assert.Nil(entity) } -func testGetRegistryClient(t *testing.T, id string, status int) (*nigoapi.RegistryClientEntity, error) { +func testGetRegistryClient(t *testing.T, id string, status int) (*nigoapi.FlowRegistryClientEntity, error) { cluster := testClusterMock(t) @@ -69,7 +69,7 @@ func TestCreateRegistryClient(t *testing.T) { assert.Nil(entity) } -func testCreateRegistryClient(t *testing.T, entity *nigoapi.RegistryClientEntity, status int) (*nigoapi.RegistryClientEntity, error) { +func testCreateRegistryClient(t *testing.T, entity *nigoapi.FlowRegistryClientEntity, status int) (*nigoapi.FlowRegistryClientEntity, error) { cluster := testClusterMock(t) @@ -110,7 +110,7 @@ func TestUpdateRegistryClient(t *testing.T) { assert.Nil(entity) } -func testUpdateRegistryClient(t *testing.T, entity *nigoapi.RegistryClientEntity, status int) (*nigoapi.RegistryClientEntity, error) { +func testUpdateRegistryClient(t *testing.T, entity *nigoapi.FlowRegistryClientEntity, status int) (*nigoapi.FlowRegistryClientEntity, error) { cluster := testClusterMock(t) @@ -148,7 +148,7 @@ func TestRemoveRegistryClient(t *testing.T) { assert.IsType(ErrNifiClusterNotReturned200, err) } -func testRemoveRegistryClient(t *testing.T, entity *nigoapi.RegistryClientEntity, status int) error { +func testRemoveRegistryClient(t *testing.T, entity *nigoapi.FlowRegistryClientEntity, status int) error { cluster := testClusterMock(t) @@ -171,11 +171,11 @@ func testRemoveRegistryClient(t *testing.T, entity *nigoapi.RegistryClientEntity return client.RemoveRegistryClient(*entity) } -func MockRegistryClient(id, name, description, uri string) nigoapi.RegistryClientEntity { +func MockRegistryClient(id, name, description, uri string) nigoapi.FlowRegistryClientEntity { var version int64 = 10 - return nigoapi.RegistryClientEntity{ + return nigoapi.FlowRegistryClientEntity{ Id: id, - Component: &nigoapi.RegistryDto{ + Component: &nigoapi.FlowRegistryClientDto{ Id: id, Name: name, Description: description,