Skip to content

Commit

Permalink
moving ansible host to a new systems_info object array
Browse files Browse the repository at this point in the history
  • Loading branch information
tahmidefaz committed Jul 19, 2024
1 parent fb67c0e commit 9dcc74d
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 55 deletions.
9 changes: 6 additions & 3 deletions internal/api/controllers/private/highlevelConnectionStatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ func formatConnectionResponse(satID *string, satOrgID *string, rhcClientID *stri
var formatedSatID SatelliteId
var formatedSatOrgID SatelliteOrgId
var formatedRHCClientID public.RunRecipient
var formatedAnsibleHost AnsibleHost

var formattedAnsibleHost AnsibleHost
formattedHostWithAnsibleHost := make([]HostIdWithAnsibleHost, len(hosts))

if satID != nil {
formatedSatID = SatelliteId(*satID)
Expand All @@ -130,11 +132,12 @@ func formatConnectionResponse(satID *string, satOrgID *string, rhcClientID *stri
}

if ansibleHost != nil {
formatedAnsibleHost = AnsibleHost(*ansibleHost)
formattedAnsibleHost = AnsibleHost(*ansibleHost)
}

for i, host := range hosts {
formatedHosts[i] = HostId(host)
formattedHostWithAnsibleHost[i] = HostIdWithAnsibleHost{HostId: HostId(host), AnsibleHost: formattedAnsibleHost}
}

connectionInfo := RecipientWithConnectionInfo{
Expand All @@ -145,7 +148,7 @@ func formatConnectionResponse(satID *string, satOrgID *string, rhcClientID *stri
SatOrgId: formatedSatOrgID,
Status: status,
Systems: formatedHosts,
AnsibleHost: formatedAnsibleHost,
SystemsInfo: formattedHostWithAnsibleHost,
}

return connectionInfo
Expand Down
69 changes: 35 additions & 34 deletions internal/api/controllers/private/spec.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions internal/api/controllers/private/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions internal/api/tests/private/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions internal/api/tests/private/highLevelConnectionStatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ var _ = Describe("high level connection status", func() {
satOrgID := SatelliteOrgId("5")
satelliteHost := []HostId{"c484f980-ab8d-401b-90e7-aa1d4ccf8c0e"}
directConnectHost := []HostId{"fe30b997-c15a-44a9-89df-c236c3b5c540"}
ansibleHost := AnsibleHost("test-ansible-host")

satelliteHostWithAnsibleHost := []HostIdWithAnsibleHost{{HostId: "c484f980-ab8d-401b-90e7-aa1d4ccf8c0e", AnsibleHost: ""}}
directConnectHostWithAnsibleHost := []HostIdWithAnsibleHost{{HostId: "fe30b997-c15a-44a9-89df-c236c3b5c540", AnsibleHost: "test-ansible-host"}}

payload := ApiInternalHighlevelConnectionStatusJSONRequestBody{
Hosts: []string{"c484f980-ab8d-401b-90e7-aa1d4ccf8c0e"},
Expand All @@ -52,7 +54,7 @@ var _ = Describe("high level connection status", func() {
Expect((*result)[0].SatOrgId).To(Equal(satOrgID))
Expect((*result)[0].Status).To(Equal("connected"))
Expect((*result)[0].Systems).To(Equal(satelliteHost))
Expect((*result)[0].AnsibleHost).To(BeEmpty())
Expect((*result)[0].SystemsInfo).To(Equal(satelliteHostWithAnsibleHost))

Expect((*result)[1].Recipient).To(Equal(public.RunRecipient("32af5948-301f-449a-a25b-ff34c83264a2")))
Expect((*result)[1].RecipientType).To(Equal(RecipientType_directConnect))
Expand All @@ -61,6 +63,6 @@ var _ = Describe("high level connection status", func() {
Expect((*result)[1].SatOrgId).To(BeEmpty())
Expect((*result)[1].Status).To(Equal("connected"))
Expect((*result)[1].Systems).To(Equal(directConnectHost))
Expect((*result)[1].AnsibleHost).To(Equal(ansibleHost))
Expect((*result)[1].SystemsInfo).To(Equal(directConnectHostWithAnsibleHost))
})
})
20 changes: 17 additions & 3 deletions schema/private.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,10 @@ components:
description: Indicates the current run status of the recipient
type: string
enum: [connected, disconnected, rhc_not_configured]
ansible_host:
$ref: '#/components/schemas/AnsibleHost'
systems_info:
type: array
items:
$ref: '#/components/schemas/HostIdWithAnsibleHost'
required:
- recipient
- org_id
Expand All @@ -341,7 +343,7 @@ components:
- sat_org_id
- systems
- status
- ansible_host
- systems_info


HighLevelRecipientStatus:
Expand All @@ -354,6 +356,18 @@ components:
type: string
minLength: 1

HostIdWithAnsibleHost:
description: An object containing the host id and the ansible host name
type: object
properties:
host_id:
$ref: '#/components/schemas/HostId'
ansible_host:
$ref: '#/components/schemas/AnsibleHost'
required:
- host_id
- ansible_host

SatelliteId:
description: Identifier of the Satellite instance in the uuid v4/v5 format
type: string
Expand Down

0 comments on commit 9dcc74d

Please sign in to comment.