GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — secureCodeBox/scbctl/pkg/client.go at main · secureCodeBox/secureCodeBox

Expand file tree

/

client.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
62 lines (49 loc) · 1.64 KB
/

client.go

Copy path

File metadata and controls

62 lines (49 loc) · 1.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-FileCopyrightText: the secureCodeBox authors
//
// SPDX-License-Identifier: Apache-2.0
package client
import (
"fmt"
cascadingv1 "github.com/secureCodeBox/secureCodeBox/operator/apis/cascading/v1"
executionv1 "github.com/secureCodeBox/secureCodeBox/operator/apis/execution/v1"
v1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
"sigs.k8s.io/controller-runtime/pkg/client"
)
var (
scheme = runtime.NewScheme()
)
func init() {
utilruntime.Must(corev1.AddToScheme(scheme))
utilruntime.Must(batchv1.AddToScheme(scheme))
utilruntime.Must(executionv1.AddToScheme(scheme))
utilruntime.Must(cascadingv1.AddToScheme(scheme))
}
type ClientProvider interface {
GetClient(flags *genericclioptions.ConfigFlags) (client.Client, string, error)
}
type DefaultClientProvider struct{}
func (d *DefaultClientProvider) GetClient(flags *genericclioptions.ConfigFlags) (client.Client, string, error) {
return GetClient(flags)
}
func GetClient(flags *genericclioptions.ConfigFlags) (client.Client, string, error) {
cnfLoader := flags.ToRawKubeConfigLoader()
cnf, err := cnfLoader.ClientConfig()
if err != nil {
return nil, "", fmt.Errorf("failed to generate config from kubeconfig")
}
namespace, _, err := cnfLoader.Namespace()
if err != nil {
return nil, "", fmt.Errorf("failed to read namespace from kubeconfig")
}
utilruntime.Must(v1.AddToScheme(scheme))
client, err := client.New(cnf, client.Options{Scheme: scheme})
if err != nil {
return nil, "", err
}
return client, namespace, nil
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.