internals.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. package dockerfile
  2. // internals for handling commands. Covers many areas and a lot of
  3. // non-contiguous functionality. Please read the comments.
  4. import (
  5. "crypto/sha256"
  6. "encoding/hex"
  7. "fmt"
  8. "io"
  9. "io/ioutil"
  10. "net/http"
  11. "net/url"
  12. "os"
  13. "path/filepath"
  14. "runtime"
  15. "sort"
  16. "strings"
  17. "time"
  18. "github.com/Sirupsen/logrus"
  19. "github.com/docker/docker/api"
  20. "github.com/docker/docker/api/types"
  21. "github.com/docker/docker/builder"
  22. "github.com/docker/docker/builder/dockerfile/parser"
  23. "github.com/docker/docker/daemon"
  24. "github.com/docker/docker/image"
  25. "github.com/docker/docker/pkg/archive"
  26. "github.com/docker/docker/pkg/httputils"
  27. "github.com/docker/docker/pkg/ioutils"
  28. "github.com/docker/docker/pkg/jsonmessage"
  29. "github.com/docker/docker/pkg/progress"
  30. "github.com/docker/docker/pkg/streamformatter"
  31. "github.com/docker/docker/pkg/stringid"
  32. "github.com/docker/docker/pkg/stringutils"
  33. "github.com/docker/docker/pkg/system"
  34. "github.com/docker/docker/pkg/tarsum"
  35. "github.com/docker/docker/pkg/urlutil"
  36. "github.com/docker/docker/runconfig"
  37. )
  38. func (b *Builder) commit(id string, autoCmd *stringutils.StrSlice, comment string) error {
  39. if b.disableCommit {
  40. return nil
  41. }
  42. if b.image == "" && !b.noBaseImage {
  43. return fmt.Errorf("Please provide a source image with `from` prior to commit")
  44. }
  45. b.runConfig.Image = b.image
  46. if id == "" {
  47. cmd := b.runConfig.Cmd
  48. if runtime.GOOS != "windows" {
  49. b.runConfig.Cmd = stringutils.NewStrSlice("/bin/sh", "-c", "#(nop) "+comment)
  50. } else {
  51. b.runConfig.Cmd = stringutils.NewStrSlice("cmd", "/S /C", "REM (nop) "+comment)
  52. }
  53. defer func(cmd *stringutils.StrSlice) { b.runConfig.Cmd = cmd }(cmd)
  54. hit, err := b.probeCache()
  55. if err != nil {
  56. return err
  57. } else if hit {
  58. return nil
  59. }
  60. id, err = b.create()
  61. if err != nil {
  62. return err
  63. }
  64. }
  65. // Note: Actually copy the struct
  66. autoConfig := *b.runConfig
  67. autoConfig.Cmd = autoCmd
  68. commitCfg := &types.ContainerCommitConfig{
  69. Author: b.maintainer,
  70. Pause: true,
  71. Config: &autoConfig,
  72. }
  73. // Commit the container
  74. imageID, err := b.docker.Commit(id, commitCfg)
  75. if err != nil {
  76. return err
  77. }
  78. b.image = imageID
  79. return nil
  80. }
  81. type copyInfo struct {
  82. builder.FileInfo
  83. decompress bool
  84. }
  85. func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalDecompression bool, cmdName string) error {
  86. if b.context == nil {
  87. return fmt.Errorf("No context given. Impossible to use %s", cmdName)
  88. }
  89. if len(args) < 2 {
  90. return fmt.Errorf("Invalid %s format - at least two arguments required", cmdName)
  91. }
  92. // Work in daemon-specific filepath semantics
  93. dest := filepath.FromSlash(args[len(args)-1]) // last one is always the dest
  94. b.runConfig.Image = b.image
  95. var infos []copyInfo
  96. // Loop through each src file and calculate the info we need to
  97. // do the copy (e.g. hash value if cached). Don't actually do
  98. // the copy until we've looked at all src files
  99. var err error
  100. for _, orig := range args[0 : len(args)-1] {
  101. var fi builder.FileInfo
  102. decompress := allowLocalDecompression
  103. if urlutil.IsURL(orig) {
  104. if !allowRemote {
  105. return fmt.Errorf("Source can't be a URL for %s", cmdName)
  106. }
  107. fi, err = b.download(orig)
  108. if err != nil {
  109. return err
  110. }
  111. defer os.RemoveAll(filepath.Dir(fi.Path()))
  112. decompress = false
  113. infos = append(infos, copyInfo{fi, decompress})
  114. continue
  115. }
  116. // not a URL
  117. subInfos, err := b.calcCopyInfo(cmdName, orig, allowLocalDecompression, true)
  118. if err != nil {
  119. return err
  120. }
  121. infos = append(infos, subInfos...)
  122. }
  123. if len(infos) == 0 {
  124. return fmt.Errorf("No source files were specified")
  125. }
  126. if len(infos) > 1 && !strings.HasSuffix(dest, string(os.PathSeparator)) {
  127. return fmt.Errorf("When using %s with more than one source file, the destination must be a directory and end with a /", cmdName)
  128. }
  129. // For backwards compat, if there's just one info then use it as the
  130. // cache look-up string, otherwise hash 'em all into one
  131. var srcHash string
  132. var origPaths string
  133. if len(infos) == 1 {
  134. fi := infos[0].FileInfo
  135. origPaths = fi.Name()
  136. if hfi, ok := fi.(builder.Hashed); ok {
  137. srcHash = hfi.Hash()
  138. }
  139. } else {
  140. var hashs []string
  141. var origs []string
  142. for _, info := range infos {
  143. fi := info.FileInfo
  144. origs = append(origs, fi.Name())
  145. if hfi, ok := fi.(builder.Hashed); ok {
  146. hashs = append(hashs, hfi.Hash())
  147. }
  148. }
  149. hasher := sha256.New()
  150. hasher.Write([]byte(strings.Join(hashs, ",")))
  151. srcHash = "multi:" + hex.EncodeToString(hasher.Sum(nil))
  152. origPaths = strings.Join(origs, " ")
  153. }
  154. cmd := b.runConfig.Cmd
  155. if runtime.GOOS != "windows" {
  156. b.runConfig.Cmd = stringutils.NewStrSlice("/bin/sh", "-c", fmt.Sprintf("#(nop) %s %s in %s", cmdName, srcHash, dest))
  157. } else {
  158. b.runConfig.Cmd = stringutils.NewStrSlice("cmd", "/S", "/C", fmt.Sprintf("REM (nop) %s %s in %s", cmdName, srcHash, dest))
  159. }
  160. defer func(cmd *stringutils.StrSlice) { b.runConfig.Cmd = cmd }(cmd)
  161. if hit, err := b.probeCache(); err != nil {
  162. return err
  163. } else if hit {
  164. return nil
  165. }
  166. container, err := b.docker.ContainerCreate(&daemon.ContainerCreateConfig{Config: b.runConfig})
  167. if err != nil {
  168. return err
  169. }
  170. b.tmpContainers[container.ID] = struct{}{}
  171. comment := fmt.Sprintf("%s %s in %s", cmdName, origPaths, dest)
  172. // Twiddle the destination when its a relative path - meaning, make it
  173. // relative to the WORKINGDIR
  174. if !system.IsAbs(dest) {
  175. hasSlash := strings.HasSuffix(dest, string(os.PathSeparator))
  176. dest = filepath.Join(string(os.PathSeparator), filepath.FromSlash(b.runConfig.WorkingDir), dest)
  177. // Make sure we preserve any trailing slash
  178. if hasSlash {
  179. dest += string(os.PathSeparator)
  180. }
  181. }
  182. for _, info := range infos {
  183. if err := b.docker.BuilderCopy(container.ID, dest, info.FileInfo, info.decompress); err != nil {
  184. return err
  185. }
  186. }
  187. return b.commit(container.ID, cmd, comment)
  188. }
  189. func (b *Builder) download(srcURL string) (fi builder.FileInfo, err error) {
  190. // get filename from URL
  191. u, err := url.Parse(srcURL)
  192. if err != nil {
  193. return
  194. }
  195. path := filepath.FromSlash(u.Path) // Ensure in platform semantics
  196. if strings.HasSuffix(path, string(os.PathSeparator)) {
  197. path = path[:len(path)-1]
  198. }
  199. parts := strings.Split(path, string(os.PathSeparator))
  200. filename := parts[len(parts)-1]
  201. if filename == "" {
  202. err = fmt.Errorf("cannot determine filename from url: %s", u)
  203. return
  204. }
  205. // Initiate the download
  206. resp, err := httputils.Download(srcURL)
  207. if err != nil {
  208. return
  209. }
  210. // Prepare file in a tmp dir
  211. tmpDir, err := ioutils.TempDir("", "docker-remote")
  212. if err != nil {
  213. return
  214. }
  215. defer func() {
  216. if err != nil {
  217. os.RemoveAll(tmpDir)
  218. }
  219. }()
  220. tmpFileName := filepath.Join(tmpDir, filename)
  221. tmpFile, err := os.OpenFile(tmpFileName, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
  222. if err != nil {
  223. return
  224. }
  225. stdoutFormatter := b.Stdout.(*streamformatter.StdoutFormatter)
  226. progressOutput := stdoutFormatter.StreamFormatter.NewProgressOutput(stdoutFormatter.Writer, true)
  227. progressReader := progress.NewProgressReader(resp.Body, progressOutput, resp.ContentLength, "", "Downloading")
  228. // Download and dump result to tmp file
  229. if _, err = io.Copy(tmpFile, progressReader); err != nil {
  230. tmpFile.Close()
  231. return
  232. }
  233. fmt.Fprintln(b.Stdout)
  234. // ignoring error because the file was already opened successfully
  235. tmpFileSt, err := tmpFile.Stat()
  236. if err != nil {
  237. return
  238. }
  239. tmpFile.Close()
  240. // Set the mtime to the Last-Modified header value if present
  241. // Otherwise just remove atime and mtime
  242. mTime := time.Time{}
  243. lastMod := resp.Header.Get("Last-Modified")
  244. if lastMod != "" {
  245. // If we can't parse it then just let it default to 'zero'
  246. // otherwise use the parsed time value
  247. if parsedMTime, err := http.ParseTime(lastMod); err == nil {
  248. mTime = parsedMTime
  249. }
  250. }
  251. if err = system.Chtimes(tmpFileName, mTime, mTime); err != nil {
  252. return
  253. }
  254. // Calc the checksum, even if we're using the cache
  255. r, err := archive.Tar(tmpFileName, archive.Uncompressed)
  256. if err != nil {
  257. return
  258. }
  259. tarSum, err := tarsum.NewTarSum(r, true, tarsum.Version1)
  260. if err != nil {
  261. return
  262. }
  263. if _, err = io.Copy(ioutil.Discard, tarSum); err != nil {
  264. return
  265. }
  266. hash := tarSum.Sum(nil)
  267. r.Close()
  268. return &builder.HashedFileInfo{FileInfo: builder.PathFileInfo{FileInfo: tmpFileSt, FilePath: tmpFileName}, FileHash: hash}, nil
  269. }
  270. func (b *Builder) calcCopyInfo(cmdName, origPath string, allowLocalDecompression, allowWildcards bool) ([]copyInfo, error) {
  271. // Work in daemon-specific OS filepath semantics
  272. origPath = filepath.FromSlash(origPath)
  273. if origPath != "" && origPath[0] == os.PathSeparator && len(origPath) > 1 {
  274. origPath = origPath[1:]
  275. }
  276. origPath = strings.TrimPrefix(origPath, "."+string(os.PathSeparator))
  277. // Deal with wildcards
  278. if allowWildcards && containsWildcards(origPath) {
  279. var copyInfos []copyInfo
  280. if err := b.context.Walk("", func(path string, info builder.FileInfo, err error) error {
  281. if err != nil {
  282. return err
  283. }
  284. if info.Name() == "" {
  285. // Why are we doing this check?
  286. return nil
  287. }
  288. if match, _ := filepath.Match(origPath, path); !match {
  289. return nil
  290. }
  291. // Note we set allowWildcards to false in case the name has
  292. // a * in it
  293. subInfos, err := b.calcCopyInfo(cmdName, path, allowLocalDecompression, false)
  294. if err != nil {
  295. return err
  296. }
  297. copyInfos = append(copyInfos, subInfos...)
  298. return nil
  299. }); err != nil {
  300. return nil, err
  301. }
  302. return copyInfos, nil
  303. }
  304. // Must be a dir or a file
  305. statPath, fi, err := b.context.Stat(origPath)
  306. if err != nil {
  307. return nil, err
  308. }
  309. copyInfos := []copyInfo{{FileInfo: fi, decompress: allowLocalDecompression}}
  310. hfi, handleHash := fi.(builder.Hashed)
  311. if !handleHash {
  312. return copyInfos, nil
  313. }
  314. // Deal with the single file case
  315. if !fi.IsDir() {
  316. hfi.SetHash("file:" + hfi.Hash())
  317. return copyInfos, nil
  318. }
  319. // Must be a dir
  320. var subfiles []string
  321. err = b.context.Walk(statPath, func(path string, info builder.FileInfo, err error) error {
  322. if err != nil {
  323. return err
  324. }
  325. // we already checked handleHash above
  326. subfiles = append(subfiles, info.(builder.Hashed).Hash())
  327. return nil
  328. })
  329. if err != nil {
  330. return nil, err
  331. }
  332. sort.Strings(subfiles)
  333. hasher := sha256.New()
  334. hasher.Write([]byte(strings.Join(subfiles, ",")))
  335. hfi.SetHash("dir:" + hex.EncodeToString(hasher.Sum(nil)))
  336. return copyInfos, nil
  337. }
  338. func containsWildcards(name string) bool {
  339. for i := 0; i < len(name); i++ {
  340. ch := name[i]
  341. if ch == '\\' {
  342. i++
  343. } else if ch == '*' || ch == '?' || ch == '[' {
  344. return true
  345. }
  346. }
  347. return false
  348. }
  349. func (b *Builder) processImageFrom(img *image.Image) error {
  350. b.image = img.ID().String()
  351. if img.Config != nil {
  352. b.runConfig = img.Config
  353. }
  354. // The default path will be blank on Windows (set by HCS)
  355. if len(b.runConfig.Env) == 0 && system.DefaultPathEnv != "" {
  356. b.runConfig.Env = append(b.runConfig.Env, "PATH="+system.DefaultPathEnv)
  357. }
  358. // Process ONBUILD triggers if they exist
  359. if nTriggers := len(b.runConfig.OnBuild); nTriggers != 0 {
  360. word := "trigger"
  361. if nTriggers > 1 {
  362. word = "triggers"
  363. }
  364. fmt.Fprintf(b.Stderr, "# Executing %d build %s...\n", nTriggers, word)
  365. }
  366. // Copy the ONBUILD triggers, and remove them from the config, since the config will be committed.
  367. onBuildTriggers := b.runConfig.OnBuild
  368. b.runConfig.OnBuild = []string{}
  369. // parse the ONBUILD triggers by invoking the parser
  370. for _, step := range onBuildTriggers {
  371. ast, err := parser.Parse(strings.NewReader(step))
  372. if err != nil {
  373. return err
  374. }
  375. for i, n := range ast.Children {
  376. switch strings.ToUpper(n.Value) {
  377. case "ONBUILD":
  378. return fmt.Errorf("Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed")
  379. case "MAINTAINER", "FROM":
  380. return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", n.Value)
  381. }
  382. if err := b.dispatch(i, n); err != nil {
  383. return err
  384. }
  385. }
  386. }
  387. return nil
  388. }
  389. // probeCache checks if `b.docker` implements builder.ImageCache and image-caching
  390. // is enabled (`b.UseCache`).
  391. // If so attempts to look up the current `b.image` and `b.runConfig` pair with `b.docker`.
  392. // If an image is found, probeCache returns `(true, nil)`.
  393. // If no image is found, it returns `(false, nil)`.
  394. // If there is any error, it returns `(false, err)`.
  395. func (b *Builder) probeCache() (bool, error) {
  396. c, ok := b.docker.(builder.ImageCache)
  397. if !ok || !b.UseCache || b.cacheBusted {
  398. return false, nil
  399. }
  400. cache, err := c.GetCachedImage(b.image, b.runConfig)
  401. if err != nil {
  402. return false, err
  403. }
  404. if len(cache) == 0 {
  405. logrus.Debugf("[BUILDER] Cache miss: %s", b.runConfig.Cmd)
  406. b.cacheBusted = true
  407. return false, nil
  408. }
  409. fmt.Fprintf(b.Stdout, " ---> Using cache\n")
  410. logrus.Debugf("[BUILDER] Use cached version: %s", b.runConfig.Cmd)
  411. b.image = string(cache)
  412. return true, nil
  413. }
  414. func (b *Builder) create() (string, error) {
  415. if b.image == "" && !b.noBaseImage {
  416. return "", fmt.Errorf("Please provide a source image with `from` prior to run")
  417. }
  418. b.runConfig.Image = b.image
  419. resources := runconfig.Resources{
  420. CgroupParent: b.CgroupParent,
  421. CPUShares: b.CPUShares,
  422. CPUPeriod: b.CPUPeriod,
  423. CPUQuota: b.CPUQuota,
  424. CpusetCpus: b.CPUSetCpus,
  425. CpusetMems: b.CPUSetMems,
  426. Memory: b.Memory,
  427. MemorySwap: b.MemorySwap,
  428. Ulimits: b.Ulimits,
  429. }
  430. // TODO: why not embed a hostconfig in builder?
  431. hostConfig := &runconfig.HostConfig{
  432. Isolation: b.Isolation,
  433. ShmSize: b.ShmSize,
  434. Resources: resources,
  435. }
  436. config := *b.runConfig
  437. // Create the container
  438. c, err := b.docker.ContainerCreate(&daemon.ContainerCreateConfig{
  439. Config: b.runConfig,
  440. HostConfig: hostConfig,
  441. })
  442. if err != nil {
  443. return "", err
  444. }
  445. for _, warning := range c.Warnings {
  446. fmt.Fprintf(b.Stdout, " ---> [Warning] %s\n", warning)
  447. }
  448. b.tmpContainers[c.ID] = struct{}{}
  449. fmt.Fprintf(b.Stdout, " ---> Running in %s\n", stringid.TruncateID(c.ID))
  450. if config.Cmd.Len() > 0 {
  451. // override the entry point that may have been picked up from the base image
  452. if err := b.docker.ContainerUpdateCmd(c.ID, config.Cmd.Slice()); err != nil {
  453. return "", err
  454. }
  455. }
  456. return c.ID, nil
  457. }
  458. func (b *Builder) run(cID string) (err error) {
  459. errCh := make(chan error)
  460. if b.Verbose {
  461. go func() {
  462. errCh <- b.docker.ContainerWsAttachWithLogs(cID, &daemon.ContainerWsAttachWithLogsConfig{
  463. OutStream: b.Stdout,
  464. ErrStream: b.Stderr,
  465. Stream: true,
  466. })
  467. }()
  468. }
  469. finished := make(chan struct{})
  470. defer close(finished)
  471. go func() {
  472. select {
  473. case <-b.cancelled:
  474. logrus.Debugln("Build cancelled, killing and removing container:", cID)
  475. b.docker.ContainerKill(cID, 0)
  476. b.removeContainer(cID)
  477. case <-finished:
  478. }
  479. }()
  480. if err := b.docker.ContainerStart(cID, nil); err != nil {
  481. return err
  482. }
  483. if b.Verbose {
  484. // Block on reading output from container, stop on err or chan closed
  485. if err := <-errCh; err != nil {
  486. return err
  487. }
  488. }
  489. if ret, _ := b.docker.ContainerWait(cID, -1); ret != 0 {
  490. // TODO: change error type, because jsonmessage.JSONError assumes HTTP
  491. return &jsonmessage.JSONError{
  492. Message: fmt.Sprintf("The command '%s' returned a non-zero code: %d", b.runConfig.Cmd.ToString(), ret),
  493. Code: ret,
  494. }
  495. }
  496. return nil
  497. }
  498. func (b *Builder) removeContainer(c string) error {
  499. rmConfig := &types.ContainerRmConfig{
  500. ForceRemove: true,
  501. RemoveVolume: true,
  502. }
  503. if err := b.docker.ContainerRm(c, rmConfig); err != nil {
  504. fmt.Fprintf(b.Stdout, "Error removing intermediate container %s: %v\n", stringid.TruncateID(c), err)
  505. return err
  506. }
  507. return nil
  508. }
  509. func (b *Builder) clearTmp() {
  510. for c := range b.tmpContainers {
  511. if err := b.removeContainer(c); err != nil {
  512. return
  513. }
  514. delete(b.tmpContainers, c)
  515. fmt.Fprintf(b.Stdout, "Removing intermediate container %s\n", stringid.TruncateID(c))
  516. }
  517. }
  518. // readDockerfile reads a Dockerfile from the current context.
  519. func (b *Builder) readDockerfile() error {
  520. // If no -f was specified then look for 'Dockerfile'. If we can't find
  521. // that then look for 'dockerfile'. If neither are found then default
  522. // back to 'Dockerfile' and use that in the error message.
  523. if b.DockerfileName == "" {
  524. b.DockerfileName = api.DefaultDockerfileName
  525. if _, _, err := b.context.Stat(b.DockerfileName); os.IsNotExist(err) {
  526. lowercase := strings.ToLower(b.DockerfileName)
  527. if _, _, err := b.context.Stat(lowercase); err == nil {
  528. b.DockerfileName = lowercase
  529. }
  530. }
  531. }
  532. f, err := b.context.Open(b.DockerfileName)
  533. if err != nil {
  534. if os.IsNotExist(err) {
  535. return fmt.Errorf("Cannot locate specified Dockerfile: %s", b.DockerfileName)
  536. }
  537. return err
  538. }
  539. if f, ok := f.(*os.File); ok {
  540. // ignoring error because Open already succeeded
  541. fi, err := f.Stat()
  542. if err != nil {
  543. return fmt.Errorf("Unexpected error reading Dockerfile: %v", err)
  544. }
  545. if fi.Size() == 0 {
  546. return fmt.Errorf("The Dockerfile (%s) cannot be empty", b.DockerfileName)
  547. }
  548. }
  549. b.dockerfile, err = parser.Parse(f)
  550. f.Close()
  551. if err != nil {
  552. return err
  553. }
  554. // After the Dockerfile has been parsed, we need to check the .dockerignore
  555. // file for either "Dockerfile" or ".dockerignore", and if either are
  556. // present then erase them from the build context. These files should never
  557. // have been sent from the client but we did send them to make sure that
  558. // we had the Dockerfile to actually parse, and then we also need the
  559. // .dockerignore file to know whether either file should be removed.
  560. // Note that this assumes the Dockerfile has been read into memory and
  561. // is now safe to be removed.
  562. if dockerIgnore, ok := b.context.(builder.DockerIgnoreContext); ok {
  563. dockerIgnore.Process([]string{b.DockerfileName})
  564. }
  565. return nil
  566. }
  567. // determine if build arg is part of built-in args or user
  568. // defined args in Dockerfile at any point in time.
  569. func (b *Builder) isBuildArgAllowed(arg string) bool {
  570. if _, ok := BuiltinAllowedBuildArgs[arg]; ok {
  571. return true
  572. }
  573. if _, ok := b.allowedBuildArgs[arg]; ok {
  574. return true
  575. }
  576. return false
  577. }