github.com/cilium/cilium@v1.16.2/pkg/datapath/linux/sysctl/cell.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package sysctl
     5  
     6  import (
     7  	"github.com/cilium/hive/cell"
     8  	"github.com/cilium/statedb"
     9  	"github.com/cilium/statedb/reconciler"
    10  	"github.com/spf13/afero"
    11  	"github.com/spf13/pflag"
    12  
    13  	"github.com/cilium/cilium/pkg/datapath/tables"
    14  	"github.com/cilium/cilium/pkg/time"
    15  )
    16  
    17  var Cell = cell.Module(
    18  	"sysctl",
    19  	"Manages sysctl settings",
    20  
    21  	cell.Config(Config{}),
    22  
    23  	cell.Provide(
    24  		newReconcilingSysctl,
    25  	),
    26  	cell.ProvidePrivate(
    27  		tables.NewSysctlTable,
    28  
    29  		newReconciler,
    30  		newOps,
    31  	),
    32  	cell.ProvidePrivate(
    33  		func() afero.Fs {
    34  			return afero.NewOsFs()
    35  		},
    36  	),
    37  )
    38  
    39  type Config struct {
    40  	ProcFs string `mapstructure:"procfs"`
    41  }
    42  
    43  func (cfg Config) Flags(flags *pflag.FlagSet) {
    44  	flags.String("procfs", "/proc", "Path to the host's proc filesystem mount")
    45  }
    46  
    47  func newReconciler(
    48  	params reconciler.Params,
    49  	ops reconciler.Operations[*tables.Sysctl],
    50  	tbl statedb.RWTable[*tables.Sysctl],
    51  ) (reconciler.Reconciler[*tables.Sysctl], error) {
    52  	return reconciler.Register(
    53  		params,
    54  		tbl,
    55  		(*tables.Sysctl).Clone,
    56  		(*tables.Sysctl).SetStatus,
    57  		(*tables.Sysctl).GetStatus,
    58  		ops,
    59  		nil,
    60  
    61  		reconciler.WithoutPruning(),
    62  		reconciler.WithRefreshing(
    63  			10*time.Minute,
    64  			nil,
    65  		),
    66  	)
    67  }