You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"Godeps","path":"Godeps","contentType":"directory"},{"name":"builder","path":"builder","contentType":"directory"},{"name":"command","path":"command","contentType":"directory"},{"name":"common","path":"common","contentType":"directory"},{"name":"communicator","path":"communicator","contentType":"directory"},{"name":"contrib","path":"contrib","contentType":"directory"},{"name":"examples","path":"examples","contentType":"directory"},{"name":"fix","path":"fix","contentType":"directory"},{"name":"helper","path":"helper","contentType":"directory"},{"name":"packer","path":"packer","contentType":"directory"},{"name":"plugin","path":"plugin","contentType":"directory"},{"name":"post-processor","path":"post-processor","contentType":"directory"},{"name":"provisioner","path":"provisioner","contentType":"directory"},{"name":"scripts","path":"scripts","contentType":"directory"},{"name":"template","path":"template","contentType":"directory"},{"name":"test","path":"test","contentType":"directory"},{"name":"vendor","path":"vendor","contentType":"directory"},{"name":"version","path":"version","contentType":"directory"},{"name":"website","path":"website","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"CHANGELOG.md","path":"CHANGELOG.md","contentType":"file"},{"name":"CONTRIBUTING.md","path":"CONTRIBUTING.md","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"Makefile","path":"Makefile","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"Vagrantfile","path":"Vagrantfile","contentType":"file"},{"name":"appveyor.yml","path":"appveyor.yml","contentType":"file"},{"name":"azure-merge.sh","path":"azure-merge.sh","contentType":"file"},{"name":"checkpoint.go","path":"checkpoint.go","contentType":"file"},{"name":"commands.go","path":"commands.go","contentType":"file"},{"name":"config.go","path":"config.go","contentType":"file"},{"name":"log.go","path":"log.go","contentType":"file"},{"name":"main.go","path":"main.go","contentType":"file"},{"name":"main_test.go","path":"main_test.go","contentType":"file"},{"name":"panic.go","path":"panic.go","contentType":"file"},{"name":"signal.go","path":"signal.go","contentType":"file"},{"name":"stdin.go","path":"stdin.go","contentType":"file"}],"totalCount":39}},"fileTreeProcessingTime":3.631948,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":58517460,"defaultBranch":"master","name":"packer","ownerLogin":"nazo","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2016-05-11T05:46:16.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/27373?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1613685627.444936","canEdit":false,"refType":"branch","currentOid":"e6ae4d9370fa038c17f3162367e4db58b78bf970"},"path":"config.go","currentUser":null,"blob":{"rawLines":["package main","","import (","\t\"encoding/json\"","\t\"fmt\"","\t\"io\"","\t\"log\"","\t\"os/exec\"","\t\"path/filepath\"","\t\"runtime\"","\t\"strings\"","","\t\"github.com/kardianos/osext\"","\t\"github.com/mitchellh/packer/command\"","\t\"github.com/mitchellh/packer/packer\"","\t\"github.com/mitchellh/packer/packer/plugin\"",")","","// PACKERSPACE is used to represent the spaces that separate args for a command","// without being confused with spaces in the path to the command itself.","const PACKERSPACE = \"-PACKERSPACE-\"","","type config struct {","\tDisableCheckpoint bool `json:\"disable_checkpoint\"`","\tDisableCheckpointSignature bool `json:\"disable_checkpoint_signature\"`","\tPluginMinPort uint","\tPluginMaxPort uint","","\tBuilders map[string]string","\tPostProcessors map[string]string `json:\"post-processors\"`","\tProvisioners map[string]string","}","","// Decodes configuration in JSON format from the given io.Reader into","// the config object pointed to.","func decodeConfig(r io.Reader, c *config) error {","\tdecoder := json.NewDecoder(r)","\treturn decoder.Decode(c)","}","","// Discover discovers plugins.","//","// Search the directory of the executable, then the plugins directory, and","// finally the CWD, in that order. Any conflicts will overwrite previously","// found plugins, in that order.","// Hence, the priority order is the reverse of the search order - i.e., the","// CWD has the highest priority.","func (c *config) Discover() error {","\t// First, look in the same directory as the executable.","\texePath, err := osext.Executable()","\tif err != nil {","\t\tlog.Printf(\"[ERR] Error loading exe directory: %s\", err)","\t} else {","\t\tif err := c.discover(filepath.Dir(exePath)); err != nil {","\t\t\treturn err","\t\t}","\t}","","\t// Next, look in the plugins directory.","\tdir, err := packer.ConfigDir()","\tif err != nil {","\t\tlog.Printf(\"[ERR] Error loading config directory: %s\", err)","\t} else {","\t\tif err := c.discover(filepath.Join(dir, \"plugins\")); err != nil {","\t\t\treturn err","\t\t}","\t}","","\t// Next, look in the CWD.","\tif err := c.discover(\".\"); err != nil {","\t\treturn err","\t}","","\t// Finally, try to use an internal plugin. Note that this will not override","\t// any previously-loaded plugins.","\tif err := c.discoverInternal(); err != nil {","\t\treturn err","\t}","","\treturn nil","}","","// This is a proper packer.BuilderFunc that can be used to load packer.Builder","// implementations from the defined plugins.","func (c *config) LoadBuilder(name string) (packer.Builder, error) {","\tlog.Printf(\"Loading builder: %s\\n\", name)","\tbin, ok := c.Builders[name]","\tif !ok {","\t\tlog.Printf(\"Builder not found: %s\\n\", name)","\t\treturn nil, nil","\t}","","\treturn c.pluginClient(bin).Builder()","}","","// This is a proper implementation of packer.HookFunc that can be used","// to load packer.Hook implementations from the defined plugins.","func (c *config) LoadHook(name string) (packer.Hook, error) {","\tlog.Printf(\"Loading hook: %s\\n\", name)","\treturn c.pluginClient(name).Hook()","}","","// This is a proper packer.PostProcessorFunc that can be used to load","// packer.PostProcessor implementations from defined plugins.","func (c *config) LoadPostProcessor(name string) (packer.PostProcessor, error) {","\tlog.Printf(\"Loading post-processor: %s\", name)","\tbin, ok := c.PostProcessors[name]","\tif !ok {","\t\tlog.Printf(\"Post-processor not found: %s\", name)","\t\treturn nil, nil","\t}","","\treturn c.pluginClient(bin).PostProcessor()","}","","// This is a proper packer.ProvisionerFunc that can be used to load","// packer.Provisioner implementations from defined plugins.","func (c *config) LoadProvisioner(name string) (packer.Provisioner, error) {","\tlog.Printf(\"Loading provisioner: %s\\n\", name)","\tbin, ok := c.Provisioners[name]","\tif !ok {","\t\tlog.Printf(\"Provisioner not found: %s\\n\", name)","\t\treturn nil, nil","\t}","","\treturn c.pluginClient(bin).Provisioner()","}","","func (c *config) discover(path string) error {","\tvar err error","","\tif !filepath.IsAbs(path) {","\t\tpath, err = filepath.Abs(path)","\t\tif err != nil {","\t\t\treturn err","\t\t}","\t}","","\terr = c.discoverSingle(","\t\tfilepath.Join(path, \"packer-builder-*\"), \u0026c.Builders)","\tif err != nil {","\t\treturn err","\t}","","\terr = c.discoverSingle(","\t\tfilepath.Join(path, \"packer-post-processor-*\"), \u0026c.PostProcessors)","\tif err != nil {","\t\treturn err","\t}","","\terr = c.discoverSingle(","\t\tfilepath.Join(path, \"packer-provisioner-*\"), \u0026c.Provisioners)","\tif err != nil {","\t\treturn err","\t}","","\treturn nil","}","","func (c *config) discoverSingle(glob string, m *map[string]string) error {","\tmatches, err := filepath.Glob(glob)","\tif err != nil {","\t\treturn err","\t}","","\tif *m == nil {","\t\t*m = make(map[string]string)","\t}","","\tprefix := filepath.Base(glob)","\tprefix = prefix[:strings.Index(prefix, \"*\")]","\tfor _, match := range matches {","\t\tfile := filepath.Base(match)","","\t\t// One Windows, ignore any plugins that don't end in .exe.","\t\t// We could do a full PATHEXT parse, but this is probably good enough.","\t\tif runtime.GOOS == \"windows\" \u0026\u0026 strings.ToLower(filepath.Ext(file)) != \".exe\" {","\t\t\tlog.Printf(","\t\t\t\t\"[DEBUG] Ignoring plugin match %s, no exe extension\",","\t\t\t\tmatch)","\t\t\tcontinue","\t\t}","","\t\t// If the filename has a \".\", trim up to there","\t\tif idx := strings.Index(file, \".\"); idx \u003e= 0 {","\t\t\tfile = file[:idx]","\t\t}","","\t\t// Look for foo-bar-baz. The plugin name is \"baz\"","\t\tplugin := file[len(prefix):]","\t\tlog.Printf(\"[DEBUG] Discovered plugin: %s = %s\", plugin, match)","\t\t(*m)[plugin] = match","\t}","","\treturn nil","}","","func (c *config) discoverInternal() error {","\t// Get the packer binary path","\tpackerPath, err := osext.Executable()","\tif err != nil {","\t\tlog.Printf(\"[ERR] Error loading exe directory: %s\", err)","\t\treturn err","\t}","","\tfor builder := range command.Builders {","\t\t_, found := (c.Builders)[builder]","\t\tif !found {","\t\t\tlog.Printf(\"Using internal plugin for %s\", builder)","\t\t\t(c.Builders)[builder] = fmt.Sprintf(\"%s%splugin%spacker-builder-%s\",","\t\t\t\tpackerPath, PACKERSPACE, PACKERSPACE, builder)","\t\t}","\t}","","\tfor provisioner := range command.Provisioners {","\t\t_, found := (c.Provisioners)[provisioner]","\t\tif !found {","\t\t\tlog.Printf(\"Using internal plugin for %s\", provisioner)","\t\t\t(c.Provisioners)[provisioner] = fmt.Sprintf(","\t\t\t\t\"%s%splugin%spacker-provisioner-%s\",","\t\t\t\tpackerPath, PACKERSPACE, PACKERSPACE, provisioner)","\t\t}","\t}","","\tfor postProcessor := range command.PostProcessors {","\t\t_, found := (c.PostProcessors)[postProcessor]","\t\tif !found {","\t\t\tlog.Printf(\"Using internal plugin for %s\", postProcessor)","\t\t\t(c.PostProcessors)[postProcessor] = fmt.Sprintf(","\t\t\t\t\"%s%splugin%spacker-post-processor-%s\",","\t\t\t\tpackerPath, PACKERSPACE, PACKERSPACE, postProcessor)","\t\t}","\t}","","\treturn nil","}","","func (c *config) pluginClient(path string) *plugin.Client {","\toriginalPath := path","","\t// First attempt to find the executable by consulting the PATH.","\tpath, err := exec.LookPath(path)","\tif err != nil {","\t\t// If that doesn't work, look for it in the same directory","\t\t// as the `packer` executable (us).","\t\tlog.Printf(\"Plugin could not be found. Checking same directory as executable.\")","\t\texePath, err := osext.Executable()","\t\tif err != nil {","\t\t\tlog.Printf(\"Couldn't get current exe path: %s\", err)","\t\t} else {","\t\t\tlog.Printf(\"Current exe path: %s\", exePath)","\t\t\tpath = filepath.Join(filepath.Dir(exePath), filepath.Base(originalPath))","\t\t}","\t}","","\t// Check for special case using `packer plugin PLUGIN`","\targs := []string{}","\tif strings.Contains(path, PACKERSPACE) {","\t\tparts := strings.Split(path, PACKERSPACE)","\t\tpath = parts[0]","\t\targs = parts[1:]","\t}","","\t// If everything failed, just use the original path and let the error","\t// bubble through.","\tif path == \"\" {","\t\tpath = originalPath","\t}","","\tlog.Printf(\"Creating plugin client for path: %s\", path)","\tvar config plugin.ClientConfig","\tconfig.Cmd = exec.Command(path, args...)","\tconfig.Managed = true","\tconfig.MinPort = c.PluginMinPort","\tconfig.MaxPort = c.PluginMaxPort","\treturn plugin.NewClient(\u0026config)","}"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/nazo/packer/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"config.go","displayUrl":"https://github.com/nazo/packer/blob/master/config.go?raw=true","headerInfo":{"blobSize":"7.39 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"07a64d0","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fnazo%2Fpacker%2Fblob%2Fmaster%2Fconfig.go","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"277","truncatedSloc":"236"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"Go","languageID":132,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/nazo/packer/blob/master/config.go","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/nazo/packer/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/nazo/packer/raw/refs/heads/master/config.go","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":false,"symbols":[{"name":"PACKERSPACE","kind":"constant","ident_start":425,"ident_end":436,"extent_start":439,"extent_end":454,"fully_qualified_name":"PACKERSPACE","ident_utf16":{"start":{"line_number":20,"utf16_col":6},"end":{"line_number":20,"utf16_col":17}},"extent_utf16":{"start":{"line_number":20,"utf16_col":20},"end":{"line_number":20,"utf16_col":35}}},{"name":"config","kind":"class","ident_start":461,"ident_end":467,"extent_start":456,"extent_end":804,"fully_qualified_name":"config","ident_utf16":{"start":{"line_number":22,"utf16_col":5},"end":{"line_number":22,"utf16_col":11}},"extent_utf16":{"start":{"line_number":22,"utf16_col":0},"end":{"line_number":31,"utf16_col":1}}},{"name":"DisableCheckpoint","kind":"field","ident_start":478,"ident_end":495,"extent_start":478,"extent_end":537,"fully_qualified_name":"config.DisableCheckpoint","ident_utf16":{"start":{"line_number":23,"utf16_col":1},"end":{"line_number":23,"utf16_col":18}},"extent_utf16":{"start":{"line_number":23,"utf16_col":1},"end":{"line_number":23,"utf16_col":60}}},{"name":"DisableCheckpointSignature","kind":"field","ident_start":539,"ident_end":565,"extent_start":539,"extent_end":608,"fully_qualified_name":"config.DisableCheckpointSignature","ident_utf16":{"start":{"line_number":24,"utf16_col":1},"end":{"line_number":24,"utf16_col":27}},"extent_utf16":{"start":{"line_number":24,"utf16_col":1},"end":{"line_number":24,"utf16_col":70}}},{"name":"PluginMinPort","kind":"field","ident_start":610,"ident_end":623,"extent_start":610,"extent_end":641,"fully_qualified_name":"config.PluginMinPort","ident_utf16":{"start":{"line_number":25,"utf16_col":1},"end":{"line_number":25,"utf16_col":14}},"extent_utf16":{"start":{"line_number":25,"utf16_col":1},"end":{"line_number":25,"utf16_col":32}}},{"name":"PluginMaxPort","kind":"field","ident_start":643,"ident_end":656,"extent_start":643,"extent_end":674,"fully_qualified_name":"config.PluginMaxPort","ident_utf16":{"start":{"line_number":26,"utf16_col":1},"end":{"line_number":26,"utf16_col":14}},"extent_utf16":{"start":{"line_number":26,"utf16_col":1},"end":{"line_number":26,"utf16_col":32}}},{"name":"Builders","kind":"field","ident_start":677,"ident_end":685,"extent_start":677,"extent_end":709,"fully_qualified_name":"config.Builders","ident_utf16":{"start":{"line_number":28,"utf16_col":1},"end":{"line_number":28,"utf16_col":9}},"extent_utf16":{"start":{"line_number":28,"utf16_col":1},"end":{"line_number":28,"utf16_col":33}}},{"name":"PostProcessors","kind":"field","ident_start":711,"ident_end":725,"extent_start":711,"extent_end":768,"fully_qualified_name":"config.PostProcessors","ident_utf16":{"start":{"line_number":29,"utf16_col":1},"end":{"line_number":29,"utf16_col":15}},"extent_utf16":{"start":{"line_number":29,"utf16_col":1},"end":{"line_number":29,"utf16_col":58}}},{"name":"Provisioners","kind":"field","ident_start":770,"ident_end":782,"extent_start":770,"extent_end":802,"fully_qualified_name":"config.Provisioners","ident_utf16":{"start":{"line_number":30,"utf16_col":1},"end":{"line_number":30,"utf16_col":13}},"extent_utf16":{"start":{"line_number":30,"utf16_col":1},"end":{"line_number":30,"utf16_col":33}}},{"name":"decodeConfig","kind":"function","ident_start":914,"ident_end":926,"extent_start":909,"extent_end":1017,"fully_qualified_name":"decodeConfig","ident_utf16":{"start":{"line_number":35,"utf16_col":5},"end":{"line_number":35,"utf16_col":17}},"extent_utf16":{"start":{"line_number":35,"utf16_col":0},"end":{"line_number":38,"utf16_col":1}}},{"name":"Discover","kind":"method","ident_start":1362,"ident_end":1370,"extent_start":1345,"extent_end":2167,"fully_qualified_name":"config.Discover","ident_utf16":{"start":{"line_number":47,"utf16_col":17},"end":{"line_number":47,"utf16_col":25}},"extent_utf16":{"start":{"line_number":47,"utf16_col":0},"end":{"line_number":80,"utf16_col":1}}},{"name":"LoadBuilder","kind":"method","ident_start":2310,"ident_end":2321,"extent_start":2293,"extent_end":2550,"fully_qualified_name":"config.LoadBuilder","ident_utf16":{"start":{"line_number":84,"utf16_col":17},"end":{"line_number":84,"utf16_col":28}},"extent_utf16":{"start":{"line_number":84,"utf16_col":0},"end":{"line_number":93,"utf16_col":1}}},{"name":"LoadHook","kind":"method","ident_start":2705,"ident_end":2713,"extent_start":2688,"extent_end":2827,"fully_qualified_name":"config.LoadHook","ident_utf16":{"start":{"line_number":97,"utf16_col":17},"end":{"line_number":97,"utf16_col":25}},"extent_utf16":{"start":{"line_number":97,"utf16_col":0},"end":{"line_number":100,"utf16_col":1}}},{"name":"LoadPostProcessor","kind":"method","ident_start":2978,"ident_end":2995,"extent_start":2961,"extent_end":3252,"fully_qualified_name":"config.LoadPostProcessor","ident_utf16":{"start":{"line_number":104,"utf16_col":17},"end":{"line_number":104,"utf16_col":34}},"extent_utf16":{"start":{"line_number":104,"utf16_col":0},"end":{"line_number":113,"utf16_col":1}}},{"name":"LoadProvisioner","kind":"method","ident_start":3399,"ident_end":3414,"extent_start":3382,"extent_end":3663,"fully_qualified_name":"config.LoadProvisioner","ident_utf16":{"start":{"line_number":117,"utf16_col":17},"end":{"line_number":117,"utf16_col":32}},"extent_utf16":{"start":{"line_number":117,"utf16_col":0},"end":{"line_number":126,"utf16_col":1}}},{"name":"discover","kind":"method","ident_start":3682,"ident_end":3690,"extent_start":3665,"extent_end":4208,"fully_qualified_name":"config.discover","ident_utf16":{"start":{"line_number":128,"utf16_col":17},"end":{"line_number":128,"utf16_col":25}},"extent_utf16":{"start":{"line_number":128,"utf16_col":0},"end":{"line_number":157,"utf16_col":1}}},{"name":"discoverSingle","kind":"method","ident_start":4227,"ident_end":4241,"extent_start":4210,"extent_end":5179,"fully_qualified_name":"config.discoverSingle","ident_utf16":{"start":{"line_number":159,"utf16_col":17},"end":{"line_number":159,"utf16_col":31}},"extent_utf16":{"start":{"line_number":159,"utf16_col":0},"end":{"line_number":195,"utf16_col":1}}},{"name":"discoverInternal","kind":"method","ident_start":5198,"ident_end":5214,"extent_start":5181,"extent_end":6333,"fully_qualified_name":"config.discoverInternal","ident_utf16":{"start":{"line_number":197,"utf16_col":17},"end":{"line_number":197,"utf16_col":33}},"extent_utf16":{"start":{"line_number":197,"utf16_col":0},"end":{"line_number":235,"utf16_col":1}}},{"name":"pluginClient","kind":"method","ident_start":6352,"ident_end":6364,"extent_start":6335,"extent_end":7562,"fully_qualified_name":"config.pluginClient","ident_utf16":{"start":{"line_number":237,"utf16_col":17},"end":{"line_number":237,"utf16_col":29}},"extent_utf16":{"start":{"line_number":237,"utf16_col":0},"end":{"line_number":276,"utf16_col":1}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/nazo/packer/branches":{"post":"Vm36WUcwq0VSjfJPIsDl8GdL3Y5IP3wtbw-XYyqVIYv6x01lF_sONMn3g8y7qzJ2lQlqNvhfbTchbSBfX1f9Jg"},"/repos/preferences":{"post":"yVUy3XM65iPu3ocUmMKCduykly2e1fekY2HnKuz9el9H_HLjVRTW3s5xFKiXhgghQBiO9-9r3l5t56chcIjInw"}}},"title":"packer/config.go at master · nazo/packer","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1b17b3e7786a.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}