Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the schema of a resource while being compiled by an extension compiler #151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ func (ctx CompilerContext) CompileRef(ref string, refPath string, applicableOnSa
return ctx.c.compileRef(ctx.r, stack, refPath, ctx.res, ref)
}

// GetResourceSchema provides a pointer to the current resource's schema.
//
// Useful in cases where the extension needs to collect metadata about the current
// target of the compilation, such as the absolute location of the resource's schema.
func (ctx CompilerContext) GetResourceSchema() *Schema {
if ctx.res == nil {
return nil
}

return ctx.res.schema
}

// ValidationContext ---

// ValidationContext provides additional context required in validating for extension.
Expand Down