@@ -285,37 +285,37 @@ func parseDockerIgnore(targetDir string) (bool, []string, error) {
285285
286286// GetBuildArgs returns the env args to be used when creating from Dockerfile
287287func (c * ContainerRequest ) GetBuildArgs () map [string ]* string {
288- return c .FromDockerfile . BuildArgs
288+ return c .BuildArgs
289289}
290290
291291// GetDockerfile returns the Dockerfile from the ContainerRequest, defaults to "Dockerfile".
292292// Sets FromDockerfile.Dockerfile to the default if blank.
293293func (c * ContainerRequest ) GetDockerfile () string {
294- if c .FromDockerfile . Dockerfile == "" {
295- c .FromDockerfile . Dockerfile = "Dockerfile"
294+ if c .Dockerfile == "" {
295+ c .Dockerfile = "Dockerfile"
296296 }
297297
298- return c .FromDockerfile . Dockerfile
298+ return c .Dockerfile
299299}
300300
301301// GetRepo returns the Repo label for image from the ContainerRequest, defaults to UUID.
302302// Sets FromDockerfile.Repo to the default value if blank.
303303func (c * ContainerRequest ) GetRepo () string {
304- if c .FromDockerfile . Repo == "" {
305- c .FromDockerfile . Repo = uuid .NewString ()
304+ if c .Repo == "" {
305+ c .Repo = uuid .NewString ()
306306 }
307307
308- return strings .ToLower (c .FromDockerfile . Repo )
308+ return strings .ToLower (c .Repo )
309309}
310310
311311// GetTag returns the Tag label for image from the ContainerRequest, defaults to UUID.
312312// Sets FromDockerfile.Tag to the default value if blank.
313313func (c * ContainerRequest ) GetTag () string {
314- if c .FromDockerfile . Tag == "" {
315- c .FromDockerfile . Tag = uuid .NewString ()
314+ if c .Tag == "" {
315+ c .Tag = uuid .NewString ()
316316 }
317317
318- return strings .ToLower (c .FromDockerfile . Tag )
318+ return strings .ToLower (c .Tag )
319319}
320320
321321// Deprecated: Testcontainers will detect registry credentials automatically, and it will be removed in the next major release.
@@ -343,13 +343,13 @@ func (c *ContainerRequest) dockerFileImages() ([]string, error) {
343343
344344 // Source is an archive, we need to read it to get the Dockerfile.
345345 dockerFile := c .GetDockerfile ()
346- tr := tar .NewReader (c .FromDockerfile . ContextArchive )
346+ tr := tar .NewReader (c .ContextArchive )
347347
348348 for {
349349 hdr , err := tr .Next ()
350350 if err != nil {
351351 if errors .Is (err , io .EOF ) {
352- return nil , fmt .Errorf ("Dockerfile %q not found in context archive" , dockerFile )
352+ return nil , fmt .Errorf ("dockerfile %q not found in context archive" , dockerFile )
353353 }
354354
355355 return nil , fmt .Errorf ("reading tar archive: %w" , err )
@@ -405,22 +405,24 @@ func getAuthConfigsFromDockerfile(c *ContainerRequest) (map[string]registry.Auth
405405}
406406
407407func (c * ContainerRequest ) ShouldBuildImage () bool {
408- return c .FromDockerfile . Context != "" || c . FromDockerfile .ContextArchive != nil
408+ return c .Context != "" || c .ContextArchive != nil
409409}
410410
411411func (c * ContainerRequest ) ShouldKeepBuiltImage () bool {
412- return c .FromDockerfile . KeepImage
412+ return c .KeepImage
413413}
414414
415415// BuildLogWriter returns the io.Writer for output of log when building a Docker image from
416416// a Dockerfile. It returns the BuildLogWriter from the ContainerRequest, defaults to io.Discard.
417417// For backward compatibility, if BuildLogWriter is default and PrintBuildLog is true,
418418// the function returns os.Stderr.
419+ //
420+ //nolint:staticcheck //FIXME
419421func (c * ContainerRequest ) BuildLogWriter () io.Writer {
420422 if c .FromDockerfile .BuildLogWriter != nil {
421423 return c .FromDockerfile .BuildLogWriter
422424 }
423- if c .FromDockerfile . PrintBuildLog {
425+ if c .PrintBuildLog {
424426 c .FromDockerfile .BuildLogWriter = os .Stderr
425427 } else {
426428 c .FromDockerfile .BuildLogWriter = io .Discard
@@ -437,8 +439,8 @@ func (c *ContainerRequest) BuildOptions() (types.ImageBuildOptions, error) {
437439 ForceRemove : true ,
438440 }
439441
440- if c .FromDockerfile . BuildOptionsModifier != nil {
441- c .FromDockerfile . BuildOptionsModifier (& buildOptions )
442+ if c .BuildOptionsModifier != nil {
443+ c .BuildOptionsModifier (& buildOptions )
442444 }
443445
444446 // apply mandatory values after the modifier
@@ -505,15 +507,15 @@ func (c *ContainerRequest) BuildOptions() (types.ImageBuildOptions, error) {
505507}
506508
507509func (c * ContainerRequest ) validateContextAndImage () error {
508- if c .FromDockerfile . Context != "" && c .Image != "" {
510+ if c .Context != "" && c .Image != "" {
509511 return errors .New ("you cannot specify both an Image and Context in a ContainerRequest" )
510512 }
511513
512514 return nil
513515}
514516
515517func (c * ContainerRequest ) validateContextOrImageIsSpecified () error {
516- if c .FromDockerfile . Context == "" && c . FromDockerfile .ContextArchive == nil && c .Image == "" {
518+ if c .Context == "" && c .ContextArchive == nil && c .Image == "" {
517519 return errors .New ("you must specify either a build context or an image" )
518520 }
519521
0 commit comments