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

Commit

Permalink
feat(firehose): skip stencil url generation if already exists (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
StewartJingga authored Oct 3, 2023
1 parent 251c96e commit f5284fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions internal/server/v1/firehose/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (api *firehoseAPI) handleCreate(w http.ResponseWriter, r *http.Request) {
}
def.Project = prj.GetSlug()

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

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

_, hasTopicUpdate := req.Configs.EnvVars[configSourceKafkaTopic]
err = api.buildEnvVars(r.Context(), &existing, reqCtx.UserID, hasTopicUpdate)
skipStencil := !hasTopicUpdate
err = api.buildEnvVars(r.Context(), &existing, reqCtx.UserID, skipStencil)
if err != nil {
utils.WriteErr(w, fmt.Errorf("error building env vars: %w", err))
return
Expand Down
4 changes: 2 additions & 2 deletions internal/server/v1/firehose/envvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/goto/dex/odin"
)

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

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

firehose.Configs.EnvVars["SCHEMA_REGISTRY_STENCIL_ENABLE"] = trueString
if fetchStencilURL || firehose.Configs.EnvVars[configStencilURL] == "" {
if firehose.Configs.EnvVars[configStencilURL] == "" && !skipStencil {
stencilUrls, err := api.getStencilURLs(
ctx,
userID,
Expand Down

0 comments on commit f5284fc

Please sign in to comment.