This repository was archived by the owner on Nov 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +50
-2
lines changed Expand file tree Collapse file tree 2 files changed +50
-2
lines changed Original file line number Diff line number Diff line change 1+ // +build kube
2+
3+ /*
4+ Copyright 2020 Docker Compose CLI authors
5+
6+ Licensed under the Apache License, Version 2.0 (the "License");
7+ you may not use this file except in compliance with the License.
8+ You may obtain a copy of the License at
9+
10+ http://www.apache.org/licenses/LICENSE-2.0
11+
12+ Unless required by applicable law or agreed to in writing, software
13+ distributed under the License is distributed on an "AS IS" BASIS,
14+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ See the License for the specific language governing permissions and
16+ limitations under the License.
17+ */
18+
19+ package client
20+
21+ import (
22+ "k8s.io/cli-runtime/pkg/genericclioptions"
23+ "k8s.io/client-go/kubernetes"
24+ )
25+
26+ type KubeClient struct {
27+ client * kubernetes.Clientset
28+ }
29+
30+ func NewKubeClient (config genericclioptions.RESTClientGetter ) (* KubeClient , error ) {
31+ restConfig , err := config .ToRESTConfig ()
32+ if err != nil {
33+ return nil , err
34+ }
35+
36+ clientset , err := kubernetes .NewForConfig (restConfig )
37+ if err != nil {
38+ return nil , err
39+ }
40+ return & KubeClient {
41+ client : clientset ,
42+ }, nil
43+ }
Original file line number Diff line number Diff line change @@ -30,12 +30,14 @@ import (
3030 "github.com/docker/compose-cli/api/context/store"
3131 "github.com/docker/compose-cli/api/errdefs"
3232 "github.com/docker/compose-cli/api/progress"
33+ "github.com/docker/compose-cli/kube/client"
3334 "github.com/docker/compose-cli/kube/helm"
3435 "github.com/docker/compose-cli/kube/resources"
3536)
3637
3738type composeService struct {
38- sdk * helm.Actions
39+ sdk * helm.Actions
40+ client * client.KubeClient
3941}
4042
4143// NewComposeService create a kubernetes implementation of the compose.Service API
@@ -52,11 +54,14 @@ func NewComposeService(ctx context.Context) (compose.Service, error) {
5254 return nil , err
5355 }
5456 actions , err := helm .NewActions (config )
57+ apiClient , err := client .NewKubeClient (config )
5558 if err != nil {
5659 return nil , err
5760 }
61+
5862 return & composeService {
59- sdk : actions ,
63+ sdk : actions ,
64+ client : apiClient ,
6065 }, nil
6166}
6267
You can’t perform that action at this time.
0 commit comments