@@ -8,16 +8,16 @@ import (
88
99 "github.com/pkg/errors"
1010 "github.com/replicatedcom/support-bundle/pkg/collect/bundle"
11- "github.com/replicatedcom/support-bundle/pkg/collect/graphql"
1211 "github.com/replicatedcom/support-bundle/pkg/collect/lifecycle"
12+ "github.com/replicatedcom/support-bundle/pkg/collect/marketapi"
1313 "github.com/replicatedcom/support-bundle/pkg/collect/spec"
1414 "github.com/replicatedcom/support-bundle/pkg/collect/types"
1515 "github.com/replicatedcom/support-bundle/pkg/util"
1616 jww "github.com/spf13/jwalterweatherman"
1717)
1818
1919const (
20- DefaultEndpoint = "https://pg .replicated.com/graphql "
20+ DefaultEndpoint = "https://api .replicated.com/market "
2121 DefaultGenerateTimeoutSeconds = 60
2222)
2323
@@ -32,7 +32,6 @@ type GenerateOptions struct {
3232 Quiet bool
3333 Endpoint string
3434 ChannelID string
35- WatchID string
3635
3736 CustomerID string // Deprecated
3837
@@ -58,41 +57,20 @@ func (cli *Cli) Generate(opts GenerateOptions) error {
5857 endpoint = DefaultEndpoint
5958 }
6059
61- graphQLClient := graphql .NewClient (endpoint , http .DefaultClient )
60+ marketapiClient := marketapi .NewClient (endpoint , http .DefaultClient )
6261 specs , err := resolveLocalSpecs (opts )
6362 if err != nil {
6463 return errors .Wrap (err , "resolve specs" )
6564 }
6665
6766 var customerDoc * types.Doc
6867 var channelDoc * types.Doc
69- var watchDoc * types.Doc
7068 expectedDefaultTasks := 1 // there is always at least 1 for the version
7169
72- // this next if statement and included scope is deprecated
73- if opts .CustomerID != "" {
74- jww .DEBUG .Printf ("Getting spec with customer id %s" , opts .CustomerID )
75-
76- customerDoc , err = getCustomerDoc (graphQLClient , opts .CustomerID )
77- if err != nil {
78- return errors .Wrap (err , "get customer specs" )
79- }
80- specs = append (specs , customerDoc .Collect .V1 ... )
81- specs = append (specs , bundle .CustomerJSONSpec (opts .CustomerID ))
82-
83- if ! opts .SkipDefault && types .GetUseDefaults (customerDoc .Lifecycle ) {
84- defaultSpecs , err := bundle .DefaultSpecs ()
85- if err != nil {
86- return errors .Wrap (err , "get default spec" )
87- }
88- specs = append (specs , defaultSpecs ... )
89- }
90-
91- expectedDefaultTasks ++
92- } else if opts .ChannelID != "" {
70+ if opts .ChannelID != "" {
9371 jww .DEBUG .Printf ("Getting spec with channel id %s" , opts .ChannelID )
9472
95- channelDoc , err = getChannelDoc (graphQLClient , opts .ChannelID )
73+ channelDoc , err = getChannelDoc (marketapiClient , opts .ChannelID )
9674 if err != nil {
9775 return errors .Wrap (err , "get channel spec" )
9876 }
@@ -107,26 +85,6 @@ func (cli *Cli) Generate(opts GenerateOptions) error {
10785 specs = append (specs , defaultSpecs ... )
10886 }
10987
110- expectedDefaultTasks ++
111- } else if opts .WatchID != "" {
112- jww .DEBUG .Printf ("Getting spec with watch id %s" , opts .WatchID )
113-
114- watchDoc , err = getWatchDoc (graphQLClient , opts .WatchID )
115- if err != nil {
116- return errors .Wrap (err , "get watch spec" )
117- }
118-
119- specs = append (specs , watchDoc .Collect .V1 ... )
120- specs = append (specs , bundle .WatchJSONSpec (opts .WatchID ))
121-
122- if ! opts .SkipDefault && types .GetUseDefaults (watchDoc .Lifecycle ) {
123- defaultSpecs , err := bundle .DefaultSpecs ()
124- if err != nil {
125- return errors .Wrap (err , "get default spec" )
126- }
127- specs = append (specs , defaultSpecs ... )
128- }
129-
13088 expectedDefaultTasks ++
13189 }
13290
@@ -144,30 +102,22 @@ func (cli *Cli) Generate(opts GenerateOptions) error {
144102 BundleTasks : tasks ,
145103 GenerateTimeout : timeoutSeconds ,
146104 GenerateBundlePath : opts .BundlePath ,
147- GraphQLClient : graphQLClient ,
148- UploadCustomerID : opts .CustomerID ,
105+ MarketAPIClient : marketapiClient ,
149106 UploadChannelID : opts .ChannelID ,
150- UploadWatchID : opts .WatchID ,
151107 ConfirmUploadPrompt : opts .ConfirmUploadPrompt ,
152108 DenyUploadPrompt : opts .DenyUploadPrompt ,
153109 Quiet : opts .Quiet ,
154110 }
155111
156112 lifecycleTasks := types .DefaultLifecycleTasks
157113
158- if opts .WatchID != "" {
159- lifecycleTasks = types .DefaultWatchLifecycleTasks
160- }
161-
162114 if channelDoc != nil && channelDoc .Lifecycle != nil {
163115 lifecycleTasks = channelDoc .Lifecycle
164116 } else if customerDoc != nil && customerDoc .Lifecycle != nil {
165117 lifecycleTasks = customerDoc .Lifecycle
166- } else if watchDoc != nil && watchDoc .Lifecycle != nil {
167- lifecycleTasks = watchDoc .Lifecycle
168118 }
169119
170- if opts .CustomerID == "" && opts .ChannelID == "" && opts . WatchID == "" {
120+ if opts .CustomerID == "" && opts .ChannelID == "" {
171121 lifecycleTasks = types .GenerateOnlyLifecycleTasks
172122 }
173123
@@ -219,23 +169,8 @@ func resolveLocalSpecs(opts GenerateOptions) ([]types.Spec, error) {
219169 return specs , nil
220170}
221171
222- // getCustomerDoc is deprecated
223- func getCustomerDoc (gqlClient * graphql.Client , customerID string ) (* types.Doc , error ) {
224- remoteSpecBody , err := gqlClient .GetCustomerSpec (customerID )
225- if err != nil {
226- return nil , errors .Wrap (err , "get remote spec" )
227- }
228-
229- customerDoc , err := spec .Unmarshal (remoteSpecBody )
230- if err != nil {
231- return nil , errors .Wrap (err , "parse customer spec" )
232- }
233-
234- return customerDoc , nil
235- }
236-
237- func getChannelDoc (gqlClient * graphql.Client , channelID string ) (* types.Doc , error ) {
238- remoteSpecBody , err := gqlClient .GetChannelSpec (channelID )
172+ func getChannelDoc (client * marketapi.Client , channelID string ) (* types.Doc , error ) {
173+ remoteSpecBody , err := client .GetChannelSpec (channelID )
239174 if err != nil {
240175 return nil , errors .Wrap (err , "get remote spec" )
241176 }
@@ -247,17 +182,3 @@ func getChannelDoc(gqlClient *graphql.Client, channelID string) (*types.Doc, err
247182
248183 return channelDoc , nil
249184}
250-
251- func getWatchDoc (gqlClient * graphql.Client , watchID string ) (* types.Doc , error ) {
252- remoteSpecBody , err := gqlClient .GetWatchSpec (watchID )
253- if err != nil {
254- return nil , errors .Wrap (err , "get remote spec" )
255- }
256-
257- watchDoc , err := spec .Unmarshal (remoteSpecBody )
258- if err != nil {
259- return nil , errors .Wrap (err , "parse watch spec" )
260- }
261-
262- return watchDoc , nil
263- }
0 commit comments