Skip to content

Commit 5c981dd

Browse files
committed
feat: update platform plugin
1 parent 426293d commit 5c981dd

File tree

7 files changed

+47
-47
lines changed

7 files changed

+47
-47
lines changed

global/configs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ const (
99
)
1010

1111
type IntegrationCredentials struct {
12-
// TODO
12+
KubeConfig string `json:"kubeconfig"`
1313
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ require (
9898
github.com/go-test/deep v1.0.8 // indirect
9999
github.com/gogo/protobuf v1.3.2 // indirect
100100
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
101-
github.com/golang/glog v1.2.2 // indirect
101+
github.com/golang/glog v1.2.4 // indirect
102102
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
103103
github.com/golang/mock v1.6.0 // indirect
104104
github.com/google/gnostic-models v0.6.8 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq
397397
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
398398
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
399399
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
400-
github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY=
401-
github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
400+
github.com/golang/glog v1.2.4 h1:CNNw5U8lSiiBk7druxtSHHTsRWcxKoac6kZKm2peBBc=
401+
github.com/golang/glog v1.2.4/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
402402
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
403403
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
404404
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=

platform/constants/ui-spec.json

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"integration_type_id": "kubernetes",
33
"integration_name": "Kubernetes Cluster",
4-
"help_text_md": "GitHub Account integration allows secure connections to your GitHub organizations. [Documentation](https://docs.github.com/en).",
4+
"help_text_md": "Kubernetes cluster integration allows secure connections to your kubernetes clusters running anywhere. [Documentation](https://kubernetes.io/docs/home/).",
55
"platform_documentation": "https://kubernetes.io/docs/home/",
66
"provider_documentation": "https://kubernetes.io/docs/home/",
77
"icon": "kubernetes.svg",
@@ -14,7 +14,7 @@
1414
"fields": [
1515
{
1616
"name": "kubeconfig",
17-
"label": "Kubeconfig",
17+
"label": "Kube config",
1818
"inputType": "text",
1919
"required": true,
2020
"order": 1,
@@ -41,32 +41,24 @@
4141
"order": 1,
4242
"info": "Unique identifier (UUID) for the integration."
4343
},
44-
{
45-
"name": "organization_name",
46-
"label": "Organization Name",
47-
"fieldType": "text",
48-
"required": true,
49-
"order": 2,
50-
"info": "Name of the GitHub organization."
51-
},
5244
{
5345
"name": "credential_type",
5446
"label": "Credential Type",
5547
"fieldType": "text",
5648
"required": true,
57-
"order": 3,
58-
"info": "Type of Credential used (Classic PAT).",
49+
"order": 2,
50+
"info": "Type of Credential used (Kube config).",
5951
"valueMap": {
60-
"classic_pat": "Classic Personal Access Token (PAT)"
52+
"kubeconfig": "Kube config file"
6153
}
6254
},
6355
{
6456
"name": "state",
6557
"label": "State",
6658
"fieldType": "status",
6759
"required": true,
68-
"order": 4,
69-
"info": "Current state of the GitHub Organization integration.",
60+
"order": 3,
61+
"info": "Current state of the Kubernetes cluster integration.",
7062
"statusOptions": [
7163
{
7264
"value": "ACTIVE",
@@ -90,15 +82,15 @@
9082
"label": "Created At",
9183
"fieldType": "date",
9284
"required": true,
93-
"order": 5,
85+
"order": 4,
9486
"info": "Timestamp when the integration was created."
9587
},
9688
{
9789
"name": "last_updated",
9890
"label": "Last Updated",
9991
"fieldType": "date",
10092
"required": true,
101-
"order": 6,
93+
"order": 5,
10294
"info": "Timestamp when the integration was last updated."
10395
}
10496
]
@@ -191,7 +183,7 @@
191183
"filterable": true,
192184
"detail": true,
193185
"detail_order": 3,
194-
"info": "Current state of the GitHub Organization integration.",
186+
"info": "Current state of the Kubernetes cluster integration.",
195187
"statusOptions": [
196188
{
197189
"value": "ACTIVE",
@@ -222,7 +214,7 @@
222214
{
223215
"type": "update",
224216
"label": "Update",
225-
"editableFields": ["pat_token"]
217+
"editableFields": ["kubeconfig"]
226218
},
227219
{
228220
"type": "delete",

platform/discovery.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

platform/healthcheck.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
package main
22

3-
3+
import (
4+
"github.com/opengovern/og-describer-kubernetes/global"
5+
"k8s.io/client-go/kubernetes"
6+
"k8s.io/client-go/tools/clientcmd"
7+
)
48

59
// Config represents the JSON input configuration
610
type Config struct {
7-
811
}
912

10-
11-
12-
13-
func IntegrationHealthcheck(cfg Config) (bool, error) {
14-
15-
//TODO
13+
func IntegrationHealthcheck(creds global.IntegrationCredentials, cfg Config) (bool, error) {
14+
config, err := clientcmd.RESTConfigFromKubeConfig([]byte(creds.KubeConfig))
15+
if err != nil {
16+
return false, err
17+
}
18+
clientSet, err := kubernetes.NewForConfig(config)
19+
if err != nil {
20+
return false, err
21+
}
22+
23+
_, err = clientSet.ServerVersion()
24+
if err != nil {
25+
return false, err
26+
}
1627

1728
return true, nil
1829
}

platform/integration.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/opengovern/og-describer-kubernetes/platform/constants"
88
"github.com/opengovern/og-util/pkg/integration"
99
"github.com/opengovern/og-util/pkg/integration/interfaces"
10+
"k8s.io/client-go/tools/clientcmd"
1011
)
1112

1213
type Integration struct{}
@@ -36,8 +37,7 @@ func (i *Integration) HealthCheck(jsonData []byte, providerId string, labels map
3637
if err != nil {
3738
return false, err
3839
}
39-
// TODO add credentials
40-
isHealthy, err := IntegrationHealthcheck(Config{})
40+
isHealthy, err := IntegrationHealthcheck(credentials, Config{})
4141

4242
return isHealthy, err
4343
}
@@ -48,11 +48,18 @@ func (i *Integration) DiscoverIntegrations(jsonData []byte) ([]integration.Integ
4848
if err != nil {
4949
return nil, err
5050
}
51-
var integrations []integration.Integration
52-
// TODO
53-
_, err = IntegrationDiscovery(Config{})
5451

55-
return integrations, nil
52+
config, err := clientcmd.RESTConfigFromKubeConfig([]byte(credentials.KubeConfig))
53+
if err != nil {
54+
return nil, err
55+
}
56+
57+
return []integration.Integration{
58+
{
59+
ProviderID: config.Host,
60+
Name: config.Host,
61+
},
62+
}, nil
5663
}
5764

5865
func (i *Integration) GetResourceTypesByLabels(labels map[string]string) ([]interfaces.ResourceTypeConfiguration, error) {

0 commit comments

Comments
 (0)