Skip to content

Commit

Permalink
[CHORE] adding recording rule group set suffix flag] (#125)
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Takashi <nicolas.takashi@coralogix.com>
  • Loading branch information
nicolastakashi authored Jul 31, 2024
1 parent ac9d221 commit 95feab7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ var recordingRuleGroupSetFinalizerName = "recordingrulegroupset.coralogix.com/fi
// RecordingRuleGroupSetReconciler reconciles a RecordingRuleGroupSet object
type RecordingRuleGroupSetReconciler struct {
client.Client
CoralogixClientSet clientset.ClientSetInterface
Scheme *runtime.Scheme
CoralogixClientSet clientset.ClientSetInterface
Scheme *runtime.Scheme
RecordingRuleGroupSetSuffix string
}

//+kubebuilder:rbac:groups=coralogix.com,resources=recordingrulegroupsets,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -97,7 +98,7 @@ func (r *RecordingRuleGroupSetReconciler) create(ctx context.Context, recordingR
response, err := r.CoralogixClientSet.
RecordingRuleGroups().
CreateRecordingRuleGroupSet(ctx, &rrg.CreateRuleGroupSet{
Name: ptr.To(recordingRuleGroupSet.Name),
Name: ptr.To(fmt.Sprintf("%s%s", recordingRuleGroupSet.Name, r.RecordingRuleGroupSetSuffix)),
Groups: recordingRuleGroupSet.Spec.ExtractRecordingRuleGroups(),
})

Expand Down Expand Up @@ -143,7 +144,7 @@ func (r *RecordingRuleGroupSetReconciler) update(ctx context.Context, recordingR
UpdateRecordingRuleGroupSet(ctx, &rrg.UpdateRuleGroupSet{
Id: remoteRecordingRule.Id,
Groups: recordingRuleGroupSet.Spec.ExtractRecordingRuleGroups(),
Name: ptr.To(recordingRuleGroupSet.Name),
Name: ptr.To(fmt.Sprintf("%s%s", recordingRuleGroupSet.Name, r.RecordingRuleGroupSetSuffix)),
}); err != nil {
return fmt.Errorf("failed to update recording rule groupSet: %w", err)
}
Expand Down
10 changes: 7 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func main() {
var prometheusRuleController bool
flag.BoolVar(&prometheusRuleController, "prometheus-rule-controller", true, "Determine if the prometheus rule controller should be started. Default is true.")

var recordingRuleGroupSetSuffix string
flag.StringVar(&recordingRuleGroupSetSuffix, "recording-rule-group-set-suffix", "", "Suffix to be added to the RecordingRuleGroupSet")

opts := zap.Options{}
opts.BindFlags(flag.CommandLine)
flag.Parse()
Expand Down Expand Up @@ -158,9 +161,10 @@ func main() {
}
}
if err = (&alphacontrollers.RecordingRuleGroupSetReconciler{
CoralogixClientSet: clientset.NewClientSet(targetUrl, apiKey),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
CoralogixClientSet: clientset.NewClientSet(targetUrl, apiKey),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
RecordingRuleGroupSetSuffix: recordingRuleGroupSetSuffix,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "RecordingRuleGroupSet")
os.Exit(1)
Expand Down

0 comments on commit 95feab7

Please sign in to comment.