@@ -1247,7 +1247,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
12471247
12481248 var err error
12491249 if ! rootless .IsRootless () {
1250- if c .state .ExtensionStageHooks , err = c .setupOCIHooks (ctx , & g ); err != nil {
1250+ if c .state .ExtensionStageHooks , err = c .setupOCIHooks (ctx , g . Config ); err != nil {
12511251 return nil , errors .Wrapf (err , "error setting up OCI Hooks" )
12521252 }
12531253 }
@@ -1287,7 +1287,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
12871287
12881288 // Look up and add groups the user belongs to, if a group wasn't directly specified
12891289 if ! rootless .IsRootless () && ! strings .Contains (c .config .User , ":" ) {
1290- groups , err := chrootuser .GetAdditionalGroupsForUser (c .state .Mountpoint , uint64 (g .Spec () .Process .User .UID ))
1290+ groups , err := chrootuser .GetAdditionalGroupsForUser (c .state .Mountpoint , uint64 (g .Config .Process .User .UID ))
12911291 if err != nil && errors .Cause (err ) != chrootuser .ErrNoSuchUser {
12921292 return nil , err
12931293 }
@@ -1344,11 +1344,11 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
13441344 g .AddAnnotation ("org.opencontainers.image.stopSignal" , fmt .Sprintf ("%d" , c .config .StopSignal ))
13451345
13461346 g .SetHostname (c .Hostname ())
1347- g .AddProcessEnv ("HOSTNAME" , g .Spec () .Hostname )
1347+ g .AddProcessEnv ("HOSTNAME" , g .Config .Hostname )
13481348
13491349 // Only add container environment variable if not already present
13501350 foundContainerEnv := false
1351- for _ , env := range g .Spec () .Process .Env {
1351+ for _ , env := range g .Config .Process .Env {
13521352 if strings .HasPrefix (env , "container=" ) {
13531353 foundContainerEnv = true
13541354 break
@@ -1376,7 +1376,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
13761376 g .SetLinuxCgroupsPath (cgroupPath )
13771377 }
13781378
1379- return g .Spec () , nil
1379+ return g .Config , nil
13801380}
13811381
13821382// Add an existing container's namespace to the spec
@@ -1511,7 +1511,7 @@ func (c *Container) saveSpec(spec *spec.Spec) error {
15111511 return nil
15121512}
15131513
1514- func (c * Container ) setupOCIHooks (ctx context.Context , g * generate. Generator ) (extensionStageHooks map [string ][]spec.Hook , err error ) {
1514+ func (c * Container ) setupOCIHooks (ctx context.Context , config * spec. Spec ) (extensionStageHooks map [string ][]spec.Hook , err error ) {
15151515 if c .runtime .config .HooksDir == "" {
15161516 return nil , nil
15171517 }
@@ -1552,5 +1552,5 @@ func (c *Container) setupOCIHooks(ctx context.Context, g *generate.Generator) (e
15521552 return nil , nil
15531553 }
15541554
1555- return manager .Hooks (g . Spec () , c .Spec ().Annotations , len (c .config .UserVolumes ) > 0 )
1555+ return manager .Hooks (config , c .Spec ().Annotations , len (c .config .UserVolumes ) > 0 )
15561556}
0 commit comments