aboutsummaryrefslogtreecommitdiff
path: root/src/cli/stasis/callbacks.c
blob: aeaa25d52c0077b62b514479b2698291a94d5f74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "callbacks.h"

int callback_except_jf(const void *a, const void *b) {
    const struct EnvCtl_Item *item = a;
    const char *name = b;

    if (!globals.enable_artifactory) {
        return STASIS_ENVCTL_RET_IGNORE;
    }

    if (envctl_check_required(item->flags)) {
        const char *content = getenv(name);
        if (!content || isempty((char *) content)) {
            return STASIS_ENVCTL_RET_FAIL;
        }
    }

    return STASIS_ENVCTL_RET_SUCCESS;
}

int callback_except_gh(const void *a, const void *b) {
    const struct EnvCtl_Item *item = a;
    const char *name = b;
    //printf("GH exception check: %s\n", name);
    if (envctl_check_required(item->flags) && envctl_check_present(item, name)) {
        return STASIS_ENVCTL_RET_SUCCESS;
    }

    return STASIS_ENVCTL_RET_FAIL;
}