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

Add hook to include custom variables by default when searching under Overview entries #1046

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oskarnrk
Copy link

refs #1045

The hook can be implemented in multiple ways. For example:

Add to run.php

$this->provideHook('Icingadb/CustomVarsRetriever', 'ExampleCustomVarsRetriever');

ExampleCustomVarsRetriever.php

<?php

namespace Icinga\Module\Icingadb\ProvidedHook;

use Icinga\Module\Icingadb\Hook\CustomVarsRetrieverHook;
use ipl\Orm\Model;

class ExampleCustomVarsRetriever extends CustomVarsRetrieverHook
{
    public function retrieveCustomVars(Model $model): array
    {
        switch ($model->getTableName()) {
            case 'host':
                return ['host.vars.hostfoo', 'host.vars.hostbar'];
            case 'service':
                return ['service.vars.servicefoo', 'service.vars.servicebar'];
            default:
                return [];
        }
    }
}

Some implementation suggestions could be:

  • retrieve the custom vars and filter letting pass only the ones that actually exist
  • provide multiple hooks to implement different logic for a specific model (it's given as input)
  • save the wanted custom variables in a config.ini file and retrieve them from it

Copy link

cla-bot bot commented Aug 20, 2024

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Oscar Zambotti.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@oskarnrk oskarnrk closed this Aug 20, 2024
@oskarnrk oskarnrk force-pushed the feature/custom-vars-default-search-1045 branch from 5c2b7d3 to 334aaf8 Compare August 20, 2024 12:59
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Aug 20, 2024
@oskarnrk oskarnrk reopened this Aug 20, 2024
Copy link

cla-bot bot commented Aug 20, 2024

Thank you for your pull request. Before we can look at it, you'll need to sign a Contributor License Agreement (CLA).

Please follow instructions at https://icinga.com/company/contributor-agreement to sign the CLA.

After that, please reply here with a comment and we'll verify.

Contributors that have not signed yet: @oskarnrk

  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Please contact us if you think this is the case.

  • If you signed the CLA as a corporation, your GitHub username may not have been submitted to us. Please reach out to the responsible person in your organization.

@cla-bot cla-bot bot removed the cla/signed CLA is signed by all contributors of a PR label Aug 20, 2024
@oskarnrk
Copy link
Author

Thank you for your pull request. Before we can look at it, you'll need to sign a Contributor License Agreement (CLA).

Please follow instructions at https://icinga.com/company/contributor-agreement to sign the CLA.

After that, please reply here with a comment and we'll verify.

Contributors that have not signed yet: @oskarnrk

I signed the ICLA, thanks in advance.

@oskarnrk
Copy link
Author

Is it possibile to retrigger the CLA check? Thanks

@bobapple
Copy link
Member

@cla-bot check

@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed CLA is signed by all contributors of a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants