Check that only one of the kubeconfig_t::fileName and kubeconfig_t::buffer is set

Add documentation note stating that only of the kubeconfig_t::fileName and kubeconfig_t::buffer may be set
This commit is contained in:
DanyT
2024-07-03 09:18:24 +03:00
parent 8f759fcfb7
commit 34d1b13efe
2 changed files with 8 additions and 1 deletions

View File

@@ -430,6 +430,11 @@ int kubeyaml_load_kubeconfig(kubeconfig_t * kubeconfig)
{
static char fname[] = "kubeyaml_load_kubeconfig()";
if (kubeconfig->fileName && kubeconfig->buffer) {
fprintf(stderr, "%s: Cannot use both kubeconfig->fileName and kubeconfig->buffer.\n", fname);
return -1;
}
/* Set a file input or use the provided buffer. */
FILE *input = NULL;
if (kubeconfig->fileName) {
@@ -443,7 +448,7 @@ int kubeyaml_load_kubeconfig(kubeconfig_t * kubeconfig)
// Nothing to do here for now.
}
else {
fprintf(stderr, "%s: The kubeconf file name needs be set by kubeconfig->fileName .\n", fname);
fprintf(stderr, "%s: One of the kubeconfig->fileName or kubeconfig->buffer needs to be set.\n", fname);
return -1;
}

View File

@@ -26,6 +26,8 @@ extern "C" {
* kubeconfig->fileName: kubernetes cluster configuration file name
* kubeconfig->buffer: kubernetes cluster configuration data; this is considered only if kubeconfig->fileName is set to NULL
*
* Note: One may use either kubeconfig->fileName or kubeconfig->buffer but not both at the same time.
*
* OUT:
* kubeconfig: kubernetes cluster configuration
*