Skip to content

Commit cdf3700

Browse files
committed
Added this.calling_bundle variable
Ticket: ENT-12724 Signed-off-by: Victor Moene <victor.moene@northern.tech>
1 parent d95e8a0 commit cdf3700

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

cf-agent/verify_methods.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ PromiseResult VerifyMethod(EvalContext *ctx, const Rval call, const Attributes *
169169

170170
BundleResolve(ctx, bp);
171171

172+
((Bundle *) bp)->calling_bundle = (Bundle *) PromiseGetBundle(pp);
172173
result = ScheduleAgentOperations(ctx, bp);
173174

174175
GetReturnValue(ctx, bp, pp);

libpromises/eval_context.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,12 @@ void EvalContextStackPushPromiseFrame(EvalContext *ctx, const Promise *owner)
15661566

15671567
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "bundle", PromiseGetBundle(owner)->name, CF_DATA_TYPE_STRING, "source=promise");
15681568
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "namespace", PromiseGetNamespace(owner), CF_DATA_TYPE_STRING, "source=promise");
1569+
if (PromiseGetBundle(owner)->calling_bundle != NULL)
1570+
{
1571+
const char *calling_bundle_name = StringFormat("%s:%s", PromiseGetBundle(owner)->calling_bundle->ns, PromiseGetBundle(owner)->calling_bundle->name);
1572+
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "calling_bundle", calling_bundle_name, CF_DATA_TYPE_STRING, "source=promise");
1573+
free(calling_bundle_name);
1574+
}
15691575

15701576
// Recompute `with`
15711577
for (size_t i = 0; i < SeqLength(owner->conlist); i++)

libpromises/policy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ Bundle *PolicyAppendBundle(Policy *policy,
13241324
bundle->custom_sections = SeqNew(10, BundleSectionDestroy);
13251325
bundle->all_promises = SeqNew(10, NULL);
13261326
bundle->evaluation_order = evaluation_order;
1327+
bundle->calling_bundle = NULL;
13271328

13281329
return bundle;
13291330
}

libpromises/policy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ typedef struct
7171
struct Bundle_
7272
{
7373
Policy *parent_policy;
74+
struct Bundle_ *calling_bundle;
7475

7576
char *type;
7677
char *name;

0 commit comments

Comments
 (0)