Skip to content

Commit 85c1118

Browse files
authored
Merge pull request #172 from replicatedhq/jelena-vendor-api-kots-channel
Using vendor-api instead graphql-api when getting channel
2 parents a33bbcd + b840de3 commit 85c1118

File tree

2 files changed

+12
-81
lines changed

2 files changed

+12
-81
lines changed

client/channel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (c *Client) GetChannel(appID string, appType string, channelID string) (*ch
4848
} else if appType == "ship" {
4949
return c.ShipClient.GetChannel(appID, channelID)
5050
} else if appType == "kots" {
51-
return c.KotsClient.GetChannel(appID, channelID)
51+
return c.KotsHTTPClient.GetChannel(appID, channelID)
5252
}
5353
return nil, nil, errors.New("unknown app type")
5454

pkg/kotsclient/channel.go

Lines changed: 11 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ import (
1212
"github.com/replicatedhq/replicated/pkg/types"
1313
)
1414

15-
type GraphQLResponseGetChannel struct {
16-
Data *KotsGetChannelData `json:"data,omitempty"`
17-
Errors []graphql.GQLError `json:"errors,omitempty"`
18-
}
19-
2015
type GraphQLResponseCreateChannel struct {
2116
Data *KotsCreateChannelData `json:"data,omitempty"`
2217
Errors []graphql.GQLError `json:"errors,omitempty"`
@@ -172,85 +167,21 @@ func (c *GraphQLClient) CreateChannel(appID string, name string, description str
172167

173168
}
174169

175-
const getKotsChannel = `
176-
query getKotsChannel($channelId: ID!) {
177-
getKotsChannel(channelId: $channelId) {
178-
id
179-
appId
180-
name
181-
description
182-
channelIcon
183-
channelSequence
184-
releaseSequence
185-
currentVersion
186-
currentReleaseDate
187-
installInstructions
188-
numReleases
189-
adoptionRate {
190-
releaseSequence
191-
semver
192-
count
193-
percent
194-
totalOnChannel
195-
}
196-
customers {
197-
id
198-
name
199-
avatar
200-
actions {
201-
shipApplyDocker
202-
}
203-
installationId
204-
shipInstallStatus {
205-
status
206-
updatedAt
207-
}
208-
}
209-
githubRef {
210-
owner
211-
repoFullName
212-
branch
213-
path
214-
}
215-
extraLintRules
216-
created
217-
updated
218-
isDefault
219-
isArchived
220-
releases {
221-
semver
222-
releaseNotes
223-
created
224-
updated
225-
releasedAt
226-
sequence
227-
channelSequence
228-
airgapBuildStatus
229-
}
230-
}
231-
}
232-
`
170+
func (c *VendorV3Client) GetChannel(appID string, channelID string) (*channels.AppChannel, []channels.ChannelRelease, error) {
171+
var response = KotsGetChannelData{}
233172

234-
func (c *GraphQLClient) GetChannel(appID string, channelID string) (*channels.AppChannel, []channels.ChannelRelease, error) {
235-
response := GraphQLResponseGetChannel{}
236-
237-
request := graphql.Request{
238-
Query: getKotsChannel,
239-
Variables: map[string]interface{}{
240-
"appID": appID,
241-
"channelId": channelID,
242-
},
243-
}
244-
if err := c.ExecuteRequest(request, &response); err != nil {
245-
return nil, nil, err
173+
url := fmt.Sprintf("/v3/app/%s/channel/%s", appID, channelID)
174+
err := c.DoJSON("GET", url, http.StatusOK, nil, &response)
175+
if err != nil {
176+
return nil, nil, errors.Wrap(err, "get app channel")
246177
}
247178

248179
channelDetail := channels.AppChannel{
249-
Id: response.Data.KotsChannel.ID,
250-
Name: response.Data.KotsChannel.Name,
251-
Description: response.Data.KotsChannel.Description,
252-
ReleaseLabel: response.Data.KotsChannel.CurrentVersion,
253-
ReleaseSequence: response.Data.KotsChannel.ReleaseSequence,
180+
Id: response.KotsChannel.ID,
181+
Name: response.KotsChannel.Name,
182+
Description: response.KotsChannel.Description,
183+
ReleaseLabel: response.KotsChannel.CurrentVersion,
184+
ReleaseSequence: response.KotsChannel.ReleaseSequence,
254185
}
255186
return &channelDetail, nil, nil
256187
}

0 commit comments

Comments
 (0)