forked from kubesphere/kubesphere
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: runzexia <[email protected]>
- Loading branch information
runzexia
committed
Aug 27, 2019
1 parent
c6440ec
commit f00917b
Showing
506 changed files
with
79,354 additions
and
52,555 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: devops.kubesphere.io/v1alpha1 | ||
kind: S2iBinary | ||
metadata: | ||
labels: | ||
controller-tools.k8s.io: "1.0" | ||
name: s2ibinary-sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright 2019 The KubeSphere Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package install | ||
|
||
import ( | ||
k8sruntime "k8s.io/apimachinery/pkg/runtime" | ||
urlruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
devopsv1alpha1 "kubesphere.io/kubesphere/pkg/apis/devops/v1alpha1" | ||
) | ||
|
||
func Install(scheme *k8sruntime.Scheme) { | ||
urlruntime.Must(devopsv1alpha1.AddToScheme(scheme)) | ||
urlruntime.Must(scheme.SetVersionPriority(devopsv1alpha1.SchemeGroupVersion)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package devops | ||
|
||
import ( | ||
"code.cloudfoundry.org/bytefmt" | ||
"fmt" | ||
"github.com/emicklei/go-restful" | ||
"github.com/golang/glog" | ||
"kubesphere.io/kubesphere/pkg/errors" | ||
"kubesphere.io/kubesphere/pkg/models/devops" | ||
"kubesphere.io/kubesphere/pkg/utils/hashutil" | ||
"net/http" | ||
) | ||
|
||
func UploadS2iBinary(req *restful.Request, resp *restful.Response) { | ||
ns := req.PathParameter("namespace") | ||
name := req.PathParameter("s2ibinary") | ||
|
||
err := req.Request.ParseMultipartForm(bytefmt.MEGABYTE * 20) | ||
if err != nil { | ||
glog.Errorf("%+v", err) | ||
errors.ParseSvcErr(restful.NewError(http.StatusBadRequest, err.Error()), resp) | ||
return | ||
} | ||
if len(req.Request.MultipartForm.File) == 0 { | ||
err := restful.NewError(http.StatusBadRequest, "could not get file from form") | ||
glog.Errorf("%+v", err) | ||
errors.ParseSvcErr(restful.NewError(http.StatusBadRequest, err.Error()), resp) | ||
return | ||
} | ||
if len(req.Request.MultipartForm.File["s2ibinary"]) == 0 { | ||
err := restful.NewError(http.StatusBadRequest, "could not get file from form") | ||
glog.Errorf("%+v", err) | ||
errors.ParseSvcErr(err, resp) | ||
return | ||
} | ||
if len(req.Request.MultipartForm.File["s2ibinary"]) > 1 { | ||
err := restful.NewError(http.StatusBadRequest, "s2ibinary should only have one file") | ||
glog.Errorf("%+v", err) | ||
errors.ParseSvcErr(err, resp) | ||
return | ||
} | ||
defer req.Request.MultipartForm.RemoveAll() | ||
file, err := req.Request.MultipartForm.File["s2ibinary"][0].Open() | ||
if err != nil { | ||
glog.Error(err) | ||
errors.ParseSvcErr(err, resp) | ||
return | ||
} | ||
filemd5, err := hashutil.GetMD5(file) | ||
if err != nil { | ||
glog.Error(err) | ||
errors.ParseSvcErr(err, resp) | ||
return | ||
} | ||
md5, ok := req.Request.MultipartForm.Value["md5"] | ||
if ok && len(req.Request.MultipartForm.Value["md5"]) > 0 { | ||
if md5[0] != filemd5 { | ||
err := restful.NewError(http.StatusBadRequest, fmt.Sprintf("md5 not match, origin: %+v, calculate: %+v", md5[0], filemd5)) | ||
glog.Error(err) | ||
errors.ParseSvcErr(err, resp) | ||
return | ||
} | ||
} | ||
|
||
s2ibin, err := devops.UploadS2iBinary(ns, name, filemd5, req.Request.MultipartForm.File["s2ibinary"][0]) | ||
if err != nil { | ||
glog.Errorf("%+v", err) | ||
errors.ParseSvcErr(err, resp) | ||
return | ||
} | ||
resp.WriteAsJson(s2ibin) | ||
|
||
} | ||
|
||
func DownloadS2iBinary(req *restful.Request, resp *restful.Response) { | ||
ns := req.PathParameter("namespace") | ||
name := req.PathParameter("s2ibinary") | ||
fileName := req.PathParameter("file") | ||
url, err := devops.DownloadS2iBinary(ns, name, fileName) | ||
if err != nil { | ||
glog.Errorf("%+v", err) | ||
errors.ParseSvcErr(err, resp) | ||
return | ||
} | ||
http.Redirect(resp.ResponseWriter, req.Request, url, http.StatusFound) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
approvers: | ||
- runzexia | ||
- soulseen | ||
|
||
reviewers: | ||
- runzexia | ||
- soulseen | ||
|
||
labels: | ||
- area/controller | ||
- area/devops |
Oops, something went wrong.