Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-12681 remove deprecated node add endpoints #2632

Merged
28 changes: 15 additions & 13 deletions admin/commands/inventory/add_node_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Node model: {{ .Node.NodeModel }}
`)

type addNodeContainerResult struct {
Node *nodes.AddContainerNodeOKBodyContainer `json:"container"`
Node *nodes.AddNodeOKBodyContainer `json:"container"`
}

func (res *addNodeContainerResult) Result() {}
Expand All @@ -60,23 +60,25 @@ type AddNodeContainerCommand struct {

func (cmd *AddNodeContainerCommand) RunCmd() (commands.Result, error) {
customLabels := commands.ParseCustomLabels(cmd.CustomLabels)
params := &nodes.AddContainerNodeParams{
Body: nodes.AddContainerNodeBody{
NodeName: cmd.NodeName,
MachineID: cmd.MachineID,
ContainerID: cmd.ContainerID,
ContainerName: cmd.ContainerName,
Address: cmd.Address,
CustomLabels: customLabels,
params := &nodes.AddNodeParams{
Body: nodes.AddNodeBody{
Container: &nodes.AddNodeParamsBodyContainer{
NodeName: cmd.NodeName,
MachineID: cmd.MachineID,
ContainerID: cmd.ContainerID,
ContainerName: cmd.ContainerName,
Address: cmd.Address,
CustomLabels: customLabels,

Region: cmd.Region,
Az: cmd.Az,
NodeModel: cmd.NodeModel,
Region: cmd.Region,
Az: cmd.Az,
NodeModel: cmd.NodeModel,
},
},
Context: commands.Ctx,
}

resp, err := client.Default.Nodes.AddContainerNode(params)
resp, err := client.Default.Nodes.AddNode(params)
if err != nil {
return nil, err
}
Expand Down
26 changes: 14 additions & 12 deletions admin/commands/inventory/add_node_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Node model: {{ .Node.NodeModel }}
`)

type addNodeGenericResult struct {
Node *nodes.AddGenericNodeOKBodyGeneric `json:"generic"`
Node *nodes.AddNodeOKBodyGeneric `json:"generic"`
}

func (res *addNodeGenericResult) Result() {}
Expand All @@ -59,22 +59,24 @@ type AddNodeGenericCommand struct {

func (cmd *AddNodeGenericCommand) RunCmd() (commands.Result, error) {
customLabels := commands.ParseCustomLabels(cmd.CustomLabels)
params := &nodes.AddGenericNodeParams{
Body: nodes.AddGenericNodeBody{
NodeName: cmd.NodeName,
MachineID: cmd.MachineID,
Distro: cmd.Distro,
Address: cmd.Address,
CustomLabels: customLabels,
params := &nodes.AddNodeParams{
Body: nodes.AddNodeBody{
Generic: &nodes.AddNodeParamsBodyGeneric{
NodeName: cmd.NodeName,
MachineID: cmd.MachineID,
Distro: cmd.Distro,
Address: cmd.Address,
CustomLabels: customLabels,

Region: cmd.Region,
Az: cmd.Az,
NodeModel: cmd.NodeModel,
Region: cmd.Region,
Az: cmd.Az,
NodeModel: cmd.NodeModel,
},
},
Context: commands.Ctx,
}

resp, err := client.Default.Nodes.AddGenericNode(params)
resp, err := client.Default.Nodes.AddNode(params)
if err != nil {
return nil, err
}
Expand Down
20 changes: 11 additions & 9 deletions admin/commands/inventory/add_node_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Az : {{ .Node.Az }}
`)

type addNodeRemoteResult struct {
Node *nodes.AddRemoteNodeOKBodyRemote `json:"remote"`
Node *nodes.AddNodeOKBodyRemote `json:"remote"`
}

func (res *addNodeRemoteResult) Result() {}
Expand All @@ -53,19 +53,21 @@ type AddNodeRemoteCommand struct {

func (cmd *AddNodeRemoteCommand) RunCmd() (commands.Result, error) {
customLabels := commands.ParseCustomLabels(cmd.CustomLabels)
params := &nodes.AddRemoteNodeParams{
Body: nodes.AddRemoteNodeBody{
NodeName: cmd.NodeName,
Address: cmd.Address,
CustomLabels: customLabels,
params := &nodes.AddNodeParams{
Body: nodes.AddNodeBody{
Remote: &nodes.AddNodeParamsBodyRemote{
NodeName: cmd.NodeName,
Address: cmd.Address,
CustomLabels: customLabels,

Region: cmd.Region,
Az: cmd.Az,
Region: cmd.Region,
Az: cmd.Az,
},
},
Context: commands.Ctx,
}

resp, err := client.Default.Nodes.AddRemoteNode(params)
resp, err := client.Default.Nodes.AddNode(params)
if err != nil {
return nil, err
}
Expand Down
22 changes: 12 additions & 10 deletions admin/commands/inventory/add_node_remote_rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Az : {{ .Node.Az }}
`)

type addNodeRemoteRDSResult struct {
Node *nodes.AddRemoteRDSNodeOKBodyRemoteRDS `json:"remote_rds"`
Node *nodes.AddNodeOKBodyRemoteRDS `json:"remote_rds"`
}

func (res *addNodeRemoteRDSResult) Result() {}
Expand All @@ -55,19 +55,21 @@ type AddNodeRemoteRDSCommand struct {

func (cmd *AddNodeRemoteRDSCommand) RunCmd() (commands.Result, error) {
customLabels := commands.ParseCustomLabels(cmd.CustomLabels)
params := &nodes.AddRemoteRDSNodeParams{
Body: nodes.AddRemoteRDSNodeBody{
NodeName: cmd.NodeName,
Address: cmd.Address,
NodeModel: cmd.NodeModel,
Region: cmd.Region,
Az: cmd.Az,
CustomLabels: customLabels,
params := &nodes.AddNodeParams{
Body: nodes.AddNodeBody{
RemoteRDS: &nodes.AddNodeParamsBodyRemoteRDS{
NodeName: cmd.NodeName,
Address: cmd.Address,
NodeModel: cmd.NodeModel,
Region: cmd.Region,
Az: cmd.Az,
CustomLabels: customLabels,
},
},
Context: commands.Ctx,
}

resp, err := client.Default.Nodes.AddRemoteRDSNode(params)
resp, err := client.Default.Nodes.AddNode(params)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion admin/commands/inventory/add_node_remote_rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

func TestAddNodeRemoteRDS(t *testing.T) {
res := &addNodeRemoteRDSResult{
Node: &nodes.AddRemoteRDSNodeOKBodyRemoteRDS{
Node: &nodes.AddNodeOKBodyRemoteRDS{
NodeID: "/node_id/1",
NodeName: "rds1",
Address: "rds-mysql57",
Expand Down
28 changes: 16 additions & 12 deletions api-tests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,35 +177,39 @@ func RemoveAgents(t TestingT, agentIDs ...string) {
}
}

func AddGenericNode(t TestingT, nodeName string) *nodes.AddGenericNodeOKBodyGeneric {
func AddGenericNode(t TestingT, nodeName string) *nodes.AddNodeOKBodyGeneric {
t.Helper()

params := &nodes.AddGenericNodeParams{
Body: nodes.AddGenericNodeBody{
NodeName: nodeName,
Address: "10.10.10.10",
params := &nodes.AddNodeParams{
Body: nodes.AddNodeBody{
Generic: &nodes.AddNodeParamsBodyGeneric{
NodeName: nodeName,
Address: "10.10.10.10",
},
},
Context: Context,
}
res, err := client.Default.Nodes.AddGenericNode(params)
res, err := client.Default.Nodes.AddNode(params)
assert.NoError(t, err)
require.NotNil(t, res)
require.NotNil(t, res.Payload)
require.NotNil(t, res.Payload.Generic)
return res.Payload.Generic
}

func AddRemoteNode(t TestingT, nodeName string) *nodes.AddRemoteNodeOKBody {
func AddRemoteNode(t TestingT, nodeName string) *nodes.AddNodeOKBody {
t.Helper()

params := &nodes.AddRemoteNodeParams{
Body: nodes.AddRemoteNodeBody{
NodeName: nodeName,
Address: "10.10.10.10",
params := &nodes.AddNodeParams{
Body: nodes.AddNodeBody{
Remote: &nodes.AddNodeParamsBodyRemote{
NodeName: nodeName,
Address: "10.10.10.10",
},
},
Context: Context,
}
res, err := client.Default.Nodes.AddRemoteNode(params)
res, err := client.Default.Nodes.AddNode(params)
assert.NoError(t, err)
require.NotNil(t, res)
return res.Payload
Expand Down
40 changes: 21 additions & 19 deletions api-tests/inventory/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ import (
"github.com/percona/pmm/api/inventorypb/json/client/services"
)

func addRemoteRDSNode(t pmmapitests.TestingT, nodeName string) *nodes.AddRemoteRDSNodeOKBody {
func addRemoteRDSNode(t pmmapitests.TestingT, nodeName string) *nodes.AddNodeOKBody {
t.Helper()

params := &nodes.AddRemoteRDSNodeParams{
Body: nodes.AddRemoteRDSNodeBody{
NodeName: nodeName,
Address: "some-address",
Region: "region",
params := &nodes.AddNodeParams{
Body: nodes.AddNodeBody{
RemoteRDS: &nodes.AddNodeParamsBodyRemoteRDS{
NodeName: nodeName,
Address: "some-address",
Region: "region",
},
},

Context: pmmapitests.Context,
}
res, err := client.Default.Nodes.AddRemoteRDSNode(params)
res, err := client.Default.Nodes.AddNode(params)
assert.NoError(t, err)
require.NotNil(t, res)

Expand All @@ -59,19 +60,20 @@ func addRDSExporter(t pmmapitests.TestingT, body agents.AddRDSExporterBody) *age
return res.Payload
}

func addRemoteAzureDatabaseNode(t pmmapitests.TestingT, nodeName string) *nodes.AddRemoteAzureDatabaseNodeOKBody {
func addRemoteAzureDatabaseNode(t pmmapitests.TestingT, nodeName string) *nodes.AddNodeOKBody {
t.Helper()

params := &nodes.AddRemoteAzureDatabaseNodeParams{
Body: nodes.AddRemoteAzureDatabaseNodeBody{
NodeName: nodeName,
Address: "some-address",
Region: "region",
params := &nodes.AddNodeParams{
Body: nodes.AddNodeBody{
RemoteAzure: &nodes.AddNodeParamsBodyRemoteAzure{
NodeName: nodeName,
Address: "some-address",
Region: "region",
},
},

Context: pmmapitests.Context,
}
res, err := client.Default.Nodes.AddRemoteAzureDatabaseNode(params)
res, err := client.Default.Nodes.AddNode(params)
assert.NoError(t, err)
require.NotNil(t, res)

Expand Down Expand Up @@ -289,7 +291,7 @@ func assertMySQLExporterNotExists(t pmmapitests.TestingT, res *agents.ListAgents
}
}
return true
}, "There should be MySQL agent with id `%s`", mySqldExporterID)
}, "There should not be MySQL agent with id `%s`", mySqldExporterID)
}

func assertPMMAgentExists(t pmmapitests.TestingT, res *agents.ListAgentsOK, pmmAgentID string) bool {
Expand All @@ -311,7 +313,7 @@ func assertPMMAgentNotExists(t pmmapitests.TestingT, res *agents.ListAgentsOK, p
}
}
return true
}, "There should be PMM-agent with id `%s`", pmmAgentID)
}, "There should not be PMM-agent with id `%s`", pmmAgentID)
}

func assertNodeExporterExists(t pmmapitests.TestingT, res *agents.ListAgentsOK, nodeExporterID string) bool { //nolint:unparam
Expand All @@ -333,5 +335,5 @@ func assertNodeExporterNotExists(t pmmapitests.TestingT, res *agents.ListAgentsO
}
}
return true
}, "There should be Node exporter with id `%s`", nodeExporterID)
}, "There should not be Node exporter with id `%s`", nodeExporterID)
}
Loading