Skip to content

Commit

Permalink
defaulting to one side car in case of no multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
anilkeshav27 committed Feb 2, 2024
1 parent 8d85456 commit 3e3b7de
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions pkg/config/stepmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,32 +311,43 @@ func (m *StepData) GetContextDefaults(stepName string) (io.ReadCloser, error) {
}

if len(m.Spec.Sidecars) > 0 {
for _, sideCar := range m.Spec.Sidecars {
key := ""
conditionParam := ""
if len(sideCar.Conditions) > 0 {
key = sideCar.Conditions[0].Params[0].Value
conditionParam = sideCar.Conditions[0].Params[0].Name

// if there one side care dont check conditions and consider the only side care as default . this is default behaviour
// if there are more than one side car then check conditions,
if len(m.Spec.Sidecars) == 1 {
if len(m.Spec.Sidecars[0].Command) > 0 {
root["sidecarCommand"] = m.Spec.Sidecars[0].Command[0]
}
p := map[string]interface{}{}
if key != "" {
root[key] = p
//add default for condition parameter if available
for _, inputParam := range m.Spec.Inputs.Parameters {
if inputParam.Name == conditionParam {
root[conditionParam] = inputParam.Default
m.Spec.Sidecars[0].commonConfiguration("sidecar", &root)
putStringIfNotEmpty(root, "sidecarReadyCommand", m.Spec.Sidecars[0].ReadyCommand)
} else {
for _, sideCar := range m.Spec.Sidecars {
key := ""
conditionParam := ""
if len(sideCar.Conditions) > 0 {
key = sideCar.Conditions[0].Params[0].Value
conditionParam = sideCar.Conditions[0].Params[0].Name
}
p := map[string]interface{}{}
if key != "" {
root[key] = p
//add default for condition parameter if available
for _, inputParam := range m.Spec.Inputs.Parameters {
if inputParam.Name == conditionParam {
root[conditionParam] = inputParam.Default
}
}
} else {
p = root
}
if len(sideCar.Command) > 0 {
root["sidecarCommand"] = sideCar.Command[0]
}
} else {
p = root
}
if len(sideCar.Command) > 0 {
root["sidecarCommand"] = sideCar.Command[0]
}

putStringIfNotEmpty(root, "sidecarReadyCommand", sideCar.ReadyCommand)
sideCar.commonConfiguration("sidecar", &p)
putStringIfNotEmpty(root, "sidecarReadyCommand", sideCar.ReadyCommand)
sideCar.commonConfiguration("sidecar", &p)

}
}

// not filled for now since this is not relevant in Kubernetes case
Expand Down

0 comments on commit 3e3b7de

Please sign in to comment.