Merge pull request #562 from rhatdan/hooks
Add support for running oci-hooks
This commit is contained in:
commit
b8a6d358e7
13 changed files with 365 additions and 1 deletions
|
@ -36,6 +36,7 @@ type ContainerServer struct {
|
|||
ctrIDIndex *truncindex.TruncIndex
|
||||
podNameIndex *registrar.Registrar
|
||||
podIDIndex *truncindex.TruncIndex
|
||||
hooks map[string]HookParams
|
||||
|
||||
imageContext *types.SystemContext
|
||||
stateLock sync.Locker
|
||||
|
@ -48,6 +49,11 @@ func (c *ContainerServer) Runtime() *oci.Runtime {
|
|||
return c.runtime
|
||||
}
|
||||
|
||||
// Hooks returns the oci hooks for the ContainerServer
|
||||
func (c *ContainerServer) Hooks() map[string]HookParams {
|
||||
return c.hooks
|
||||
}
|
||||
|
||||
// Store returns the Store for the ContainerServer
|
||||
func (c *ContainerServer) Store() cstorage.Store {
|
||||
return c.store
|
||||
|
@ -131,6 +137,21 @@ func New(config *Config) (*ContainerServer, error) {
|
|||
lock = new(sync.Mutex)
|
||||
}
|
||||
|
||||
hooks := make(map[string]HookParams)
|
||||
// If hooks directory is set in config use it
|
||||
if config.HooksDirPath != "" {
|
||||
if err := readHooks(config.HooksDirPath, hooks); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// If user overrode default hooks, this means it is in a test, so don't
|
||||
// use OverrideHooksDirPath
|
||||
if config.HooksDirPath == DefaultHooksDirPath {
|
||||
if err := readHooks(OverrideHooksDirPath, hooks); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &ContainerServer{
|
||||
runtime: runtime,
|
||||
store: store,
|
||||
|
@ -141,6 +162,7 @@ func New(config *Config) (*ContainerServer, error) {
|
|||
podNameIndex: registrar.NewRegistrar(),
|
||||
podIDIndex: truncindex.NewTruncIndex([]string{}),
|
||||
imageContext: &types.SystemContext{SignaturePolicyPath: config.SignaturePolicyPath},
|
||||
hooks: hooks,
|
||||
stateLock: lock,
|
||||
state: &containerServerState{
|
||||
containers: oci.NewMemoryStore(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue