Merge pull request #4011 from ks-ci-bot/cherry-pick-3965-to-release-3.1

[release-3.1] Improve the s3 uploader for better performance.
This commit is contained in:
KubeSphere CI Bot
2021-06-27 20:57:23 +08:00
committed by GitHub
102 changed files with 155 additions and 113 deletions

View File

@@ -24,7 +24,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"github.com/pkg/errors" "github.com/pkg/errors"
prommodel "github.com/prometheus/common/model" prommodel "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/pkg/timestamp"

View File

@@ -20,7 +20,7 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"kubesphere.io/kubesphere/pkg/simple/client/auditing" "kubesphere.io/kubesphere/pkg/simple/client/auditing"
) )

View File

@@ -20,7 +20,7 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"kubesphere.io/kubesphere/pkg/simple/client/events" "kubesphere.io/kubesphere/pkg/simple/client/events"
) )

View File

@@ -20,7 +20,7 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"kubesphere.io/kubesphere/pkg/simple/client/logging" "kubesphere.io/kubesphere/pkg/simple/client/logging"
) )

View File

@@ -3,7 +3,7 @@ package v1alpha1
import ( import (
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"kubesphere.io/kubesphere/pkg/apiserver/query" "kubesphere.io/kubesphere/pkg/apiserver/query"
model "kubesphere.io/kubesphere/pkg/models/monitoring" model "kubesphere.io/kubesphere/pkg/models/monitoring"

View File

@@ -21,7 +21,7 @@ import (
"runtime" "runtime"
"strings" "strings"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/klog" "k8s.io/klog"
) )

View File

@@ -23,7 +23,7 @@ package v1alpha1
import ( import (
auditregistrationv1alpha1 "k8s.io/api/auditregistration/v1alpha1" auditregistrationv1alpha1 "k8s.io/api/auditregistration/v1alpha1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
) )

View File

@@ -21,7 +21,7 @@ limitations under the License.
package v1alpha1 package v1alpha1
import ( import (
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
) )

View File

@@ -21,7 +21,7 @@ limitations under the License.
package v1alpha2 package v1alpha2
import ( import (
"k8s.io/api/rbac/v1" v1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
) )

View File

@@ -21,7 +21,7 @@ limitations under the License.
package v1alpha1 package v1alpha1
import ( import (
"k8s.io/api/networking/v1" v1 "k8s.io/api/networking/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
) )

View File

@@ -21,7 +21,7 @@ limitations under the License.
package v2beta1 package v2beta1
import ( import (
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
) )

View File

@@ -21,7 +21,7 @@ limitations under the License.
package v1alpha2 package v1alpha2
import ( import (
"k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
) )

View File

@@ -21,7 +21,7 @@ limitations under the License.
package v1beta1 package v1beta1
import ( import (
"k8s.io/api/rbac/v1" v1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
) )

View File

@@ -30,7 +30,7 @@ import (
"strconv" "strconv"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
urlruntime "k8s.io/apimachinery/pkg/util/runtime" urlruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"

View File

@@ -21,7 +21,7 @@ import (
"testing" "testing"
"golang.org/x/oauth2" "golang.org/x/oauth2"
"gopkg.in/yaml.v3" yaml "gopkg.in/yaml.v3"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/identityprovider" "kubesphere.io/kubesphere/pkg/apiserver/authentication/identityprovider"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth" "kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth"

View File

@@ -30,7 +30,7 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"
"golang.org/x/oauth2" "golang.org/x/oauth2"
"gopkg.in/yaml.v3" yaml "gopkg.in/yaml.v3"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/identityprovider" "kubesphere.io/kubesphere/pkg/apiserver/authentication/identityprovider"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth" "kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth"

View File

@@ -22,7 +22,7 @@ import (
"testing" "testing"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"gopkg.in/yaml.v3" yaml "gopkg.in/yaml.v3"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth" "kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth"
) )

View File

@@ -27,8 +27,8 @@ import (
"kubesphere.io/kubesphere/pkg/utils/sliceutil" "kubesphere.io/kubesphere/pkg/utils/sliceutil"
"github.com/coreos/go-oidc" oidc "github.com/coreos/go-oidc"
"github.com/form3tech-oss/jwt-go" jwt "github.com/dgrijalva/jwt-go"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"golang.org/x/oauth2" "golang.org/x/oauth2"

View File

@@ -32,11 +32,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/form3tech-oss/jwt-go" jwt "github.com/dgrijalva/jwt-go"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"
"gopkg.in/square/go-jose.v2" jose "gopkg.in/square/go-jose.v2"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/identityprovider" "kubesphere.io/kubesphere/pkg/apiserver/authentication/identityprovider"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth" "kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth"

View File

@@ -22,7 +22,7 @@ import (
"time" "time"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"gopkg.in/yaml.v3" yaml "gopkg.in/yaml.v3"
) )
func TestDefaultAuthOptions(t *testing.T) { func TestDefaultAuthOptions(t *testing.T) {

View File

@@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/form3tech-oss/jwt-go" jwt "github.com/dgrijalva/jwt-go"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
"k8s.io/klog" "k8s.io/klog"
) )

View File

@@ -24,7 +24,7 @@ import (
"time" "time"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"gopkg.in/yaml.v2" yaml "gopkg.in/yaml.v2"
networkv1alpha1 "kubesphere.io/kubesphere/pkg/apis/network/v1alpha1" networkv1alpha1 "kubesphere.io/kubesphere/pkg/apis/network/v1alpha1"
"kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth" "kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth"

View File

@@ -19,7 +19,7 @@ package query
import ( import (
"strconv" "strconv"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"kubesphere.io/kubesphere/pkg/utils/sliceutil" "kubesphere.io/kubesphere/pkg/utils/sliceutil"

View File

@@ -21,7 +21,7 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
) )

View File

@@ -17,7 +17,7 @@ limitations under the License.
package runtime package runtime
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
) )

View File

@@ -24,7 +24,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@@ -23,7 +23,7 @@ import (
"reflect" "reflect"
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@@ -23,7 +23,7 @@ import (
"reflect" "reflect"
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v1 package v1
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"kubesphere.io/kubesphere/pkg/kapis/generic" "kubesphere.io/kubesphere/pkg/kapis/generic"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v2alpha1 package v2alpha1
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
promresourcesclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned" promresourcesclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned"
"k8s.io/klog" "k8s.io/klog"

View File

@@ -19,7 +19,7 @@ package v2alpha1
import ( import (
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
promresourcesclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned" promresourcesclient "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"

View File

@@ -28,8 +28,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"gopkg.in/yaml.v2" yaml "gopkg.in/yaml.v2"
appsv1 "k8s.io/api/apps/v1" appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"

View File

@@ -19,7 +19,7 @@ package v1alpha1
import ( import (
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
k8sinformers "k8s.io/client-go/informers" k8sinformers "k8s.io/client-go/informers"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v1alpha2 package v1alpha2
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
kubesphereconfig "kubesphere.io/kubesphere/pkg/apiserver/config" kubesphereconfig "kubesphere.io/kubesphere/pkg/apiserver/config"

View File

@@ -23,7 +23,7 @@ import (
"net/http" "net/http"
"strings" "strings"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
log "k8s.io/klog" log "k8s.io/klog"
"k8s.io/klog/v2" "k8s.io/klog/v2"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v1alpha2 package v1alpha2
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api" "kubesphere.io/kubesphere/pkg/api"

View File

@@ -22,7 +22,7 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/proxy" "k8s.io/apimachinery/pkg/util/proxy"

View File

@@ -21,7 +21,7 @@ import (
"net/http" "net/http"
"code.cloudfoundry.org/bytefmt" "code.cloudfoundry.org/bytefmt"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api" "kubesphere.io/kubesphere/pkg/api"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v1alpha3 package v1alpha3
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/informers" "k8s.io/client-go/informers"

View File

@@ -21,7 +21,7 @@ package v1alpha3
import ( import (
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"

View File

@@ -22,7 +22,7 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/proxy" "k8s.io/apimachinery/pkg/util/proxy"
"k8s.io/klog" "k8s.io/klog"

View File

@@ -21,7 +21,7 @@ import (
"net/url" "net/url"
"testing" "testing"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
) )

View File

@@ -25,7 +25,7 @@ import (
"kubesphere.io/kubesphere/pkg/apiserver/request" "kubesphere.io/kubesphere/pkg/apiserver/request"
"kubesphere.io/kubesphere/pkg/models/auth" "kubesphere.io/kubesphere/pkg/models/auth"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
rbacv1 "k8s.io/api/rbac/v1" rbacv1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/klog" "k8s.io/klog"

View File

@@ -21,7 +21,7 @@ import (
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer" "kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
rbacv1 "k8s.io/api/rbac/v1" rbacv1 "k8s.io/api/rbac/v1"
v1 "k8s.io/api/rbac/v1" v1 "k8s.io/api/rbac/v1"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v1 package v1
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"kubesphere.io/kubesphere/pkg/kapis/generic" "kubesphere.io/kubesphere/pkg/kapis/generic"

View File

@@ -19,7 +19,7 @@
package v1alpha1 package v1alpha1
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
openpitrixoptions "kubesphere.io/kubesphere/pkg/simple/client/openpitrix" openpitrixoptions "kubesphere.io/kubesphere/pkg/simple/client/openpitrix"

View File

@@ -24,7 +24,7 @@ import (
"kubesphere.io/kubesphere/pkg/client/clientset/versioned" "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"

View File

@@ -23,6 +23,7 @@ import (
"regexp" "regexp"
"strings" "strings"
restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
openpitrixoptions "kubesphere.io/kubesphere/pkg/simple/client/openpitrix" openpitrixoptions "kubesphere.io/kubesphere/pkg/simple/client/openpitrix"
@@ -31,7 +32,6 @@ import (
"kubesphere.io/kubesphere/pkg/client/clientset/versioned" "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
"kubesphere.io/kubesphere/pkg/models/openpitrix" "kubesphere.io/kubesphere/pkg/models/openpitrix"
"github.com/emicklei/go-restful"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"kubesphere.io/kubesphere/pkg/api" "kubesphere.io/kubesphere/pkg/api"

View File

@@ -29,7 +29,7 @@ import (
"github.com/jszwec/csvutil" "github.com/jszwec/csvutil"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"github.com/pkg/errors" "github.com/pkg/errors"
corev1 "k8s.io/apimachinery/pkg/apis/meta/v1" corev1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@@ -7,7 +7,7 @@ import (
"kubesphere.io/kubesphere/pkg/models/openpitrix" "kubesphere.io/kubesphere/pkg/models/openpitrix"
"kubesphere.io/kubesphere/pkg/server/params" "kubesphere.io/kubesphere/pkg/server/params"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/klog" "k8s.io/klog"

View File

@@ -24,7 +24,7 @@ import (
"kubesphere.io/kubesphere/pkg/client/clientset/versioned" "kubesphere.io/kubesphere/pkg/client/clientset/versioned"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"

View File

@@ -22,7 +22,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api" "kubesphere.io/kubesphere/pkg/api"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v1 package v1
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"kubesphere.io/kubesphere/pkg/kapis/generic" "kubesphere.io/kubesphere/pkg/kapis/generic"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v2beta1 package v2beta1
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/klog" "k8s.io/klog"

View File

@@ -21,7 +21,7 @@ package v2beta1
import ( import (
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
openapi "github.com/emicklei/go-restful-openapi" openapi "github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"

View File

@@ -23,7 +23,7 @@ import (
"kubesphere.io/kubesphere/pkg/server/errors" "kubesphere.io/kubesphere/pkg/server/errors"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/labels"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"

View File

@@ -19,7 +19,7 @@ package oauth
import ( import (
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
"kubesphere.io/kubesphere/pkg/api" "kubesphere.io/kubesphere/pkg/api"

View File

@@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
k8serr "k8s.io/apimachinery/pkg/api/errors" k8serr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"

View File

@@ -19,7 +19,7 @@ package v1alpha2
import ( import (
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"

View File

@@ -22,7 +22,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors" k8serr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"

View File

@@ -19,7 +19,7 @@ package v1alpha2
import ( import (
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
appsv1 "k8s.io/api/apps/v1" appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"

View File

@@ -19,7 +19,7 @@ package v1alpha3
import ( import (
"strings" "strings"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api" "kubesphere.io/kubesphere/pkg/api"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v1alpha3 package v1alpha3
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/cache"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package install package install
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
urlruntime "k8s.io/apimachinery/pkg/util/runtime" urlruntime "k8s.io/apimachinery/pkg/util/runtime"
"kubesphere.io/kubesphere/pkg/apiserver/runtime" "kubesphere.io/kubesphere/pkg/apiserver/runtime"

View File

@@ -21,7 +21,7 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api" "kubesphere.io/kubesphere/pkg/api"

View File

@@ -19,7 +19,7 @@ package v1alpha2
import ( import (
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"

View File

@@ -20,7 +20,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@@ -3,7 +3,7 @@ package v1alpha2
import ( import (
"fmt" "fmt"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
"strconv" "strconv"

View File

@@ -23,7 +23,7 @@ import (
"kubesphere.io/kubesphere/pkg/models/metering" "kubesphere.io/kubesphere/pkg/models/metering"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"

View File

@@ -24,7 +24,7 @@ import (
"kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer" "kubesphere.io/kubesphere/pkg/apiserver/authorization/authorizer"
requestctx "kubesphere.io/kubesphere/pkg/apiserver/request" requestctx "kubesphere.io/kubesphere/pkg/apiserver/request"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package v1alpha2 package v1alpha2
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
restfulspec "github.com/emicklei/go-restful-openapi" restfulspec "github.com/emicklei/go-restful-openapi"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package version package version
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/discovery" "k8s.io/client-go/discovery"
"k8s.io/klog" "k8s.io/klog"

View File

@@ -19,7 +19,7 @@ package devops
import ( import (
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
"kubesphere.io/kubesphere/pkg/server/errors" "kubesphere.io/kubesphere/pkg/server/errors"

View File

@@ -26,7 +26,7 @@ import (
"code.cloudfoundry.org/bytefmt" "code.cloudfoundry.org/bytefmt"
"github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/awserr"
awsS3 "github.com/aws/aws-sdk-go/service/s3" awsS3 "github.com/aws/aws-sdk-go/service/s3"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/util/retry" "k8s.io/client-go/util/retry"
"k8s.io/klog" "k8s.io/klog"
@@ -103,7 +103,7 @@ func (s *s2iBinaryUploader) UploadS2iBinary(namespace, name, md5 string, fileHea
copy.Spec.FileName = fileHeader.Filename copy.Spec.FileName = fileHeader.Filename
copy.Spec.DownloadURL = fmt.Sprintf(GetS2iBinaryURL, namespace, name, copy.Spec.FileName) copy.Spec.DownloadURL = fmt.Sprintf(GetS2iBinaryURL, namespace, name, copy.Spec.FileName)
err = s.s3Client.Upload(fmt.Sprintf("%s-%s", namespace, name), copy.Spec.FileName, binFile) err = s.s3Client.Upload(fmt.Sprintf("%s-%s", namespace, name), copy.Spec.FileName, binFile, int(fileHeader.Size))
if err != nil { if err != nil {
if aerr, ok := err.(awserr.Error); ok { if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() { switch aerr.Code() {

View File

@@ -19,7 +19,7 @@ package git
import ( import (
"fmt" "fmt"
"gopkg.in/src-d/go-git.v4" git "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/config" "gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/plumbing/transport/http" "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
"gopkg.in/src-d/go-git.v4/storage/memory" "gopkg.in/src-d/go-git.v4/storage/memory"

View File

@@ -115,7 +115,7 @@ func (c *applicationOperator) createApp(app *v1alpha1.HelmApplication, iconData
if len(iconData) != 0 { if len(iconData) != 0 {
// save icon attachment // save icon attachment
iconId := idutils.GetUuid(v1alpha1.HelmAttachmentPrefix) iconId := idutils.GetUuid(v1alpha1.HelmAttachmentPrefix)
err = c.backingStoreClient.Upload(iconId, iconId, bytes.NewBuffer(iconData)) err = c.backingStoreClient.Upload(iconId, iconId, bytes.NewBuffer(iconData), len(iconData))
if err != nil { if err != nil {
klog.Errorf("save icon attachment failed, error: %s", err) klog.Errorf("save icon attachment failed, error: %s", err)
return nil, err return nil, err
@@ -498,7 +498,7 @@ func (c *applicationOperator) modifyAppAttachment(app *v1alpha1.HelmApplication,
// add attachment to app // add attachment to app
add := idutils.GetUuid("att-") add := idutils.GetUuid("att-")
*attachments = append(*attachments, add) *attachments = append(*attachments, add)
err = c.backingStoreClient.Upload(add, add, bytes.NewBuffer(request.AttachmentContent)) err = c.backingStoreClient.Upload(add, add, bytes.NewBuffer(request.AttachmentContent), len(request.AttachmentContent))
if err != nil { if err != nil {
return "", err return "", err
} else { } else {
@@ -517,7 +517,7 @@ func (c *applicationOperator) modifyAppAttachment(app *v1alpha1.HelmApplication,
} }
if len(request.AttachmentContent) != 0 { if len(request.AttachmentContent) != 0 {
add := idutils.GetUuid("att-") add := idutils.GetUuid("att-")
err = c.backingStoreClient.Upload(add, add, bytes.NewBuffer(request.AttachmentContent)) err = c.backingStoreClient.Upload(add, add, bytes.NewBuffer(request.AttachmentContent), len(request.AttachmentContent))
if err != nil { if err != nil {
return "", err return "", err
} else { } else {

View File

@@ -202,7 +202,7 @@ func (c *applicationOperator) ModifyAppVersion(id string, request *ModifyAppVers
spec.Created = &now spec.Created = &now
// 3. save chart data to s3 storage, just overwrite the legacy data // 3. save chart data to s3 storage, just overwrite the legacy data
err = c.backingStoreClient.Upload(dataKeyInStorage(versionCopy.GetWorkspace(), versionCopy.Name), versionCopy.Name, bytes.NewReader(request.Package)) err = c.backingStoreClient.Upload(dataKeyInStorage(versionCopy.GetWorkspace(), versionCopy.Name), versionCopy.Name, bytes.NewBuffer(request.Package), len(request.Package))
if err != nil { if err != nil {
klog.Errorf("upload chart for app version: %s/%s failed, error: %s", versionCopy.GetWorkspace(), klog.Errorf("upload chart for app version: %s/%s failed, error: %s", versionCopy.GetWorkspace(),
versionCopy.GetTrueName(), err) versionCopy.GetTrueName(), err)
@@ -490,7 +490,7 @@ func (c *applicationOperator) createApplicationVersion(ver *v1alpha1.HelmApplica
klog.Errorf("decode error: %s", err) klog.Errorf("decode error: %s", err)
return nil, err return nil, err
} else { } else {
err = c.backingStoreClient.Upload(dataKeyInStorage(ver.GetWorkspace(), ver.Name), ver.Name, bytes.NewReader(ver.Spec.Data)) err = c.backingStoreClient.Upload(dataKeyInStorage(ver.GetWorkspace(), ver.Name), ver.Name, bytes.NewBuffer(ver.Spec.Data), len(ver.Spec.Data))
if err != nil { if err != nil {
klog.Errorf("upload chart for app version: %s/%s failed, error: %s", ver.GetWorkspace(), klog.Errorf("upload chart for app version: %s/%s failed, error: %s", ver.GetWorkspace(),
ver.GetTrueName(), err) ver.GetTrueName(), err)

View File

@@ -65,7 +65,7 @@ func (c *attachmentOperator) CreateAttachment(data []byte) (*Attachment, error)
} }
id := idutils.GetUuid36(v1alpha1.HelmAttachmentPrefix) id := idutils.GetUuid36(v1alpha1.HelmAttachmentPrefix)
err := c.backingStoreClient.Upload(id, id, bytes.NewBuffer(data)) err := c.backingStoreClient.Upload(id, id, bytes.NewBuffer(data), len(data))
if err != nil { if err != nil {
klog.Errorf("upload attachment failed, err: %s", err) klog.Errorf("upload attachment failed, err: %s", err)
return nil, err return nil, err

View File

@@ -22,7 +22,7 @@ import (
"strings" "strings"
"github.com/docker/distribution/reference" "github.com/docker/distribution/reference"
"github.com/opencontainers/go-digest" digest "github.com/opencontainers/go-digest"
log "k8s.io/klog" log "k8s.io/klog"
) )

View File

@@ -19,7 +19,7 @@ package registries
import ( import (
"time" "time"
"github.com/opencontainers/go-digest" digest "github.com/opencontainers/go-digest"
) )
// ImageBlobInfo describes the info of an image. // ImageBlobInfo describes the info of an image.

View File

@@ -22,7 +22,7 @@ import (
"net/http" "net/http"
"github.com/docker/distribution/manifest/schema2" "github.com/docker/distribution/manifest/schema2"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
log "k8s.io/klog" log "k8s.io/klog"
) )

View File

@@ -25,7 +25,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/informers" "k8s.io/client-go/informers"
"k8s.io/klog" "k8s.io/klog"

View File

@@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
) )
type Error struct { type Error struct {

View File

@@ -22,7 +22,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
) )
const ( const (

View File

@@ -22,9 +22,8 @@ import (
"reflect" "reflect"
"testing" "testing"
restful "github.com/emicklei/go-restful"
"gotest.tools/assert" "gotest.tools/assert"
"github.com/emicklei/go-restful"
) )
func TestParseConditions(t *testing.T) { func TestParseConditions(t *testing.T) {

View File

@@ -23,7 +23,7 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3" devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"

View File

@@ -22,7 +22,7 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"kubesphere.io/kubesphere/pkg/simple/client/devops" "kubesphere.io/kubesphere/pkg/simple/client/devops"
) )

View File

@@ -19,7 +19,7 @@ import (
"net/http" "net/http"
"strconv" "strconv"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/klog" "k8s.io/klog"

View File

@@ -17,7 +17,7 @@ limitations under the License.
package jenkins package jenkins
import ( import (
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
"kubesphere.io/kubesphere/pkg/simple/client/devops" "kubesphere.io/kubesphere/pkg/simple/client/devops"

View File

@@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/emicklei/go-restful" restful "github.com/emicklei/go-restful"
"k8s.io/klog" "k8s.io/klog"
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3" devopsv1alpha3 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha3"

View File

@@ -29,7 +29,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/form3tech-oss/jwt-go" jwt "github.com/dgrijalva/jwt-go"
authtoken "kubesphere.io/kubesphere/pkg/apiserver/authentication/token" authtoken "kubesphere.io/kubesphere/pkg/apiserver/authentication/token"
"kubesphere.io/kubesphere/pkg/simple/client/devops" "kubesphere.io/kubesphere/pkg/simple/client/devops"

View File

@@ -24,7 +24,7 @@ import (
"io/ioutil" "io/ioutil"
"time" "time"
"github.com/elastic/go-elasticsearch/v5" elasticsearch "github.com/elastic/go-elasticsearch/v5"
"github.com/elastic/go-elasticsearch/v5/esapi" "github.com/elastic/go-elasticsearch/v5/esapi"
) )

View File

@@ -24,7 +24,7 @@ import (
"io/ioutil" "io/ioutil"
"time" "time"
"github.com/elastic/go-elasticsearch/v6" elasticsearch "github.com/elastic/go-elasticsearch/v6"
"github.com/elastic/go-elasticsearch/v6/esapi" "github.com/elastic/go-elasticsearch/v6/esapi"
) )

View File

@@ -24,7 +24,7 @@ import (
"io/ioutil" "io/ioutil"
"time" "time"
"github.com/elastic/go-elasticsearch/v7" elasticsearch "github.com/elastic/go-elasticsearch/v7"
"github.com/elastic/go-elasticsearch/v7/esapi" "github.com/elastic/go-elasticsearch/v7/esapi"
) )

View File

@@ -43,7 +43,7 @@ type Object struct {
Body io.Reader Body io.Reader
} }
func (s *FakeS3) Upload(key, fileName string, body io.Reader) error { func (s *FakeS3) Upload(key, fileName string, body io.Reader, size int) error {
s.Storage[key] = &Object{ s.Storage[key] = &Object{
Key: key, Key: key,
FileName: fileName, FileName: fileName,

View File

@@ -25,7 +25,7 @@ func TestFakeS3(t *testing.T) {
s3 := NewFakeS3() s3 := NewFakeS3()
key := "hello" key := "hello"
fileName := "world" fileName := "world"
err := s3.Upload(key, fileName, nil) err := s3.Upload(key, fileName, nil, 0)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -16,16 +16,14 @@ limitations under the License.
package s3 package s3
import ( import "io"
"io"
)
type Interface interface { type Interface interface {
//read the content, caller should close the io.ReadCloser. //read the content, caller should close the io.ReadCloser.
Read(key string) ([]byte, error) Read(key string) ([]byte, error)
// Upload uploads a object to storage and returns object location if succeeded // Upload uploads a object to storage and returns object location if succeeded
Upload(key, fileName string, body io.Reader) error Upload(key, fileName string, body io.Reader, size int) error
GetDownloadURL(key string, fileName string) (string, error) GetDownloadURL(key string, fileName string) (string, error)

View File

@@ -19,6 +19,7 @@ package s3
import ( import (
"fmt" "fmt"
"io" "io"
"math"
"time" "time"
"code.cloudfoundry.org/bytefmt" "code.cloudfoundry.org/bytefmt"
@@ -36,10 +37,40 @@ type Client struct {
bucket string bucket string
} }
func (s *Client) Upload(key, fileName string, body io.Reader) error { const (
DefaultPartSize = 5 * bytefmt.MEGABYTE
// MinConcurrency is the minimum concurrency when uploading a part to Amazon S3,
// it's also the default value of Concurrency in aws-sdk-go.
MinConcurrency = 5
// MaxConcurrency is the maximum concurrency to limit the goroutines.
MaxConcurrency = 128
)
// calculateConcurrency calculates the concurrency for better performance,
// make the concurrency in range [5, 128].
func calculateConcurrency(size int) int {
if size <= 0 {
return MinConcurrency
}
c := int(math.Ceil(float64(size) / float64(DefaultPartSize)))
if c < MinConcurrency {
return MinConcurrency
} else if c > MaxConcurrency {
return MaxConcurrency
}
return c
}
// Upload use Multipart upload to upload a single object as a set of parts.
// If the data length is known to be large, it is recommended to pass in the data length,
// it will helps to calculate concurrency. Otherwise, `size` can be 0,
// use 5 as default upload concurrency, same as aws-sdk-go.
// See https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html for more details.
func (s *Client) Upload(key, fileName string, body io.Reader, size int) error {
uploader := s3manager.NewUploader(s.s3Session, func(uploader *s3manager.Uploader) { uploader := s3manager.NewUploader(s.s3Session, func(uploader *s3manager.Uploader) {
uploader.PartSize = 5 * bytefmt.MEGABYTE uploader.PartSize = DefaultPartSize
uploader.LeavePartsOnError = true uploader.LeavePartsOnError = true
uploader.Concurrency = calculateConcurrency(size)
}) })
_, err := uploader.Upload(&s3manager.UploadInput{ _, err := uploader.Upload(&s3manager.UploadInput{
Bucket: aws.String(s.bucket), Bucket: aws.String(s.bucket),

View File

@@ -0,0 +1,14 @@
package s3
import (
"testing"
"gotest.tools/assert"
)
func TestCalculateConcurrency(t *testing.T) {
assert.Equal(t, 5, calculateConcurrency(1*1024*1024))
assert.Equal(t, 5, calculateConcurrency(5*1024*1024))
assert.Equal(t, 20, calculateConcurrency(99*1024*1024))
assert.Equal(t, 128, calculateConcurrency(129*5*1024*1024))
}

View File

@@ -22,7 +22,7 @@ import (
"github.com/golang/example/stringutil" "github.com/golang/example/stringutil"
"github.com/sony/sonyflake" "github.com/sony/sonyflake"
"github.com/speps/go-hashids" hashids "github.com/speps/go-hashids"
"kubesphere.io/kubesphere/pkg/utils/stringutils" "kubesphere.io/kubesphere/pkg/utils/stringutils"
) )

Some files were not shown because too many files have changed in this diff Show More