Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit f5284fc

Browse files
feat(firehose): skip stencil url generation if already exists (#71)
1 parent 251c96e commit f5284fc

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

internal/server/v1/firehose/crud.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (api *firehoseAPI) handleCreate(w http.ResponseWriter, r *http.Request) {
7878
}
7979
def.Project = prj.GetSlug()
8080

81-
err = api.buildEnvVars(r.Context(), &def, reqCtx.UserID, true)
81+
err = api.buildEnvVars(r.Context(), &def, reqCtx.UserID, false)
8282
if err != nil {
8383
utils.WriteErr(w, fmt.Errorf("error building env vars: %w", err))
8484
return
@@ -269,7 +269,7 @@ func (api *firehoseAPI) handleUpdate(w http.ResponseWriter, r *http.Request) {
269269
labels[labelDescription] = existingFirehose.Description
270270
}
271271

272-
err = api.buildEnvVars(r.Context(), &existingFirehose, reqCtx.UserID, true)
272+
err = api.buildEnvVars(r.Context(), &existingFirehose, reqCtx.UserID, false)
273273
if err != nil {
274274
utils.WriteErr(w, fmt.Errorf("error building env vars: %w", err))
275275
return
@@ -385,7 +385,8 @@ func (api *firehoseAPI) handlePartialUpdate(w http.ResponseWriter, r *http.Reque
385385
)
386386

387387
_, hasTopicUpdate := req.Configs.EnvVars[configSourceKafkaTopic]
388-
err = api.buildEnvVars(r.Context(), &existing, reqCtx.UserID, hasTopicUpdate)
388+
skipStencil := !hasTopicUpdate
389+
err = api.buildEnvVars(r.Context(), &existing, reqCtx.UserID, skipStencil)
389390
if err != nil {
390391
utils.WriteErr(w, fmt.Errorf("error building env vars: %w", err))
391392
return

internal/server/v1/firehose/envvars.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/goto/dex/odin"
1010
)
1111

12-
func (api *firehoseAPI) buildEnvVars(ctx context.Context, firehose *models.Firehose, userID string, fetchStencilURL bool) error {
12+
func (api *firehoseAPI) buildEnvVars(ctx context.Context, firehose *models.Firehose, userID string, skipStencil bool) error {
1313
streamURN := buildStreamURN(*firehose.Configs.StreamName, firehose.Project)
1414

1515
if firehose.Configs.EnvVars[configSourceKafkaBrokers] == "" {
@@ -21,7 +21,7 @@ func (api *firehoseAPI) buildEnvVars(ctx context.Context, firehose *models.Fireh
2121
}
2222

2323
firehose.Configs.EnvVars["SCHEMA_REGISTRY_STENCIL_ENABLE"] = trueString
24-
if fetchStencilURL || firehose.Configs.EnvVars[configStencilURL] == "" {
24+
if firehose.Configs.EnvVars[configStencilURL] == "" && !skipStencil {
2525
stencilUrls, err := api.getStencilURLs(
2626
ctx,
2727
userID,

0 commit comments

Comments
 (0)