Skip to content

Commit

Permalink
We should consider default fields in relationship constrains
Browse files Browse the repository at this point in the history
as is required for external ticketing which depends on ticketing a default field
  • Loading branch information
btipling committed Oct 9, 2024
1 parent 7b0a602 commit 9d27c9e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@ func DefineConfiguration(
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
v.AutomaticEnv()

confschema := schema
confschema.Fields = append(field.DefaultFields, confschema.Fields...)
// Ensure unique fields
uniqueFields := make(map[string]field.SchemaField)
for _, f := range confschema.Fields {
uniqueFields[f.FieldName] = f
}
confschema.Fields = make([]field.SchemaField, 0, len(uniqueFields))
for _, f := range uniqueFields {
confschema.Fields = append(confschema.Fields, f)
}
// setup CLI with cobra
mainCMD := &cobra.Command{
Use: connectorName,
Short: connectorName,
SilenceErrors: true,
SilenceUsage: true,
RunE: cli.MakeMainCommand(ctx, connectorName, v, schema, connector, options...),
RunE: cli.MakeMainCommand(ctx, connectorName, v, confschema, connector, options...),
}
// set persistent flags only on the main subcommand
err = setFlagsAndConstraints(mainCMD, field.NewConfiguration(field.DefaultFields, field.DefaultRelationships...))
Expand Down

0 comments on commit 9d27c9e

Please sign in to comment.