Skip to content

Commit

Permalink
Upgrade nigoapi to v0.0.8 (konpyutaika#263)
Browse files Browse the repository at this point in the history
* feature/upgrade_nigoapi_v0.0.8

* Update changelog
  • Loading branch information
juldrixx authored May 4, 2023
1 parent 40182b0 commit bfebbe8
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
12 changes: 6 additions & 6 deletions pkg/clientwrappers/registryclient/registryclient.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pkg/nificlient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions pkg/nificlient/registryclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -26,7 +26,7 @@ func (n *nifiClient) GetRegistryClient(id string) (*nigoapi.RegistryClientEntity
return &regCliEntity, 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 {
Expand All @@ -35,15 +35,15 @@ 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
}

return &regCliEntity, 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 {
Expand All @@ -52,15 +52,15 @@ 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
}

return &regCliEntity, 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 {
Expand All @@ -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)),
})

Expand Down
14 changes: 7 additions & 7 deletions pkg/nificlient/registryclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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,
Expand Down

0 comments on commit bfebbe8

Please sign in to comment.