# Buggy code
def generate_tmp_kube_config(credential, namespace):
    host_input = credential.get_input("host")
    config = {
        "apiVersion": "v1",
        "kind": "Config",
        "preferences": {},
        "clusters": [{"name": host_input, "cluster": {"server": host_input}}],
        "users": [
            {
                "name": host_input,
                "user": {"token": credential.get_input("bearer_token")},
            }
        ],
        "contexts": [
            {
                "name": host_input,
                "context": {
                    "cluster": host_input,
                    "user": host_input,
                    "namespace": namespace,
                },
            }
        ],
        "current-context": host_input,
    }

    if credential.get_input("verify_ssl"):
        config["clusters"][0]["cluster"]["certificate-authority-data"] = b64encode(
            credential.get_input("ssl_ca_cert").encode()  # encode to bytes
        ).decode()  # decode the base64 data into a str
    else:
        config["clusters"][0]["cluster"]["insecure-skip-tls-verify"] = True
    return config


# Traceback (AttributeError)
Traceback (most recent call last):
File "/awx_devel/awx/main/scheduler/kubernetes.py", line 55, in list_active_jobs
for pod in pm.kube_api.list_namespaced_pod(
File "/venv/awx/lib64/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/awx_devel/awx/main/scheduler/kubernetes.py", line 91, in kube_api
config_dict=self.kube_config
File "/venv/awx/lib64/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/awx_devel/awx/main/scheduler/kubernetes.py", line 83, in kube_config
return generate_tmp_kube_config(self.credential, self.namespace)
File "/awx_devel/awx/main/scheduler/kubernetes.py", line 178, in generate_tmp_kube_config
credential.get_input('ssl_ca_cert').encode() # encode to bytes
File "/awx_devel/awx/main/models/credential/__init__.py", line 288, in get_input
raise AttributeError
AttributeError

# Fixed code
def generate_tmp_kube_config(credential, namespace):
    host_input = credential.get_input("host")
    config = {
        "apiVersion": "v1",
        "kind": "Config",
        "preferences": {},
        "clusters": [{"name": host_input, "cluster": {"server": host_input}}],
        "users": [
            {
                "name": host_input,
                "user": {"token": credential.get_input("bearer_token")},
            }
        ],
        "contexts": [
            {
                "name": host_input,
                "context": {
                    "cluster": host_input,
                    "user": host_input,
                    "namespace": namespace,
                },
            }
        ],
        "current-context": host_input,
    }

    if credential.get_input("verify_ssl") and "ssl_ca_cert" in credential.inputs:
        config["clusters"][0]["cluster"]["certificate-authority-data"] = b64encode(
            credential.get_input("ssl_ca_cert").encode()  # encode to bytes
        ).decode()  # decode the base64 data into a str
    else:
        config["clusters"][0]["cluster"]["insecure-skip-tls-verify"] = True
    return config