Skip to content

Commit acb4bb2

Browse files
authored
Merge pull request #320 from replicatedcom/divolgin/sc-106531/remove-graphql-api-references-from-support
remove graphql api references from support bundle
2 parents b44d21e + 9e43ed3 commit acb4bb2

14 files changed

Lines changed: 154 additions & 608 deletions

File tree

cmd/support-bundle/commands/generate.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,9 @@ func NewGenerateCommand(supportBundle *cli.Cli) *cobra.Command {
3333
cmd.Flags().BoolVarP(&opts.ConfirmUploadPrompt, "yes-upload", "u", false, "If present, auto-confirm any upload prompts")
3434
cmd.Flags().BoolVar(&opts.DenyUploadPrompt, "no-upload", false, "If present, auto-deny any upload prompts")
3535

36-
cmd.Flags().StringVar(&opts.CustomerID, "customer-id", "", "Replicated Customer ID")
3736
cmd.Flags().StringVar(&opts.Endpoint, "endpoint", cli.DefaultEndpoint, "Customer API Endpoint")
3837

3938
cmd.Flags().StringVar(&opts.ChannelID, "channel-id", "", "Replicated ChannelID to attempt to get a collector definition from")
40-
cmd.Flags().StringVar(&opts.WatchID, "watch-id", "", "Replicated WatchID to attempt to get a collector definition from")
41-
42-
cmd.Flags().MarkDeprecated("customer-id", "This argument is no longer supported. Consider using \"channel-id\"")
4339

4440
//--out - works, and its totally interactive and everything,
4541
// and the bundle just gets dumped to stdout.

pkg/analyze/analyze/analyze.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ type Analyze struct {
3939
Specs []string
4040
SkipDefault bool
4141
BundleRootSubpath string
42-
CustomerID string // deprecated
4342
ChannelID string
4443
Endpoint string
4544

@@ -60,7 +59,6 @@ func New(v *viper.Viper, logger log.Logger, resolver *resolver.Resolver, getter
6059
Specs: v.GetStringSlice("spec"),
6160
SkipDefault: v.GetBool("skip-default"),
6261
BundleRootSubpath: v.GetString("bundle-root-subpath"),
63-
CustomerID: v.GetString("customer-id"),
6462
Endpoint: v.GetString("endpoint"),
6563

6664
// analyze
@@ -133,18 +131,16 @@ func (a *Analyze) Execute(ctx context.Context, bundlePath string) ([]api.Result,
133131
}
134132

135133
input := resolver.Input{
136-
Files: a.SpecFiles,
137-
Inline: a.Specs,
138-
CustomerID: a.CustomerID,
139-
ChannelID: a.ChannelID,
140-
Endpoint: endpoint,
134+
Files: a.SpecFiles,
135+
Inline: a.Specs,
136+
ChannelID: a.ChannelID,
137+
Endpoint: endpoint,
141138
}
142139
spec, err := a.Resolver.ResolveSpec(ctx, input, a.SkipDefault)
143140
debug.Log(
144141
"phase", "resolve",
145142
"files", a.SpecFiles,
146143
"inline", a.Specs,
147-
"customerID", a.CustomerID,
148144
"channelID", a.ChannelID,
149145
"endpoint", endpoint,
150146
"error", err)

pkg/analyze/cli/run.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ func RunCmd() *cobra.Command {
6161
cmd.Flags().Bool("skip-default", false, "Skip the default analyze spec")
6262
cmd.Flags().String("bundle-root-subpath", "", "The subpath within the archive at which the bundle root resides")
6363

64-
cmd.Flags().String("customer-id", "", "Replicated Customer ID")
65-
cmd.Flags().MarkDeprecated("customer-id", "This argument is no longer supported. Consider using \"channel-id\"")
66-
6764
cmd.Flags().String("channel-id", "", "Replicated ChannelID to attempt to get a collector definition from")
6865
cmd.Flags().String("endpoint", collectcli.DefaultEndpoint, "Endpoint to fetch collector definitions fom")
6966

pkg/analyze/resolver/resolver.go

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
multierror "github.com/hashicorp/go-multierror"
1111
"github.com/pkg/errors"
1212
"github.com/replicatedcom/support-bundle/pkg/analyze/api"
13-
"github.com/replicatedcom/support-bundle/pkg/collect/graphql"
13+
"github.com/replicatedcom/support-bundle/pkg/collect/marketapi"
1414
"github.com/spf13/afero"
1515
)
1616

@@ -20,11 +20,10 @@ type Resolver struct {
2020
}
2121

2222
type Input struct {
23-
Files []string
24-
Inline []string
25-
CustomerID string
26-
ChannelID string
27-
Endpoint string
23+
Files []string
24+
Inline []string
25+
ChannelID string
26+
Endpoint string
2827
}
2928

3029
func New(logger log.Logger, fs afero.Fs) *Resolver {
@@ -77,29 +76,8 @@ func (r *Resolver) ResolveSpec(ctx context.Context, input Input, skipDefault boo
7776
}
7877
}
7978

80-
if input.CustomerID != "" {
81-
client := graphql.NewClient(input.Endpoint, http.DefaultClient)
82-
inline, errI := client.GetCustomerSpec(input.CustomerID)
83-
debug.Log(
84-
"phase", "doc.customer.retrieve",
85-
"error", errI)
86-
if errI != nil {
87-
err = multierror.Append(err, errors.Wrap(errI, "retrieve customer doc"))
88-
} else {
89-
doc, errI := api.DeserializeDoc([]byte(inline))
90-
debug.Log(
91-
"phase", "doc.customer.deserialize",
92-
"error", errI)
93-
if errI != nil {
94-
err = multierror.Append(err, errors.Wrap(errI, "deserialize customer doc"))
95-
} else {
96-
resolved = mergeDocs(resolved, doc)
97-
}
98-
}
99-
}
100-
10179
if input.ChannelID != "" {
102-
client := graphql.NewClient(input.Endpoint, http.DefaultClient)
80+
client := marketapi.NewClient(input.Endpoint, http.DefaultClient)
10381
inline, errI := client.GetChannelSpec(input.ChannelID)
10482
debug.Log(
10583
"phase", "doc.channel.retrieve",

pkg/collect/bundle/default.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,3 @@ func ChannelJSONSpec(channelID string) types.Spec {
8080
},
8181
}
8282
}
83-
84-
func WatchJSONSpec(watchID string) types.Spec {
85-
return types.Spec{
86-
SpecShared: types.SpecShared{
87-
Description: "Troubleshoot Watch Metadata",
88-
OutputDir: "/",
89-
},
90-
WatchMeta: &types.WatchMetaOptions{
91-
WatchID: watchID,
92-
},
93-
}
94-
}

pkg/collect/cli/generate.go

Lines changed: 9 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1919
const (
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

Comments
 (0)