Files
kubesphere/pkg/kapis/operations/v1alpha2/register.go
KubeSphere CI Bot 447a51f08b feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

---------

Signed-off-by: ci-bot <ci-bot@kubesphere.io>
Co-authored-by: ks-ci-bot <ks-ci-bot@example.com>
Co-authored-by: joyceliu <joyceliu@yunify.com>
2024-09-06 11:05:52 +08:00

57 lines
1.6 KiB
Go

/*
* Please refer to the LICENSE file in the root directory of the project.
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
*/
package v1alpha2
import (
"net/http"
restfulspec "github.com/emicklei/go-restful-openapi/v2"
"github.com/emicklei/go-restful/v3"
"k8s.io/apimachinery/pkg/runtime/schema"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/rest"
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
"kubesphere.io/kubesphere/pkg/models/workloads"
"kubesphere.io/kubesphere/pkg/server/errors"
)
const (
GroupName = "operations.kubesphere.io"
)
var GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
func NewHandler(cacheClient runtimeclient.Client) rest.Handler {
return &handler{
jobRunner: workloads.NewJobRunner(cacheClient),
}
}
func NewFakeHandler() rest.Handler {
return &handler{}
}
func (h *handler) AddToContainer(c *restful.Container) error {
ws := runtime.NewWebService(GroupVersion)
ws.Route(ws.POST("/namespaces/{namespace}/jobs/{job}").
To(h.JobReRun).
Deprecate().
Doc("Job rerun").
Metadata(restfulspec.KeyOpenAPITags, []string{api.TagAdvancedOperations}).
Notes("Rerun job whether the job is complete or not.").
Param(ws.PathParameter("job", "job name")).
Param(ws.PathParameter("namespace", "The specified namespace.")).
Param(ws.QueryParameter("action", "action must be \"rerun\"")).
Param(ws.QueryParameter("resourceVersion", "version of job, rerun when the version matches").Required(true)).
Returns(http.StatusOK, api.StatusOK, errors.Error{}))
c.Add(ws)
return nil
}