Files
test/keywords/k8s/files/kubectl_file_apply_keywords.py
Gabriel Calixto 80a3c82fba add test_k8s_dashboard_access test steps part1
with the test setup done, this change adds the necessary code to create
a k8s token which will be used to login via the k8s dashboard URL.

Change-Id: I44b3690306f1522c4f2b94af83e2a816f22e9573
Signed-off-by: Gabriel Calixto <Gabriel.CalixtodePaula@windriver.com>
2025-03-12 16:08:31 -03:00

29 lines
953 B
Python

from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword
from keywords.k8s.k8s_command_wrapper import export_k8s_config
class KubectlFileApplyKeywords(BaseKeyword):
"""
K8s file apply keywords
"""
def __init__(self, ssh_connection: SSHConnection):
"""
Initializes the class with an SSH connection.
Args:
ssh_connection (SSHConnection): An instance of SSHConnection to be used for SSH operations.
"""
self.ssh_connection = ssh_connection
def apply_resource_from_yaml(self, yaml_file: str):
"""
Applies a Kubernetes resource using the given YAML file.
Args:
yaml_file (str): The path to the YAML file containing the resource definition.
"""
self.ssh_connection.send(export_k8s_config(f"kubectl apply -f {yaml_file}"))
self.validate_success_return_code(self.ssh_connection)