mirror of
https://github.com/stakater/Reloader.git
synced 2026-05-06 00:36:39 +00:00
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
/**
|
|
* Copyright (C) 2015 Red Hat, Inc.
|
|
*
|
|
* 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 client
|
|
|
|
import (
|
|
oclient "github.com/openshift/origin/pkg/client"
|
|
"github.com/pkg/errors"
|
|
"k8s.io/kubernetes/pkg/client/restclient"
|
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
|
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
|
)
|
|
|
|
func NewClient(f *cmdutil.Factory) (*client.Client, *restclient.Config, error) {
|
|
var err error
|
|
cfg, err := f.ClientConfig()
|
|
if err != nil {
|
|
return nil, nil, errors.Wrap(err, "Could not initialise client")
|
|
}
|
|
c, err := client.New(cfg)
|
|
if err != nil {
|
|
return nil, nil, errors.Wrap(err, "Could not initialise client")
|
|
}
|
|
|
|
return c, cfg, nil
|
|
}
|
|
|
|
func NewOpenShiftClient(cfg *restclient.Config) (*oclient.Client, *restclient.Config, error) {
|
|
ocfg := *cfg
|
|
ocfg.APIPath = ""
|
|
c, err := oclient.New(&ocfg)
|
|
if err != nil {
|
|
return nil, nil, errors.Wrap(err, "Could not initialise an OpenShift client")
|
|
}
|
|
|
|
return c, cfg, nil
|
|
}
|