Skip to content

Commit

Permalink
Check that only one of the kubeconfig_t::fileName and kubeconfig_t::b…
Browse files Browse the repository at this point in the history
…uffer is set

Add documentation note stating that only of the kubeconfig_t::fileName and kubeconfig_t::buffer may be set
  • Loading branch information
DanyT committed Jul 3, 2024
1 parent 8f759fc commit 34d1b13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kubernetes/config/kube_config_yaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions kubernetes/config/kube_config_yaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 34d1b13

Please sign in to comment.