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

Commit

Permalink
fix: fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayushi Sharma committed Oct 16, 2023
1 parent 63d5c1d commit ceeebdf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions internal/server/v1/firehose/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
configSourceKafkaBrokers = "SOURCE_KAFKA_BROKERS"
configSourceKafkaConsumerGroup = "SOURCE_KAFKA_CONSUMER_GROUP_ID"
configSinkType = "SINK_TYPE"
configStreamName = "STREAM_NAME"
configStencilURL = "SCHEMA_REGISTRY_STENCIL_URLS"
)

Expand Down
46 changes: 38 additions & 8 deletions internal/server/v1/firehose/mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,24 @@ func mapEntropyResourceToFirehose(res *entropyv1beta1.Resource) (models.Firehose
return firehose, fmt.Errorf("error when decoding: %w", err)
}

var err error
firehose, err = mapEntropySpecAndLabels(firehose, res.GetSpec(), labels)
if err != nil {
return firehose, errors.ErrInternal.WithCausef(err.Error())
}

firehose = mapEntropyLabels(firehose, labels)
return firehose, nil
}

func mapEntropyLabels(firehose models.Firehose, labels map[string]string) models.Firehose {
title := labels[labelTitle]
groupID := strfmt.UUID(labels[labelGroup])

firehose.Title = &title
firehose.Group = &groupID
firehose.Labels = labels
firehose.Description = labels[labelDescription]

firehose.Configs = &models.FirehoseConfig{}

return firehose
}

func mapEntropySpecAndLabels(firehose models.Firehose, spec *entropyv1beta1.ResourceSpec, labels map[string]string) (models.Firehose, error) {
title := labels[labelTitle]
groupID := strfmt.UUID(labels[labelGroup])
Expand All @@ -121,6 +130,17 @@ func mapEntropySpecAndLabels(firehose models.Firehose, spec *entropyv1beta1.Reso
firehose.Labels = labels
firehose.Description = labels[labelDescription]

var modConf entropy.FirehoseConfig
if err := utils.ProtoStructToGoVal(spec.GetConfigs(), &modConf); err != nil {
return firehose, err
}

var stopTime *strfmt.DateTime
if modConf.StopTime != nil {
dt := strfmt.DateTime(*modConf.StopTime)
stopTime = &dt
}

var kubeCluster string
for _, dep := range spec.GetDependencies() {
if dep.GetKey() == kubeClusterDependencyKey {
Expand All @@ -129,10 +149,20 @@ func mapEntropySpecAndLabels(firehose models.Firehose, spec *entropyv1beta1.Reso
}

streamName := labels[labelStream]
if streamName == "" {
streamName = modConf.EnvVariables[configStreamName]
}

firehose.Configs = &models.FirehoseConfig{
StreamName: &streamName,
KubeCluster: &kubeCluster,
Image: modConf.ChartValues.ImageTag,
EnvVars: modConf.EnvVariables,
Stopped: modConf.Stopped,
StopTime: stopTime,
ResetOffset: modConf.ResetOffset,
Replicas: float64(modConf.Replicas),
StreamName: &streamName,
DeploymentID: modConf.DeploymentID,
KubeCluster: &kubeCluster,
}

return firehose, nil
Expand Down

0 comments on commit ceeebdf

Please sign in to comment.