Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Gchbg committed Apr 8, 2024
1 parent 157efbf commit 02ed40b
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 94 deletions.
10 changes: 2 additions & 8 deletions client/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

metalv1alpha1 "github.com/ironcore-dev/metal/api/v1alpha1"
"github.com/ironcore-dev/metal/internal/controller"
"github.com/ironcore-dev/metal/internal/cru"
"github.com/ironcore-dev/metal/internal/log"
//+kubebuilder:scaffold:imports
)
Expand All @@ -41,6 +42,7 @@ type params struct {
secureMetrics bool
enableHTTP2 bool
kubeconfig string
systemNamespace string
enableMachineController bool
enableMachineClaimController bool
enableOOBController bool
Expand All @@ -59,6 +61,7 @@ func parseCmdLine() params {
pflag.Bool("metrics-secure", false, "Serve metrics securely.")
pflag.Bool("enable-http2", false, "Enable HTTP2 for the metrics and webhook servers.")
pflag.String("kubeconfig", "", "Use a kubeconfig to run out of cluster.")
pflag.String("system-namespace", "", "Use a specific namespace for controller state. If blank, use the in-cluster namespace. Required if running out of cluster.")
pflag.Bool("enable-machine-controller", true, "Enable the Machine controller.")
pflag.Bool("enable-machineclaim-controller", true, "Enable the MachineClaim controller.")
pflag.Bool("enable-oob-controller", true, "Enable the OOB controller.")
Expand Down Expand Up @@ -88,6 +91,7 @@ func parseCmdLine() params {
secureMetrics: viper.GetBool("metrics-secure"),
enableHTTP2: viper.GetBool("enable-http2"),
kubeconfig: viper.GetString("kubeconfig"),
systemNamespace: viper.GetString("system-namespace"),
enableMachineController: viper.GetBool("enable-machine-controller"),
enableMachineClaimController: viper.GetBool("enable-machineclaim-controller"),
enableOOBController: viper.GetBool("enable-oob-controller"),
Expand Down Expand Up @@ -120,7 +124,7 @@ func main() {

ctx, stop := signal.NotifyContext(log.Setup(context.Background(), p.dev, false, os.Stderr), syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGHUP)
defer stop()
log.Info(ctx, "Starting OOB operator")
log.Info(ctx, "Starting Metal")

defer func() {
log.Info(ctx, "Exiting", "exitCode", exitCode)
Expand Down Expand Up @@ -153,6 +157,15 @@ func main() {
return
}

if p.systemNamespace == "" {
p.systemNamespace = cru.InClusterNamespace()
if p.systemNamespace == "" {
log.Error(ctx, fmt.Errorf("system namespace must be specified when running out of cluster"))
exitCode = 1
return
}
}

var tlsOpts []func(*tls.Config)
if !p.enableHTTP2 {
tlsOpts = append(tlsOpts, func(c *tls.Config) {
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions internal/controller/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
metalv1alpha1 "github.com/ironcore-dev/metal/api/v1alpha1"
)

//+kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines/finalizers,verbs=update
// +kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines/finalizers,verbs=update

func NewMachineReconciler() (*MachineReconciler, error) {
return &MachineReconciler{}, nil
Expand Down
12 changes: 6 additions & 6 deletions internal/controller/machineclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (
"github.com/ironcore-dev/metal/internal/util"
)

//+kubebuilder:rbac:groups=metal.ironcore.dev,resources=machineclaims,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=metal.ironcore.dev,resources=machineclaims/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=metal.ironcore.dev,resources=machineclaims/finalizers,verbs=update
//+kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines,verbs=get;list;watch;update;patch
//+kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines/status,verbs=get
//+kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines/finalizers,verbs=update
// +kubebuilder:rbac:groups=metal.ironcore.dev,resources=machineclaims,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=metal.ironcore.dev,resources=machineclaims/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=metal.ironcore.dev,resources=machineclaims/finalizers,verbs=update
// +kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines,verbs=get;list;watch;update;patch
// +kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines/status,verbs=get
// +kubebuilder:rbac:groups=metal.ironcore.dev,resources=machines/finalizers,verbs=update

const (
MachineClaimFieldOwner string = "metal.ironcore.dev/machineclaim"
Expand Down
Loading

0 comments on commit 02ed40b

Please sign in to comment.