From d830c8be991f3957a4242f503049b626af4c058b Mon Sep 17 00:00:00 2001 From: Jan Boehm <6552713+jeloba@users.noreply.github.com> Date: Mon, 10 Jan 2022 13:44:29 +0100 Subject: [PATCH] Upgrade github.com/docker/cli to v20.10.12 Signed-off-by: Jan Boehm <6552713+jeloba@users.noreply.github.com> --- go.mod | 2 +- go.sum | 2 + vendor/github.com/docker/cli/AUTHORS | 58 +++++++++++++-- .../docker/cli/cli/config/config.go | 71 ++++++++++++------- .../docker/cli/cli/config/configfile/file.go | 39 ++++++++-- .../cli/config/credentials/default_store.go | 2 +- vendor/modules.txt | 2 +- 7 files changed, 137 insertions(+), 39 deletions(-) diff --git a/go.mod b/go.mod index bf9f3eaaf..4f17893ec 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/containerd/containerd v1.4.11 github.com/containerd/continuity v0.0.0-20200413184840-d3ef23f19fbb // indirect github.com/containerd/ttrpc v1.0.1 // indirect - github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492 + github.com/docker/cli v20.10.12+incompatible github.com/docker/distribution v2.7.1+incompatible github.com/docker/docker v1.4.2-0.20200203170920-46ec8731fbce github.com/docker/docker-credential-helpers v0.6.3 // indirect diff --git a/go.sum b/go.sum index 55dcaab50..a26e9265e 100644 --- a/go.sum +++ b/go.sum @@ -208,6 +208,8 @@ github.com/dhui/dktest v0.3.0/go.mod h1:cyzIUfGsBEbZ6BT7tnXqAShHSXCZhSNmFl70sZ7c github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492 h1:FwssHbCDJD025h+BchanCwE1Q8fyMgqDr2mOQAWOLGw= github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v20.10.12+incompatible h1:lZlz0uzG+GH+c0plStMUdF/qk3ppmgnswpR5EbqzVGA= +github.com/docker/cli v20.10.12+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v0.0.0-20191216044856-a8371794149d h1:jC8tT/S0OGx2cswpeUTn4gOIea8P08lD3VFQT0cOZ50= github.com/docker/distribution v0.0.0-20191216044856-a8371794149d/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= github.com/docker/docker v0.7.3-0.20190103212154-2b7e084dc98b/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= diff --git a/vendor/github.com/docker/cli/AUTHORS b/vendor/github.com/docker/cli/AUTHORS index ecb6251ba..8990f85b5 100644 --- a/vendor/github.com/docker/cli/AUTHORS +++ b/vendor/github.com/docker/cli/AUTHORS @@ -8,6 +8,7 @@ Aaron.L.Xu Abdur Rehman Abhinandan Prativadi Abin Shahab +Abreto FU Ace Tang Addam Hardy Adolfo Ochagavía @@ -17,12 +18,15 @@ Adrien Folie Ahmet Alp Balkan Aidan Feldman Aidan Hobson Sayers -AJ Bowen -Akihiro Suda +AJ Bowen +Akhil Mohan +Akihiro Suda Akim Demaille Alan Thompson Albert Callarisa +Albin Kerouanton Aleksa Sarai +Aleksander Piotrowski Alessandro Boch Alex Mavrogiannis Alex Mayer @@ -40,6 +44,7 @@ Amir Goldstein Amit Krishnan Amit Shukla Amy Lindburg +Anca Iordache Anda Xu Andrea Luzzardi Andreas Köhler @@ -49,6 +54,7 @@ Andrew Macpherson Andrew McDonnell Andrew Po Andrey Petrov +Andrii Berehuliak André Martins Andy Goldstein Andy Rothfusz @@ -61,7 +67,9 @@ Antonis Kalipetis Anusha Ragunathan Ao Li Arash Deshmeh +Arko Dasgupta Arnaud Porterie +Arthur Peka Ashwini Oruganti Azat Khuyiyakhmetov Bardia Keyoumarsi @@ -87,6 +95,7 @@ Brent Salisbury Bret Fisher Brian (bex) Exelbierd Brian Goff +Brian Wieder Bryan Bess Bryan Boreham Bryan Murphy @@ -95,6 +104,7 @@ Cameron Spear Cao Weiwei Carlo Mion Carlos Alexandro Becker +Carlos de Paula Ce Gao Cedric Davies Cezar Sa Espinola @@ -128,26 +138,31 @@ Coenraad Loubser Colin Hebert Collin Guarino Colm Hally +Comical Derskeal <27731088+derskeal@users.noreply.github.com> Corey Farrell Corey Quon Craig Wilhite Cristian Staretu Daehyeok Mun Dafydd Crosby +Daisuke Ito dalanlan Damien Nadé Dan Cotora +Daniel Artine Daniel Cassidy Daniel Dao Daniel Farrell Daniel Gasienica Daniel Goosen +Daniel Helfand Daniel Hiltgen Daniel J Walsh Daniel Nephin Daniel Norberg Daniel Watkins Daniel Zhang +Daniil Nikolenko Danny Berger Darren Shepherd Darren Stahl @@ -180,13 +195,15 @@ Dima Stopel Dimitry Andric Ding Fei Diogo Monica +Djordje Lukic Dmitry Gusev Dmitry Smirnov Dmitry V. Krivenok +Dominik Braun Don Kjer Dong Chen Doug Davis -Drew Erny +Drew Erny Ed Costello Elango Sivanandam Eli Uriegas @@ -249,6 +266,7 @@ Harald Albers Harold Cooper Harry Zhang He Simei +Hector S Helen Xie Henning Sprang Henry N @@ -256,6 +274,7 @@ Hernan Garcia Hongbin Lu Hu Keping Huayi Zhang +Hugo Gabriel Eyherabide huqun Huu Nguyen Hyzhou Zhy @@ -297,7 +316,7 @@ Jeremy Unruh Jeremy Yallop Jeroen Franse Jesse Adametz -Jessica Frazelle +Jessica Frazelle Jezeniel Zapanta Jian Zhang Jie Luo @@ -308,6 +327,7 @@ Jimmy Song jimmyxian Jintao Zhang Joao Fernandes +Joe Abbey Joe Doliner Joe Gordon Joel Handwell @@ -317,7 +337,7 @@ Johan Euphrosine Johannes 'fish' Ziemke John Feminella John Harris -John Howard (VM) +John Howard John Laswell John Maguire John Mulhausen @@ -326,12 +346,15 @@ John Stephens John Tims John V. Martinez John Willis +Jon Johnson +Jonatas Baldin Jonathan Boulle Jonathan Lee Jonathan Lomas Jonathan McCrohan Jonh Wendell Jordan Jennings +Jose J. Escobar <53836904+jescobar-docker@users.noreply.github.com> Joseph Kern Josh Bodah Josh Chorlton @@ -369,6 +392,7 @@ Kevin Kern Kevin Kirsche Kevin Meredith Kevin Richardson +Kevin Woblick khaled souf Kim Eik Kir Kolyshkin @@ -406,13 +430,16 @@ Luca Favatella Luca Marturana Lucas Chan Luka Hartwig +Lukas Heeren Lukasz Zajaczkowski Lydell Manganti Lénaïc Huard Ma Shimiao Mabin +Maciej Kalisz Madhav Puri Madhu Venugopal +Madhur Batra Malte Janduda Manjunath A Kumatagi Mansi Nahar @@ -422,6 +449,7 @@ Marco Mariani Marco Vedovati Marcus Martins Marianna Tessel +Marius Ileana Marius Sturm Mark Oates Marsh Macy @@ -467,12 +495,14 @@ mikelinjie <294893458@qq.com> Mikhail Vasin Milind Chawre Mindaugas Rukas +Miroslav Gula Misty Stanley-Jones Mohammad Banikazemi Mohammed Aaqib Ansari Mohini Anne Dsouza Moorthy RS Morgan Bauer +Morten Hekkvang Moysés Borges Mrunal Patel muicoder @@ -503,9 +533,11 @@ Nishant Totla NIWA Hideyuki Noah Treuhaft O.S. Tezer +Odin Ugedal ohmystack Olle Jonsson Olli Janatuinen +Oscar Wieman Otto Kekäläinen Ovidio Mallo Pascal Borreli @@ -515,6 +547,7 @@ Patrick Lang Paul Paul Kehrer Paul Lietar +Paul Mulders Paul Weaver Pavel Pospisil Paweł Szczekutowicz @@ -541,6 +574,7 @@ Qiang Huang Qinglan Peng qudongfang Raghavendra K T +Rahul Zoldyck Ravi Shekhar Jethani Ray Tsang Reficul @@ -553,6 +587,7 @@ Richard Scothern Rick Wieman Ritesh H Shukla Riyaz Faizullabhoy +Rob Gulewich Robert Wallis Robin Naundorf Robin Speekenbrink @@ -574,10 +609,14 @@ Sainath Grandhi Sakeven Jiang Sally O'Malley Sam Neirinck +Samarth Shah Sambuddha Basu Sami Tabet +Samuel Cochran Samuel Karp Santhosh Manohar +Sargun Dhillon +Saswat Bhattacharya Scott Brenner Scott Collier Sean Christopherson @@ -598,6 +637,7 @@ sidharthamani Silvin Lubecki Simei He Simon Ferquel +Simon Heimberg Sindhu S Slava Semushin Solomon Hykes @@ -627,7 +667,10 @@ TAGOMORI Satoshi taiji-tech Taylor Jones Tejaswini Duggaraju +Tengfei Wang +Teppei Fukuda Thatcher Peskens +Thibault Coupin Thomas Gazagnaire Thomas Krzero Thomas Leonard @@ -639,6 +682,7 @@ Tianyi Wang Tibor Vass Tim Dettrick Tim Hockin +Tim Sampson Tim Smith Tim Waugh Tim Wraight @@ -663,9 +707,11 @@ Tristan Carel Tycho Andersen Tycho Andersen uhayate +Ulrich Bareth Ulysses Souza Umesh Yadav Valentin Lorentz +Venkateswara Reddy Bukkasamudram Veres Lajos Victor Vieux Victoria Bialas @@ -683,6 +729,7 @@ Wang Long Wang Ping Wang Xing Wang Yuexiao +Wang Yumu <37442693@qq.com> Wataru Ishida Wayne Song Wen Cheng Ma @@ -691,6 +738,7 @@ Wes Morgan Wewang Xiaorenfine William Henry Xianglin Gao +Xiaodong Liu Xiaodong Zhang Xiaoxi He Xinbo Weng diff --git a/vendor/github.com/docker/cli/cli/config/config.go b/vendor/github.com/docker/cli/cli/config/config.go index 6e4d73dfa..93275f3d9 100644 --- a/vendor/github.com/docker/cli/cli/config/config.go +++ b/vendor/github.com/docker/cli/cli/config/config.go @@ -6,6 +6,7 @@ import ( "os" "path/filepath" "strings" + "sync" "github.com/docker/cli/cli/config/configfile" "github.com/docker/cli/cli/config/credentials" @@ -23,17 +24,44 @@ const ( ) var ( - configDir = os.Getenv("DOCKER_CONFIG") + initConfigDir = new(sync.Once) + configDir string + homeDir string ) -func init() { +// resetHomeDir is used in testing to reset the "homeDir" package variable to +// force re-lookup of the home directory between tests. +func resetHomeDir() { + homeDir = "" +} + +func getHomeDir() string { + if homeDir == "" { + homeDir = homedir.Get() + } + return homeDir +} + +// resetConfigDir is used in testing to reset the "configDir" package variable +// and its sync.Once to force re-lookup between tests. +func resetConfigDir() { + configDir = "" + initConfigDir = new(sync.Once) +} + +func setConfigDir() { + if configDir != "" { + return + } + configDir = os.Getenv("DOCKER_CONFIG") if configDir == "" { - configDir = filepath.Join(homedir.Get(), configFileDir) + configDir = filepath.Join(getHomeDir(), configFileDir) } } // Dir returns the directory the configuration file is stored in func Dir() string { + initConfigDir.Do(setConfigDir) return configDir } @@ -76,10 +104,15 @@ func LoadFromReader(configData io.Reader) (*configfile.ConfigFile, error) { return &configFile, err } +// TODO remove this temporary hack, which is used to warn about the deprecated ~/.dockercfg file +var printLegacyFileWarning bool + // Load reads the configuration files in the given directory, and sets up // the auth config information and returns values. // FIXME: use the internal golang config parser func Load(configDir string) (*configfile.ConfigFile, error) { + printLegacyFileWarning = false + if configDir == "" { configDir = Dir() } @@ -88,11 +121,7 @@ func Load(configDir string) (*configfile.ConfigFile, error) { configFile := configfile.New(filename) // Try happy path first - latest config file - if _, err := os.Stat(filename); err == nil { - file, err := os.Open(filename) - if err != nil { - return configFile, errors.Wrap(err, filename) - } + if file, err := os.Open(filename); err == nil { defer file.Close() err = configFile.LoadFromReader(file) if err != nil { @@ -106,22 +135,13 @@ func Load(configDir string) (*configfile.ConfigFile, error) { } // Can't find latest config file so check for the old one - homedir, err := os.UserHomeDir() - if err != nil { - return configFile, errors.Wrap(err, oldConfigfile) - } - confFile := filepath.Join(homedir, oldConfigfile) - if _, err := os.Stat(confFile); err != nil { - return configFile, nil // missing file is not an error - } - file, err := os.Open(confFile) - if err != nil { - return configFile, errors.Wrap(err, filename) - } - defer file.Close() - err = configFile.LegacyLoadFromReader(file) - if err != nil { - return configFile, errors.Wrap(err, filename) + filename = filepath.Join(getHomeDir(), oldConfigfile) + if file, err := os.Open(filename); err == nil { + printLegacyFileWarning = true + defer file.Close() + if err := configFile.LegacyLoadFromReader(file); err != nil { + return configFile, errors.Wrap(err, filename) + } } return configFile, nil } @@ -133,6 +153,9 @@ func LoadDefaultConfigFile(stderr io.Writer) *configfile.ConfigFile { if err != nil { fmt.Fprintf(stderr, "WARNING: Error loading config file: %v\n", err) } + if printLegacyFileWarning { + _, _ = fmt.Fprintln(stderr, "WARNING: Support for the legacy ~/.dockercfg configuration file and file-format is deprecated and will be removed in an upcoming release") + } if !configFile.ContainsAuth() { configFile.CredentialsStore = credentials.DetectDefaultStore(configFile.CredentialsStore) } diff --git a/vendor/github.com/docker/cli/cli/config/configfile/file.go b/vendor/github.com/docker/cli/cli/config/configfile/file.go index a4e97a5ca..dc9f39eb7 100644 --- a/vendor/github.com/docker/cli/cli/config/configfile/file.go +++ b/vendor/github.com/docker/cli/cli/config/configfile/file.go @@ -13,6 +13,7 @@ import ( "github.com/docker/cli/cli/config/credentials" "github.com/docker/cli/cli/config/types" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) const ( @@ -118,7 +119,7 @@ func (configFile *ConfigFile) LegacyLoadFromReader(configData io.Reader) error { // LoadFromReader reads the configuration data given and sets up the auth config // information with given directory and populates the receiver object func (configFile *ConfigFile) LoadFromReader(configData io.Reader) error { - if err := json.NewDecoder(configData).Decode(&configFile); err != nil { + if err := json.NewDecoder(configData).Decode(&configFile); err != nil && !errors.Is(err, io.EOF) { return err } var err error @@ -168,6 +169,13 @@ func (configFile *ConfigFile) SaveToWriter(writer io.Writer) error { configFile.AuthConfigs = tmpAuthConfigs defer func() { configFile.AuthConfigs = saveAuthConfigs }() + // User-Agent header is automatically set, and should not be stored in the configuration + for v := range configFile.HTTPHeaders { + if strings.EqualFold(v, "User-Agent") { + delete(configFile.HTTPHeaders, v) + } + } + data, err := json.MarshalIndent(configFile, "", "\t") if err != nil { return err @@ -177,7 +185,7 @@ func (configFile *ConfigFile) SaveToWriter(writer io.Writer) error { } // Save encodes and writes out all the authorization information -func (configFile *ConfigFile) Save() error { +func (configFile *ConfigFile) Save() (retErr error) { if configFile.Filename == "" { return errors.Errorf("Can't save config with empty filename") } @@ -190,16 +198,33 @@ func (configFile *ConfigFile) Save() error { if err != nil { return err } + defer func() { + temp.Close() + if retErr != nil { + if err := os.Remove(temp.Name()); err != nil { + logrus.WithError(err).WithField("file", temp.Name()).Debug("Error cleaning up temp file") + } + } + }() + err = configFile.SaveToWriter(temp) - temp.Close() if err != nil { - os.Remove(temp.Name()) return err } - // Try copying the current config file (if any) ownership and permissions - copyFilePermissions(configFile.Filename, temp.Name()) - return os.Rename(temp.Name(), configFile.Filename) + if err := temp.Close(); err != nil { + return errors.Wrap(err, "error closing temp file") + } + + // Handle situation where the configfile is a symlink + cfgFile := configFile.Filename + if f, err := os.Readlink(cfgFile); err == nil { + cfgFile = f + } + + // Try copying the current config file (if any) ownership and permissions + copyFilePermissions(cfgFile, temp.Name()) + return os.Rename(temp.Name(), cfgFile) } // ParseProxyConfig computes proxy configuration by retrieving the config for the provided host and diff --git a/vendor/github.com/docker/cli/cli/config/credentials/default_store.go b/vendor/github.com/docker/cli/cli/config/credentials/default_store.go index 7a760f1a9..402235bff 100644 --- a/vendor/github.com/docker/cli/cli/config/credentials/default_store.go +++ b/vendor/github.com/docker/cli/cli/config/credentials/default_store.go @@ -1,7 +1,7 @@ package credentials import ( - "os/exec" + exec "golang.org/x/sys/execabs" ) // DetectDefaultStore return the default credentials store for the platform if diff --git a/vendor/modules.txt b/vendor/modules.txt index a047dfb04..032ca4090 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -100,7 +100,7 @@ github.com/containerd/continuity/sysx github.com/containerd/ttrpc # github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew/spew -# github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492 +# github.com/docker/cli v20.10.12+incompatible ## explicit github.com/docker/cli/cli/config github.com/docker/cli/cli/config/configfile