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 helper to check is role enabled #68

Closed
Satbek opened this issue Dec 19, 2023 · 1 comment · Fixed by #69
Closed

Add helper to check is role enabled #68

Satbek opened this issue Dec 19, 2023 · 1 comment · Fixed by #69
Assignees
Labels
feature A new functionality

Comments

@Satbek
Copy link
Contributor

Satbek commented Dec 19, 2023

module runs the same lua code on all instances, but I want to run some lua code only on router, some only on storage. So, i have to write something like this

local function is_storage_master()
    if box.info.ro then
        return false
    end
    
    local roles = cartridge_api_topology.get_enabled_roles_without_deps()
    for _, rname in pairs(roles) do
        if rname == 'crud-storage' then
            return true
        end
    end

    return false
end

please add in utils something like this utils.check_roles_enabled({'crud-storage', 'my_super_role'})

@Satbek Satbek added the feature A new functionality label Dec 19, 2023
@hackallcode
Copy link

Also I want is_router function

@Satbek Satbek linked a pull request Jan 25, 2024 that will close this issue
DifferentialOrange added a commit that referenced this issue Jan 30, 2024
Overview

  This release introduces new helper to check whether roles are enabled
  on the Cartridge instance

New features
  - `utils.check_roles_enabled` helper function
    to check whether roles are enabled on the instance (#68).

Thanks

  We want to thank @Satbek for a feature contribution.
DifferentialOrange added a commit that referenced this issue Jan 30, 2024
Overview

  This release introduces new helper to check whether roles are enabled
  on the Cartridge instance

New features
  - `utils.check_roles_enabled` helper function
    to check whether roles are enabled on the instance (#68).

Thanks

  We want to thank @Satbek for a feature contribution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants