func (m *Monitor) createContainerEventFromContainerID(containerID string) (*model.ContainerEvent, error) {
	// Fetch information about the container
	cConfig, err := m.Client.ContainerInspect(context.Background(), containerID)
	if err != nil {
		return nil, err
	}
	pid := uint32(cConfig.ContainerJSONBase.State.Pid)
	exitTime, err := time.Parse(time.RFC3339Nano, cConfig.State.FinishedAt)
	if err != nil {
		fmt.Println(cConfig.State.FinishedAt, err)
		exitTime = time.Time{}
	}
	startTime, err := time.Parse(time.RFC3339Nano, cConfig.State.StartedAt)
	if err != nil {
		startTime = time.Time{}
	}
	image, tag := m.getImageAndTag(cConfig)
	return &model.ContainerEvent{
		EventBase: model.EventBase{
			EventType:        model.UnknownEventType,
			EventMonitorName: m.Name,
		},
		InitPid:             pid,
		Pidns:               utils.GetPidnsFromPid(pid),
		Cgroup:              utils.GetCgroupFromPid(pid),
		Mntns:               utils.GetMntnsFromPid(pid),
		Netns:               utils.GetNetnsFromPid(pid),
		Userns:              utils.GetUsernsFromPid(pid),
		ContainerName:       cConfig.Name[1:],
		ContainerID:         containerID,
		Image:               image,
		K8sLabelImage:       strings.Replace(image, "/", "_", -1),
		Tag:                 tag,
		Digest:              cConfig.Image,
		Privileged:          cConfig.HostConfig.Privileged,
		CapAdd:              cConfig.HostConfig.CapAdd,
		AppArmorProfile:     cConfig.AppArmorProfile,
		StartedAt:           startTime,
		FinishedAt:          exitTime,
		PortBindings:        cConfig.HostConfig.PortBindings,
		SecurityOpt:         cConfig.HostConfig.SecurityOpt,
		CommandPath:         cConfig.Path,
		CommandArgs:         cConfig.Args,
		OverlayFsMergedPath: cConfig.GraphDriver.Data["MergedDir"],
		Resources:           cConfig.HostConfig.Resources,
		NetworkSettings:     cConfig.NetworkSettings,
		MountPoints:         cConfig.Mounts,
		Labels:              cConfig.Config.Labels,
	}, nil
}
// createContainerEventFromContainerID - Creates a container event (empty action) based on a container ID
Creates a container event (empty action) based on a container ID
// createContainerEventFromContainerID - Creates a container event ( empty action ) based on a container ID
func (m *Monitor) createContainerEventFromContainerID(containerID string) (*model.ContainerEvent, error) {
	cConfig, err := m.Client.ContainerInspect(context.Background(), containerID)
	if err != nil {
		return nil, err
	}
	pid := uint32(cConfig.ContainerJSONBase.State.Pid)
	exitTime, err := time.Parse(time.RFC3339Nano, cConfig.State.FinishedAt)
	if err != nil {
		fmt.Println(cConfig.State.FinishedAt, err)
		exitTime = time.Time{}
	}
	startTime, err := time.Parse(time.RFC3339Nano, cConfig.State.StartedAt)
	if err != nil {
		startTime = time.Time{}
	}
	image, tag := m.getImageAndTag(cConfig)
	return &model.ContainerEvent{
		EventBase: model.EventBase{
			EventType:        model.UnknownEventType,
			EventMonitorName: m.Name,
		},
		InitPid:             pid,
		Pidns:               utils.GetPidnsFromPid(pid),
		Cgroup:              utils.GetCgroupFromPid(pid),
		Mntns:               utils.GetMntnsFromPid(pid),
		Netns:               utils.GetNetnsFromPid(pid),
		Userns:              utils.GetUsernsFromPid(pid),
		ContainerName:       cConfig.Name[1:],
		ContainerID:         containerID,
		Image:               image,
		K8sLabelImage:       strings.Replace(image, "/", "_", -1),
		Tag:                 tag,
		Digest:              cConfig.Image,
		Privileged:          cConfig.HostConfig.Privileged,
		CapAdd:              cConfig.HostConfig.CapAdd,
		AppArmorProfile:     cConfig.AppArmorProfile,
		StartedAt:           startTime,
		FinishedAt:          exitTime,
		PortBindings:        cConfig.HostConfig.PortBindings,
		SecurityOpt:         cConfig.HostConfig.SecurityOpt,
		CommandPath:         cConfig.Path,
		CommandArgs:         cConfig.Args,
		OverlayFsMergedPath: cConfig.GraphDriver.Data["MergedDir"],
		Resources:           cConfig.HostConfig.Resources,
		NetworkSettings:     cConfig.NetworkSettings,
		MountPoints:         cConfig.Mounts,
		Labels:              cConfig.Config.Labels,
	}, nil
}
func ( m * Monitor ) createContainerEventFromContainerID ( containerID string ) ( * model . ContainerEvent , error ) { cConfig , err := m . Client . ContainerInspect ( context . Background ( ) , containerID ) if err != nil { return nil , err } pid := uint32 ( cConfig . ContainerJSONBase . State . Pid ) exitTime , err := time . Parse ( time . RFC3339Nano , cConfig . State . FinishedAt ) if err != nil { fmt . Println ( cConfig . State . FinishedAt , err ) exitTime = time . Time { } } startTime , err := time . Parse ( time . RFC3339Nano , cConfig . State . StartedAt ) if err != nil { startTime = time . Time { } } image , tag := m . getImageAndTag ( cConfig ) return & model . ContainerEvent { EventBase : model . EventBase { EventType : model . UnknownEventType , EventMonitorName : m . Name , } , InitPid : pid , Pidns : utils . GetPidnsFromPid ( pid ) , Cgroup : utils . GetCgroupFromPid ( pid ) , Mntns : utils . GetMntnsFromPid ( pid ) , Netns : utils . GetNetnsFromPid ( pid ) , Userns : utils . GetUsernsFromPid ( pid ) , ContainerName : cConfig . Name [ 1 : ] , ContainerID : containerID , Image : image , K8sLabelImage : strings . Replace ( image , " " , " " , - 1 ) , Tag : tag , Digest : cConfig . Image , Privileged : cConfig . HostConfig . Privileged , CapAdd : cConfig . HostConfig . CapAdd , AppArmorProfile : cConfig . AppArmorProfile , StartedAt : startTime , FinishedAt : exitTime , PortBindings : cConfig . HostConfig . PortBindings , SecurityOpt : cConfig . HostConfig . SecurityOpt , CommandPath : cConfig . Path , CommandArgs : cConfig . Args , OverlayFsMergedPath : cConfig . GraphDriver . Data [ " " ] , Resources : cConfig . HostConfig . Resources , NetworkSettings : cConfig . NetworkSettings , MountPoints : cConfig . Mounts , Labels : cConfig . Config . Labels , } , nil }
Creates a container event (empty action) based on a container ID
Creates a container event ( empty action ) based on a container ID
// Fetch information about the container