Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE] adding recording rule group set suffix flag #125

Merged
Merged
Show file tree
Hide file tree
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
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
Loading