mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
fix: use madmin.Credentials for gateway interface (#12493)
the main reason is to de-couple the project from depending on MinIO's internal/auth package, other changes will subsequently follow.
This commit is contained in:
parent
0d1d26a4ea
commit
0d1fb10940
@ -17,9 +17,7 @@
|
|||||||
|
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import "github.com/minio/madmin-go"
|
||||||
"github.com/minio/minio/internal/auth"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GatewayMinioSysTmp prefix is used in Azure/GCS gateway for save metadata sent by Initialize Multipart Upload API.
|
// GatewayMinioSysTmp prefix is used in Azure/GCS gateway for save metadata sent by Initialize Multipart Upload API.
|
||||||
const (
|
const (
|
||||||
@ -37,8 +35,5 @@ type Gateway interface {
|
|||||||
Name() string
|
Name() string
|
||||||
|
|
||||||
// NewGatewayLayer returns a new ObjectLayer.
|
// NewGatewayLayer returns a new ObjectLayer.
|
||||||
NewGatewayLayer(creds auth.Credentials) (ObjectLayer, error)
|
NewGatewayLayer(creds madmin.Credentials) (ObjectLayer, error)
|
||||||
|
|
||||||
// Returns true if gateway is ready for production.
|
|
||||||
Production() bool
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/minio/internal/color"
|
"github.com/minio/madmin-go"
|
||||||
xhttp "github.com/minio/minio/internal/http"
|
xhttp "github.com/minio/minio/internal/http"
|
||||||
"github.com/minio/minio/internal/logger"
|
"github.com/minio/minio/internal/logger"
|
||||||
"github.com/minio/pkg/certs"
|
"github.com/minio/pkg/certs"
|
||||||
@ -294,7 +294,10 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
|||||||
|
|
||||||
signal.Notify(globalOSSignalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
|
signal.Notify(globalOSSignalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
|
||||||
|
|
||||||
newObject, err := gw.NewGatewayLayer(globalActiveCred)
|
newObject, err := gw.NewGatewayLayer(madmin.Credentials{
|
||||||
|
AccessKey: globalActiveCred.AccessKey,
|
||||||
|
SecretKey: globalActiveCred.SecretKey,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globalHTTPServer.Shutdown()
|
globalHTTPServer.Shutdown()
|
||||||
logger.FatalIf(err, "Unable to initialize gateway backend")
|
logger.FatalIf(err, "Unable to initialize gateway backend")
|
||||||
@ -350,16 +353,12 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
|||||||
verifyObjectLayerFeatures("gateway "+gatewayName, newObject)
|
verifyObjectLayerFeatures("gateway "+gatewayName, newObject)
|
||||||
|
|
||||||
// Prints the formatted startup message once object layer is initialized.
|
// Prints the formatted startup message once object layer is initialized.
|
||||||
if !globalCLIContext.Quiet {
|
if !globalCLIContext.Quiet && !globalInplaceUpdateDisabled {
|
||||||
mode := globalMinioModeGatewayPrefix + gatewayName
|
|
||||||
// Check update mode.
|
// Check update mode.
|
||||||
checkUpdate(mode)
|
checkUpdate(globalMinioModeGatewayPrefix + gatewayName)
|
||||||
|
}
|
||||||
// Print a warning message if gateway is not ready for production before the startup banner.
|
|
||||||
if !gw.Production() {
|
|
||||||
logStartupMessage(color.Yellow(" *** Warning: Not Ready for Production ***"))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if !globalCLIContext.Quiet {
|
||||||
// Print gateway startup message.
|
// Print gateway startup message.
|
||||||
printGatewayStartupMessage(getAPIEndpoints(), gatewayName)
|
printGatewayStartupMessage(getAPIEndpoints(), gatewayName)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ import (
|
|||||||
"github.com/minio/madmin-go"
|
"github.com/minio/madmin-go"
|
||||||
miniogopolicy "github.com/minio/minio-go/v7/pkg/policy"
|
miniogopolicy "github.com/minio/minio-go/v7/pkg/policy"
|
||||||
minio "github.com/minio/minio/cmd"
|
minio "github.com/minio/minio/cmd"
|
||||||
"github.com/minio/minio/internal/auth"
|
|
||||||
"github.com/minio/minio/internal/logger"
|
"github.com/minio/minio/internal/logger"
|
||||||
"github.com/minio/pkg/bucket/policy"
|
"github.com/minio/pkg/bucket/policy"
|
||||||
"github.com/minio/pkg/bucket/policy/condition"
|
"github.com/minio/pkg/bucket/policy/condition"
|
||||||
@ -138,14 +137,14 @@ func (g *Azure) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewGatewayLayer initializes azure blob storage client and returns AzureObjects.
|
// NewGatewayLayer initializes azure blob storage client and returns AzureObjects.
|
||||||
func (g *Azure) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
func (g *Azure) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// Override credentials from the Azure storage environment variables if specified
|
// Override credentials from the Azure storage environment variables if specified
|
||||||
if acc, key := env.Get("AZURE_STORAGE_ACCOUNT", creds.AccessKey), env.Get("AZURE_STORAGE_KEY", creds.SecretKey); acc != "" && key != "" {
|
if acc, key := env.Get("AZURE_STORAGE_ACCOUNT", creds.AccessKey), env.Get("AZURE_STORAGE_KEY", creds.SecretKey); acc != "" && key != "" {
|
||||||
creds, err = auth.CreateCredentials(acc, key)
|
creds = madmin.Credentials{
|
||||||
if err != nil {
|
AccessKey: acc,
|
||||||
return nil, err
|
SecretKey: key,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,11 +243,6 @@ func parseStorageEndpoint(host string, accountName string) (*url.URL, error) {
|
|||||||
return url.Parse(endpoint)
|
return url.Parse(endpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Production - Azure gateway is production ready.
|
|
||||||
func (g *Azure) Production() bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// s3MetaToAzureProperties converts metadata meant for S3 PUT/COPY
|
// s3MetaToAzureProperties converts metadata meant for S3 PUT/COPY
|
||||||
// object into Azure data structures - BlobMetadata and
|
// object into Azure data structures - BlobMetadata and
|
||||||
// BlobProperties.
|
// BlobProperties.
|
||||||
|
@ -40,7 +40,6 @@ import (
|
|||||||
"github.com/minio/madmin-go"
|
"github.com/minio/madmin-go"
|
||||||
miniogopolicy "github.com/minio/minio-go/v7/pkg/policy"
|
miniogopolicy "github.com/minio/minio-go/v7/pkg/policy"
|
||||||
minio "github.com/minio/minio/cmd"
|
minio "github.com/minio/minio/cmd"
|
||||||
"github.com/minio/minio/internal/auth"
|
|
||||||
"github.com/minio/minio/internal/logger"
|
"github.com/minio/minio/internal/logger"
|
||||||
"github.com/minio/pkg/bucket/policy"
|
"github.com/minio/pkg/bucket/policy"
|
||||||
"github.com/minio/pkg/bucket/policy/condition"
|
"github.com/minio/pkg/bucket/policy/condition"
|
||||||
@ -164,7 +163,7 @@ func (g *GCS) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewGatewayLayer returns gcs ObjectLayer.
|
// NewGatewayLayer returns gcs ObjectLayer.
|
||||||
func (g *GCS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
func (g *GCS) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error) {
|
||||||
ctx := minio.GlobalContext
|
ctx := minio.GlobalContext
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@ -206,11 +205,6 @@ func (g *GCS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error)
|
|||||||
return gcs, nil
|
return gcs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Production - GCS gateway is production ready.
|
|
||||||
func (g *GCS) Production() bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stored in gcs.json - Contents of this file is not used anywhere. It can be
|
// Stored in gcs.json - Contents of this file is not used anywhere. It can be
|
||||||
// used for debugging purposes.
|
// used for debugging purposes.
|
||||||
type gcsMultipartMetaV1 struct {
|
type gcsMultipartMetaV1 struct {
|
||||||
|
@ -41,7 +41,6 @@ import (
|
|||||||
"github.com/minio/madmin-go"
|
"github.com/minio/madmin-go"
|
||||||
"github.com/minio/minio-go/v7/pkg/s3utils"
|
"github.com/minio/minio-go/v7/pkg/s3utils"
|
||||||
minio "github.com/minio/minio/cmd"
|
minio "github.com/minio/minio/cmd"
|
||||||
"github.com/minio/minio/internal/auth"
|
|
||||||
"github.com/minio/minio/internal/logger"
|
"github.com/minio/minio/internal/logger"
|
||||||
xnet "github.com/minio/minio/internal/net"
|
xnet "github.com/minio/minio/internal/net"
|
||||||
"github.com/minio/pkg/env"
|
"github.com/minio/pkg/env"
|
||||||
@ -158,7 +157,7 @@ func getKerberosClient() (*krb.Client, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewGatewayLayer returns hdfs gatewaylayer.
|
// NewGatewayLayer returns hdfs gatewaylayer.
|
||||||
func (g *HDFS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
func (g *HDFS) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error) {
|
||||||
dialFunc := (&net.Dialer{
|
dialFunc := (&net.Dialer{
|
||||||
Timeout: 30 * time.Second,
|
Timeout: 30 * time.Second,
|
||||||
KeepAlive: 30 * time.Second,
|
KeepAlive: 30 * time.Second,
|
||||||
@ -223,11 +222,6 @@ func (g *HDFS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error
|
|||||||
return &hdfsObjects{clnt: clnt, subPath: commonPath, listPool: minio.NewTreeWalkPool(time.Minute * 30)}, nil
|
return &hdfsObjects{clnt: clnt, subPath: commonPath, listPool: minio.NewTreeWalkPool(time.Minute * 30)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Production - hdfs gateway is production ready.
|
|
||||||
func (g *HDFS) Production() bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *hdfsObjects) Shutdown(ctx context.Context) error {
|
func (n *hdfsObjects) Shutdown(ctx context.Context) error {
|
||||||
return n.clnt.Close()
|
return n.clnt.Close()
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/madmin-go"
|
"github.com/minio/madmin-go"
|
||||||
minio "github.com/minio/minio/cmd"
|
minio "github.com/minio/minio/cmd"
|
||||||
"github.com/minio/minio/internal/auth"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -86,7 +85,7 @@ func (g *NAS) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewGatewayLayer returns nas gatewaylayer.
|
// NewGatewayLayer returns nas gatewaylayer.
|
||||||
func (g *NAS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
func (g *NAS) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error) {
|
||||||
var err error
|
var err error
|
||||||
newObject, err := minio.NewFSObjectLayer(g.path)
|
newObject, err := minio.NewFSObjectLayer(g.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -95,11 +94,6 @@ func (g *NAS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error)
|
|||||||
return &nasObjects{newObject}, nil
|
return &nasObjects{newObject}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Production - nas gateway is production ready.
|
|
||||||
func (g *NAS) Production() bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsListenSupported returns whether listen bucket notification is applicable for this gateway.
|
// IsListenSupported returns whether listen bucket notification is applicable for this gateway.
|
||||||
func (n *nasObjects) IsListenSupported() bool {
|
func (n *nasObjects) IsListenSupported() bool {
|
||||||
return false
|
return false
|
||||||
|
@ -34,7 +34,6 @@ import (
|
|||||||
"github.com/minio/minio-go/v7/pkg/s3utils"
|
"github.com/minio/minio-go/v7/pkg/s3utils"
|
||||||
"github.com/minio/minio-go/v7/pkg/tags"
|
"github.com/minio/minio-go/v7/pkg/tags"
|
||||||
minio "github.com/minio/minio/cmd"
|
minio "github.com/minio/minio/cmd"
|
||||||
"github.com/minio/minio/internal/auth"
|
|
||||||
xhttp "github.com/minio/minio/internal/http"
|
xhttp "github.com/minio/minio/internal/http"
|
||||||
"github.com/minio/minio/internal/logger"
|
"github.com/minio/minio/internal/logger"
|
||||||
"github.com/minio/pkg/bucket/policy"
|
"github.com/minio/pkg/bucket/policy"
|
||||||
@ -205,7 +204,7 @@ func newS3(urlStr string, tripper http.RoundTripper) (*miniogo.Core, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewGatewayLayer returns s3 ObjectLayer.
|
// NewGatewayLayer returns s3 ObjectLayer.
|
||||||
func (g *S3) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
func (g *S3) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error) {
|
||||||
metrics := minio.NewMetrics()
|
metrics := minio.NewMetrics()
|
||||||
|
|
||||||
t := &minio.MetricsTransport{
|
t := &minio.MetricsTransport{
|
||||||
@ -250,11 +249,6 @@ func (g *S3) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error)
|
|||||||
return &s, nil
|
return &s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Production - s3 gateway is production ready.
|
|
||||||
func (g *S3) Production() bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// s3Objects implements gateway for MinIO and S3 compatible object storage servers.
|
// s3Objects implements gateway for MinIO and S3 compatible object storage servers.
|
||||||
type s3Objects struct {
|
type s3Objects struct {
|
||||||
minio.GatewayUnsupported
|
minio.GatewayUnsupported
|
||||||
|
Loading…
Reference in New Issue
Block a user