// buildUserContainer builds hyperd's UserContainer based kubelet ContainerConfig.
buildUserContainer builds hyperd's UserContainer based kubelet ContainerConfig.
// buildUserContainer builds hyperd ' s UserContainer based kubelet ContainerConfig .
func buildUserContainer(config *kubeapi.ContainerConfig, sandboxConfig *kubeapi.PodSandboxConfig) (*types.UserContainer, error) {
	privilege := false
	readonlyRootfs := false
	if securityContext := config.GetLinux().GetSecurityContext(); securityContext != nil {
		privilege = securityContext.Privileged
		readonlyRootfs = securityContext.ReadonlyRootfs
	}
	if privilege {
		return nil, fmt.Errorf("Privileged containers are not supported in hyper")
	}
	logPath := filepath.Join(sandboxConfig.LogDirectory, config.LogPath)
	if config.Labels == nil {
		config.Labels = make(map[string]string)
	}
	config.Labels[containerLogPathLabelKey] = logPath
	containerSpec := &types.UserContainer{
		Name:       buildContainerName(sandboxConfig, config),
		Image:      config.GetImage().Image,
		Workdir:    config.WorkingDir,
		Tty:        config.Tty,
		Command:    config.Args,
		Entrypoint: config.Command,
		Labels:     buildLabelsWithAnnotations(config.Labels, config.Annotations),
		LogPath:    logPath,
		ReadOnly:   readonlyRootfs,
	}
	volumes, err := makeContainerVolumes(config)
	if err != nil {
		return nil, err
	}
	containerSpec.Volumes = volumes
	environments := make([]*types.EnvironmentVar, len(config.Envs))
	for idx, env := range config.Envs {
		environments[idx] = &types.EnvironmentVar{
			Env:   env.Key,
			Value: env.Value,
		}
	}
	containerSpec.Envs = environments
	return containerSpec, nil
}
func buildUserContainer ( config * kubeapi . ContainerConfig , sandboxConfig * kubeapi . PodSandboxConfig ) ( * types . UserContainer , error ) { privilege := false readonlyRootfs := false if securityContext := config . GetLinux ( ) . GetSecurityContext ( ) ; securityContext != nil { privilege = securityContext . Privileged readonlyRootfs = securityContext . ReadonlyRootfs } if privilege { return nil , fmt . Errorf ( " " ) } logPath := filepath . Join ( sandboxConfig . LogDirectory , config . LogPath ) if config . Labels == nil { config . Labels = make ( map [ string ] string ) } config . Labels [ containerLogPathLabelKey ] = logPath containerSpec := & types . UserContainer { Name : buildContainerName ( sandboxConfig , config ) , Image : config . GetImage ( ) . Image , Workdir : config . WorkingDir , Tty : config . Tty , Command : config . Args , Entrypoint : config . Command , Labels : buildLabelsWithAnnotations ( config . Labels , config . Annotations ) , LogPath : logPath , ReadOnly : readonlyRootfs , } volumes , err := makeContainerVolumes ( config ) if err != nil { return nil , err } containerSpec . Volumes = volumes environments := make ( [ ] * types . EnvironmentVar , len ( config . Envs ) ) for idx , env := range config . Envs { environments [ idx ] = & types . EnvironmentVar { Env : env . Key , Value : env . Value , } } containerSpec . Envs = environments return containerSpec , nil }
buildUserContainer builds hyperd's UserContainer based kubelet ContainerConfig.
buildUserContainer builds hyperd ' s UserContainer based kubelet ContainerConfig .
// make volumes // make environments