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

fix: removed configs from firehose #75

Merged
merged 4 commits into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 33 additions & 24 deletions internal/server/v1/firehose/mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
shieldv1beta1 "buf.build/gen/go/gotocompany/proton/protocolbuffers/go/gotocompany/shield/v1beta1"
"github.com/go-openapi/strfmt"
"github.com/mitchellh/mapstructure"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"

"github.com/goto/dex/entropy"
Expand Down Expand Up @@ -121,17 +122,6 @@ 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 @@ -140,20 +130,39 @@ func mapEntropySpecAndLabels(firehose models.Firehose, spec *entropyv1beta1.Reso
}

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

firehose.Configs = &models.FirehoseConfig{
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,
if proto.Equal(spec.GetConfigs(), structpb.NewNullValue()) {
// Handle the "null_value" case
firehose.Configs = &models.FirehoseConfig{
StreamName: &streamName,
KubeCluster: &kubeCluster,
}
} else {
var modConf entropy.FirehoseConfig
if err := utils.ProtoStructToGoVal(spec.GetConfigs(), &modConf); err != nil {
return firehose, err
}

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

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

firehose.Configs = &models.FirehoseConfig{
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
Loading