diff --git a/go.mod b/go.mod index 9fbbe1e..7b35a47 100644 --- a/go.mod +++ b/go.mod @@ -4,28 +4,26 @@ go 1.18 require ( github.com/avast/retry-go/v4 v4.1.0 - github.com/aws/aws-sdk-go v1.44.34 github.com/creack/pty v1.1.18 github.com/gliderlabs/ssh v0.3.4 github.com/google/uuid v1.3.0 github.com/sethvargo/go-password v0.2.0 github.com/stmcginnis/gofish v0.13.0 - github.com/stretchr/testify v1.7.2 + github.com/stretchr/testify v1.7.4 github.com/vmware/goipmi v0.0.0-20181114221114-2333cd82d702 go.uber.org/zap v1.21.0 - golang.org/x/net v0.0.0-20220614195744-fb05da6f9022 + golang.org/x/net v0.0.0-20220622184535-263ec571b305 ) require ( github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect - golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098 // indirect + golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect + golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 // indirect golang.org/x/text v0.3.7 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index c8e6785..b26fe6b 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/avast/retry-go/v4 v4.1.0 h1:CwudD9anYv6JMVnDuTRlK6kLo4dBamiL+F3U8YDiyfg= github.com/avast/retry-go/v4 v4.1.0/go.mod h1:HqmLvS2VLdStPCGDFjSuZ9pzlTqVRldCI4w2dO4m1Ms= -github.com/aws/aws-sdk-go v1.44.34 h1:+ZtWIbtSGLNB99P8eBrxXfJZgiIouzUbpkf/MNxq2yQ= -github.com/aws/aws-sdk-go v1.44.34/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -16,10 +14,6 @@ github.com/gliderlabs/ssh v0.3.4 h1:+AXBtim7MTKaLVPgvE+3mhewYRawNLTd+jEEz/wExZw= github.com/gliderlabs/ssh v0.3.4/go.mod h1:ZSS+CUoKHDrqVakTfTWUlKSr9MtMFkC4UvtQKD7O914= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -27,9 +21,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pierrre/gotestcover v0.0.0-20160517101806-924dca7d15f0/go.mod h1:4xpMLz7RBWyB+ElzHu8Llua96TRCB3YwX+l5EP1wmHk= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= @@ -38,11 +31,13 @@ github.com/sethvargo/go-password v0.2.0/go.mod h1:Ym4Mr9JXLBycr02MFuVQ/0JHidNetS github.com/stmcginnis/gofish v0.13.0 h1:qq6q3yNt9vw7ZuJxiw87hq9+BdPLsuRQBwl+XoZSz60= github.com/stmcginnis/gofish v0.13.0/go.mod h1:BLDSFTp8pDlf/xDbLZa+F7f7eW0E/CHCboggsu8CznI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.4 h1:wZRexSlwd7ZXfKINDLsO4r7WBt3gTKONc6K/VesHvHM= +github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/vmware/goipmi v0.0.0-20181114221114-2333cd82d702 h1:yx587LNBbOpIxzCBHBiI94Wx8ryIAFlu1w0lDwm64cA= github.com/vmware/goipmi v0.0.0-20181114221114-2333cd82d702/go.mod h1:YiWonbS/PuCtti3wt9jl+FvNEJ7c0nvmjGoEYxdjyk0= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -60,8 +55,8 @@ go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -70,9 +65,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220614195744-fb05da6f9022 h1:0qjDla5xICC2suMtyRH/QqX3B1btXTfNsIt/i4LFgO0= -golang.org/x/net v0.0.0-20220614195744-fb05da6f9022/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220622184535-263ec571b305 h1:dAgbJ2SP4jD6XYfMNLVj0BF21jo2PjChrtGaAvF5M3I= +golang.org/x/net v0.0.0-20220622184535-263ec571b305/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -85,12 +79,10 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098 h1:PgOr27OhUx2IRqGJ2RxAWI4dJQ7bi9cSrB82uzFzfUA= -golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 h1:wEZYwx+kK+KlZ0hpvP2Ls1Xr4+RWnlzGFwPP0aiDjIU= +golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= diff --git a/hal.go b/hal.go index e8338a5..a4e1c1a 100644 --- a/hal.go +++ b/hal.go @@ -174,9 +174,9 @@ type OutBand interface { Console(ssh.Session) error - UpdateBIOS(board, revision string, s3Config *api.S3Config) error + UpdateBIOS(url string) error - UpdateBMC(board, revision string, s3Config *api.S3Config) error + UpdateBMC(url string) error // Returns a connection to the BMC BMCConnection() api.OutBandBMCConnection diff --git a/internal/s3client/s3client.go b/internal/s3client/s3client.go deleted file mode 100644 index 43db5c5..0000000 --- a/internal/s3client/s3client.go +++ /dev/null @@ -1,35 +0,0 @@ -package s3client - -import ( - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/client" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/s3" - "github.com/metal-stack/go-hal/pkg/api" - "time" -) - -func New(cfg *api.S3Config) (*s3.S3, error) { - s, err := newSession(cfg) - if err != nil { - return nil, err - } - return s3.New(s), nil -} - -func newSession(cfg *api.S3Config) (client.ConfigProvider, error) { - dummyRegion := "dummy" // we don't use AWS S3, we don't need a proper region - hostnameImmutable := true - return session.NewSession(&aws.Config{ - Region: &dummyRegion, - Endpoint: &cfg.Url, - Credentials: credentials.NewStaticCredentials(cfg.Key, cfg.Secret, ""), - S3ForcePathStyle: &hostnameImmutable, - SleepDelay: time.Sleep, - Retryer: client.DefaultRetryer{ - NumMaxRetries: 3, - MinRetryDelay: 10 * time.Second, - }, - }) -} diff --git a/internal/vendors/lenovo/lenovo.go b/internal/vendors/lenovo/lenovo.go index acee5e3..3c46995 100644 --- a/internal/vendors/lenovo/lenovo.go +++ b/internal/vendors/lenovo/lenovo.go @@ -2,6 +2,7 @@ package lenovo import ( "fmt" + "github.com/gliderlabs/ssh" "github.com/google/uuid" "github.com/metal-stack/go-hal" @@ -214,11 +215,11 @@ func (ob *outBand) Console(s ssh.Session) error { return errorNotImplemented // https://github.com/metal-stack/go-hal/issues/11 } -func (ob *outBand) UpdateBIOS(board, revision string, s3Config *api.S3Config) error { +func (ob *outBand) UpdateBIOS(url string) error { return nil } -func (ob *outBand) UpdateBMC(board, revision string, s3Config *api.S3Config) error { +func (ob *outBand) UpdateBMC(url string) error { return nil } diff --git a/internal/vendors/supermicro/supermicro.go b/internal/vendors/supermicro/supermicro.go index fc2b3aa..731ce92 100644 --- a/internal/vendors/supermicro/supermicro.go +++ b/internal/vendors/supermicro/supermicro.go @@ -1,12 +1,10 @@ package supermicro import ( - "context" "fmt" "io" - "strings" + "net/http" - "github.com/aws/aws-sdk-go/service/s3" "github.com/gliderlabs/ssh" "github.com/google/uuid" "github.com/metal-stack/go-hal" @@ -14,7 +12,6 @@ import ( "github.com/metal-stack/go-hal/internal/ipmi" "github.com/metal-stack/go-hal/internal/outband" "github.com/metal-stack/go-hal/internal/redfish" - "github.com/metal-stack/go-hal/internal/s3client" uuidendian "github.com/metal-stack/go-hal/internal/uuid-endianness" "github.com/metal-stack/go-hal/pkg/api" "github.com/metal-stack/go-hal/pkg/logger" @@ -276,8 +273,8 @@ func (ob *outBand) Console(s ssh.Session) error { return ob.IpmiTool.OpenConsole(s) } -func (ob *outBand) UpdateBIOS(board, revision string, s3Config *api.S3Config) error { - update, err := ob.downloadFirmwareUpdate("bios", board, revision, s3Config) +func (ob *outBand) UpdateBIOS(url string) error { + update, err := ob.downloadFirmwareUpdate(url) if err != nil { return err } @@ -285,8 +282,8 @@ func (ob *outBand) UpdateBIOS(board, revision string, s3Config *api.S3Config) er return ob.sum.UpdateBIOS(update) } -func (ob *outBand) UpdateBMC(board, revision string, s3Config *api.S3Config) error { - update, err := ob.downloadFirmwareUpdate("bmc", board, revision, s3Config) +func (ob *outBand) UpdateBMC(url string) error { + update, err := ob.downloadFirmwareUpdate(url) if err != nil { return err } @@ -294,19 +291,8 @@ func (ob *outBand) UpdateBMC(board, revision string, s3Config *api.S3Config) err return ob.sum.UpdateBMC(update) } -func (ob *outBand) downloadFirmwareUpdate(kind, board, revision string, s3Config *api.S3Config) (io.Reader, error) { - c, err := s3client.New(s3Config) - if err != nil { - return nil, err - } - - v := strings.ToLower(vendor.String()) - board = strings.ToUpper(board) - key := fmt.Sprintf("%s/%s/%s/%s", kind, v, board, revision) - resp, err := c.GetObjectWithContext(context.Background(), &s3.GetObjectInput{ - Bucket: &s3Config.FirmwareBucket, - Key: &key, - }) +func (ob *outBand) downloadFirmwareUpdate(url string) (io.Reader, error) { + resp, err := http.Get(url) // nolint:gosec if err != nil { return nil, err } diff --git a/internal/vendors/vagrant/vagrant.go b/internal/vendors/vagrant/vagrant.go index f2e1da5..c978db7 100644 --- a/internal/vendors/vagrant/vagrant.go +++ b/internal/vendors/vagrant/vagrant.go @@ -207,11 +207,11 @@ func (ob *outBand) Console(s ssh.Session) error { //Virsh console return console.Open(s, cmd) } -func (ob *outBand) UpdateBIOS(board, revision string, s3Config *api.S3Config) error { +func (ob *outBand) UpdateBIOS(url string) error { return nil } -func (ob *outBand) UpdateBMC(board, revision string, s3Config *api.S3Config) error { +func (ob *outBand) UpdateBMC(url string) error { return nil } diff --git a/pkg/api/types.go b/pkg/api/types.go index 325acbb..ad4ac6f 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -7,13 +7,6 @@ import ( "github.com/metal-stack/go-hal/internal/kernel" ) -type S3Config struct { - Url string - Key string - Secret string - FirmwareBucket string -} - // PasswordConstraints holds the constraints that are ensured for generated passwords type PasswordConstraints struct { Length int