Skip to content

Commit

Permalink
Added PropertiesFromVariables to connector hash (#5012)
Browse files Browse the repository at this point in the history
  • Loading branch information
esevastyanov authored Jun 3, 2024
1 parent 4632b9c commit 8801ae4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
19 changes: 19 additions & 0 deletions runtime/reconcilers/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,24 @@ func (r *ConnectorReconciler) executionSpecHash(spec *runtimev1.ConnectorSpec) (
}
}

// sort propertiesFromVariables by key
keys = make([]string, 0, len(spec.PropertiesFromVariables))
for k := range spec.PropertiesFromVariables {
keys = append(keys, k)
}
sort.Strings(keys)

// write propertiesFromVariables to hash
for _, k := range keys {
_, err = hash.Write([]byte(k))
if err != nil {
return "", err
}
_, err = hash.Write([]byte(spec.PropertiesFromVariables[k]))
if err != nil {
return "", err
}
}

return hex.EncodeToString(hash.Sum(nil)), nil
}
7 changes: 4 additions & 3 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ func (r *Runtime) UpdateInstanceConnector(ctx context.Context, instanceID, name

// append the new/updated connector
inst.ProjectConnectors = append(inst.ProjectConnectors, &runtimev1.Connector{
Name: name,
Type: connector.Driver,
Config: connector.Properties,
Name: name,
Type: connector.Driver,
Config: connector.Properties,
ConfigFromVariables: connector.PropertiesFromVariables,
})

return r.EditInstance(ctx, inst, false)
Expand Down
6 changes: 5 additions & 1 deletion runtime/server/connectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ func (s *Server) AnalyzeConnectors(ctx context.Context, req *runtimev1.AnalyzeCo

cfg, err := s.runtime.ConnectorConfig(ctx, req.InstanceId, connector.Name)
if err != nil {
return nil, err
res[connector.Name] = &runtimev1.AnalyzedConnector{
Name: connector.Name,
ErrorMessage: err.Error(),
}
continue
}

c := &runtimev1.AnalyzedConnector{
Expand Down

0 comments on commit 8801ae4

Please sign in to comment.