ricardozanini commented on code in PR #2465:
URL:
https://github.com/apache/incubator-kie-tools/pull/2465#discussion_r1727033495
##########
packages/kn-plugin-workflow/pkg/common/k8sclient/goapi.go:
##########
@@ -53,42 +53,37 @@ func KubeRestConfig() (*rest.Config, error) {
return config, nil
}
-func (m GoAPI) GetKubectlNamespace() (string, error) {
- fmt.Println("🔎 Checking current namespace in kubectl...")
+func (m GoAPI) GetNamespace() (string, error) {
+ fmt.Println("🔎 Checking current namespace in k8s...")
config, err := KubeApiConfig()
if err != nil {
- return "", fmt.Errorf("❌ ERROR: Failed to get current kubectl
namespace: %w", err)
+ return "", fmt.Errorf("❌ ERROR: Failed to get current k8s
namespace: %w", err)
}
namespace := config.Contexts[config.CurrentContext].Namespace
if len(namespace) == 0 {
namespace = "default"
}
- fmt.Printf(" - ✅ kubectl current namespace: %s\n", namespace)
+ fmt.Printf(" - ✅ k8s current namespace: %s\n", namespace)
return namespace, nil
}
-func (m GoAPI) CheckKubectlContext() (string, error) {
+func (m GoAPI) CheckContext() (string, error) {
config, err := KubeApiConfig()
if err != nil {
- return "", fmt.Errorf("❌ ERROR: No current kubectl context
found %w", err)
+ return "", fmt.Errorf("❌ ERROR: No current k8s context found
%w", err)
}
context := config.CurrentContext
if context == "" {
- return "", fmt.Errorf("❌ ERROR: No current kubectl context
found")
+ return "", fmt.Errorf("❌ ERROR: No current k8s context found")
}
- fmt.Printf(" - ✅ kubectl current context: %s\n", context)
+ fmt.Printf(" - ✅ k8s current context: %s\n", context)
return context, nil
}
-func (m GoAPI) ExecuteKubectlApply(path, namespace string) error {
- config, err := KubeRestConfig()
- if err != nil {
- return fmt.Errorf("❌ ERROR: Failed to create rest config for
Kubernetes client: %v", err)
- }
-
- client, err := dynamic.NewForConfig(config)
+func (m GoAPI) ExecuteApply(path, namespace string) error {
+ client, err := getDynamicClient()
Review Comment:
There's a catch here you might need to check. The file can contain many
objects, so the deserialization from the file below might not work as expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]