Skip to content

Commit

Permalink
feat: add GrailFilterSegmentClient
Browse files Browse the repository at this point in the history
  • Loading branch information
jskelin committed Dec 10, 2024
1 parent 9e903f8 commit 6420bbe
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
12 changes: 12 additions & 0 deletions cmd/monaco/download/download_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,18 @@ func downloadConfigs(clientSet *client.ClientSet, apisToDownload api.APIs, opts
}
}

if featureflags.Temporary[featureflags.GrailFilterSegment].Enabled() {
if shouldDownloadGrailFilterSegments(opts) {
cgfs, err := fn.grailFilterSegment(clientSet.GrailFilterSegmentClient, opts.projectName)
if err != nil {
return nil, err
}
copyConfigs(configs, cgfs)
} else if opts.onlyGrailFilterSegment {
return nil, errors.New("can't download filter-segment resources: no OAuth credentials configured")
}
}

return configs, nil
}

Expand Down
36 changes: 22 additions & 14 deletions pkg/client/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ type ClientSet struct {
DocumentClient DocumentClient

// OpenPipelineClient is a client capable of manipulating openPipeline configs
OpenPipelineClient OpenPipelineClient
OpenPipelineClient OpenPipelineClient
GrailFilterSegmentClient GrailFilterSegmentClient
}

func (s ClientSet) Config() ConfigClient {
Expand Down Expand Up @@ -255,13 +256,14 @@ func validateURL(dtURL string) error {

func CreateClientSet(ctx context.Context, url string, auth manifest.Auth, opts ClientOptions) (*ClientSet, error) {
var (
configClient ConfigClient
settingsClient SettingsClient
bucketClient BucketClient
autClient AutomationClient
documentClient DocumentClient
openPipelineClient OpenPipelineClient
err error
configClient ConfigClient
settingsClient SettingsClient
bucketClient BucketClient
autClient AutomationClient
documentClient DocumentClient
openPipelineClient OpenPipelineClient
grailFilterSegmentClient GrailFilterSegmentClient
err error
)
concurrentReqLimit := environment.GetEnvValueIntLog(environment.ConcurrentRequestsEnvKey)
if err = validateURL(url); err != nil {
Expand Down Expand Up @@ -311,6 +313,11 @@ func CreateClientSet(ctx context.Context, url string, auth manifest.Auth, opts C
return nil, err
}

grailFilterSegmentClient, err = cFactory.FilterSegmentsClient()
if err != nil {
return nil, err
}

settingsClient, err = dtclient.NewPlatformSettingsClient(client, dtclient.WithCachingDisabled(opts.CachingDisabled))
if err != nil {
return nil, err
Expand Down Expand Up @@ -344,12 +351,13 @@ func CreateClientSet(ctx context.Context, url string, auth manifest.Auth, opts C
}

return &ClientSet{
ConfigClient: configClient,
SettingsClient: settingsClient,
AutClient: autClient,
BucketClient: bucketClient,
DocumentClient: documentClient,
OpenPipelineClient: openPipelineClient,
ConfigClient: configClient,
SettingsClient: settingsClient,
AutClient: autClient,
BucketClient: bucketClient,
DocumentClient: documentClient,
OpenPipelineClient: openPipelineClient,
GrailFilterSegmentClient: grailFilterSegmentClient,
}, nil
}

Expand Down

0 comments on commit 6420bbe

Please sign in to comment.