Files
fission-src/pkg/controller/client/v1/v1.go
T
Eng Zer JunandGitHub 2f4ec4b2b9 refactor: move from io/ioutil to io and os package (#2236)
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-10-23 17:14:12 +05:30

101 lines
2.1 KiB
Go

/*
Copyright 2019 The Fission 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 v1
import (
"io"
"net/http"
ferror "github.com/fission/fission/pkg/error"
"github.com/fission/fission/pkg/controller/client/rest"
)
type (
V1Interface interface {
MiscGetter
CanaryConfigGetter
EnvironmentGetter
FunctionGetter
HTTPTriggerGetter
KubeWatcherGetter
MessageQueueTriggerGetter
PackageGetter
TimeTriggerGetter
}
V1 struct {
restClient rest.Interface
}
)
func MakeV1Client(restClient rest.Interface) *V1 {
return &V1{restClient: restClient}
}
func (c *V1) Misc() MiscInterface {
return newMiscClient(c)
}
func (c *V1) CanaryConfig() CanaryConfigInterface {
return newCanaryConfigClient(c)
}
func (c *V1) Environment() EnvironmentInterface {
return newEnvironmentClient(c)
}
func (c *V1) Function() FunctionInterface {
return newFunctionClient(c)
}
func (c *V1) HTTPTrigger() HTTPTriggerInterface {
return newHTTPTriggerClient(c)
}
func (c *V1) KubeWatcher() KubeWatcherInterface {
return newKubeWatcher(c)
}
func (c *V1) MessageQueueTrigger() MessageQueueTriggerInterface {
return newMessageQueueTrigger(c)
}
func (c *V1) Package() PackageInterface {
return newPackageClient(c)
}
func (c *V1) TimeTrigger() TimeTriggerInterface {
return newTimeTriggerClient(c)
}
func handleResponse(resp *http.Response) ([]byte, error) {
if resp.StatusCode != 200 {
return nil, ferror.MakeErrorFromHTTP(resp)
}
body, err := io.ReadAll(resp.Body)
return body, err
}
func handleCreateResponse(resp *http.Response) ([]byte, error) {
if resp.StatusCode != 201 {
return nil, ferror.MakeErrorFromHTTP(resp)
}
body, err := io.ReadAll(resp.Body)
return body, err
}