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

Kubernetes crd detection #1

Open
wants to merge 4 commits into
base: kubernetes_crd_detection
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lua/yaml-companion/_matchers/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ matchers.manager = setmetatable({}, {
t[k] = {
health = m.health or function()
local health = vim.health
health.report_info("No healthcheck provided")
health.info("No healthcheck provided")
end,
match = m.match or function(_)
return nil
Expand Down
20 changes: 18 additions & 2 deletions lua/yaml-companion/builtin/kubernetes/resources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ return {
"ClusterRoleBinding",
"ClusterRoleBindingList",
"ClusterRoleList",
"ClusterTrustBundle",
"ClusterTrustBundleList",
"ComponentStatus",
"ComponentStatusList",
"ConfigMap",
Expand All @@ -48,6 +50,8 @@ return {
"FlowSchemaList",
"HorizontalPodAutoscaler",
"HorizontalPodAutoscalerList",
"IPAddress",
"IPAddressList",
"Ingress",
"IngressClass",
"IngressClassList",
Expand Down Expand Up @@ -75,8 +79,8 @@ return {
"PodDisruptionBudget",
"PodDisruptionBudgetList",
"PodList",
"PodScheduling",
"PodSchedulingList",
"PodSchedulingContext",
"PodSchedulingContextList",
"PodTemplate",
"PodTemplateList",
"PriorityClass",
Expand All @@ -89,12 +93,18 @@ return {
"ReplicationControllerList",
"ResourceClaim",
"ResourceClaimList",
"ResourceClaimParameters",
"ResourceClaimParametersList",
"ResourceClaimTemplate",
"ResourceClaimTemplateList",
"ResourceClass",
"ResourceClassList",
"ResourceClassParameters",
"ResourceClassParametersList",
"ResourceQuota",
"ResourceQuotaList",
"ResourceSlice",
"ResourceSliceList",
"Role",
"RoleBinding",
"RoleBindingList",
Expand All @@ -110,6 +120,8 @@ return {
"Service",
"ServiceAccount",
"ServiceAccountList",
"ServiceCIDR",
"ServiceCIDRList",
"ServiceList",
"StatefulSet",
"StatefulSetList",
Expand All @@ -118,6 +130,8 @@ return {
"StorageClassList",
"StorageVersion",
"StorageVersionList",
"StorageVersionMigration",
"StorageVersionMigrationList",
"SubjectAccessReview",
"TokenRequest",
"TokenReview",
Expand All @@ -129,5 +143,7 @@ return {
"ValidatingWebhookConfigurationList",
"VolumeAttachment",
"VolumeAttachmentList",
"VolumeAttributesClass",
"VolumeAttributesClassList",
"WatchEvent",
}
7 changes: 3 additions & 4 deletions lua/yaml-companion/context/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ M.schema = function(bufnr, new_schema)

local bufuri = vim.uri_from_bufnr(bufnr)
local client = M.ctxs[bufnr].client
local settings = client.config.settings
local settings = client.settings

-- we don't want more than 1 schema per file
for key, _ in pairs(settings.yaml.schemas) do
Expand All @@ -165,9 +165,8 @@ M.schema = function(bufnr, new_schema)
log.fmt_debug("file=%s schema=%s set new override", bufuri, new_schema.uri)

settings = vim.tbl_deep_extend("force", settings, { yaml = { schemas = override } })
client.config.settings =
vim.tbl_deep_extend("force", settings, { yaml = { schemas = override } })
client.workspace_did_change_configuration(client.config.settings)
client.settings = vim.tbl_deep_extend("force", settings, { yaml = { schemas = override } })
client.workspace_did_change_configuration(client.settings)
end

return M.ctxs[bufnr].schema
Expand Down
16 changes: 8 additions & 8 deletions lua/yaml-companion/health.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,32 @@ M.check = function()
if not binary_installed(binary.bin) then
local bin_not_installed = binary.bin .. " not found"
if binary.optional then
health.report_warn(("%s %s"):format(bin_not_installed, binary.info))
health.warn(("%s %s"):format(bin_not_installed, binary.info))
else
health.report_error(binary.bin .. " not found")
health.error(binary.bin .. " not found")
end
else
health.report_ok(binary.bin .. " found")
health.ok(binary.bin .. " found")
end
end

health.report_start("Checking for plugins")
health.start("Checking for plugins")
for _, plugin in ipairs(plugins) do
if lualib_installed(plugin.lib) then
health.report_ok(plugin.lib .. " installed")
health.ok(plugin.lib .. " installed")
else
local lib_not_installed = plugin.lib .. " not found"
if plugin.optional then
health.report_warn(("%s %s"):format(lib_not_installed, plugin.info))
health.warn(("%s %s"):format(lib_not_installed, plugin.info))
else
health.report_error(lib_not_installed)
health.error(lib_not_installed)
end
end
end

local matchers = require("yaml-companion._matchers")._loaded
for name, matcher in pairs(matchers) do
health.report_start(string.format("Matcher: `%s`", name))
health.start(string.format("Matcher: `%s`", name))
matcher.health()
end
end
Expand Down