Skip to content

Commit

Permalink
ui is not a tool - update the schema to reflect that
Browse files Browse the repository at this point in the history
Programatically add 'ui' as a format to gateway_entity pages
  • Loading branch information
fabianrbz committed Nov 19, 2024
1 parent 40fedb0 commit 2839cdc
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 17 deletions.
3 changes: 1 addition & 2 deletions app/_data/schemas/frontmatter/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
"kic",
"terraform",
"admin-api",
"konnect-api",
"ui"
"konnect-api"
]
}
},
Expand Down
1 change: 0 additions & 1 deletion app/_gateway_entities/consumer.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ tools:
- konnect-api
- kic
- deck
- ui
- terraform

api_specs:
Expand Down
1 change: 0 additions & 1 deletion app/_gateway_entities/consumer_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ tools:
- konnect-api
- kic
- deck
- ui
- terraform

tier: enterprise
Expand Down
1 change: 0 additions & 1 deletion app/_gateway_entities/route.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ tools:
- konnect-api
- kic
- deck
- ui
- terraform

schema:
Expand Down
1 change: 0 additions & 1 deletion app/_gateway_entities/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ tools:
- konnect-api
- kic
- deck
- ui
- terraform

schema:
Expand Down
1 change: 0 additions & 1 deletion app/_gateway_entities/target.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ tools:
- konnect-api
- kic
- deck
- ui
- terraform

description: A target identifies a specific instance of an upstream service.
Expand Down
1 change: 0 additions & 1 deletion app/_gateway_entities/upstream.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ tools:
- admin-api
- kic
- deck
- ui
- terraform

description: An upstream refers to the service applications sitting behind Kong Gateway, to which client requests are forwarded.
Expand Down
1 change: 0 additions & 1 deletion app/_gateway_entities/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ tools:
- admin-api
- kic
- deck
- ui
- terraform

tier: enterprise
Expand Down
22 changes: 14 additions & 8 deletions app/_plugins/blocks/entity_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

module Jekyll
class EntityExample < Liquid::Block
def render(context) # rubocop:disable Metrics/MethodLength
def render(context) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
@context = context
@site = context.registers[:site]
@page = context.environments.first['page']
environment = context.environments.first

contents = super

example = YAML.load(contents)
example = example.merge('formats' => @page['tools']) unless example['formats']
example = example.merge('formats' => formats(@page)) unless example['formats']

unless example['formats']
raise ArgumentError, "Missing key `tools` in metadata, or `formats` in entity_example block on page #{@page['path']}"
raise ArgumentError,
"Missing key `tools` in metadata, or `formats` in entity_example block on page #{@page['path']}"
end

entity_example = EntityExampleBlock::Base.make_for(example: example)
Expand All @@ -30,11 +30,17 @@ def render(context) # rubocop:disable Metrics/MethodLength
end
rescue Psych::SyntaxError => e
message = <<~STRING
On `#{@page['path']}`, the following {% entity_example %} block contains a malformed yaml:
#{contents.strip.split("\n").each_with_index.map { |l, i| "#{i}: #{l}" }.join("\n")}
#{e.message}
On `#{@page['path']}`, the following {% entity_example %} block contains a malformed yaml:
#{contents.strip.split("\n").each_with_index.map { |l, i| "#{i}: #{l}" }.join("\n")}
#{e.message}
STRING
raise ArgumentError.new(message)
raise ArgumentError, message
end

def formats(page)
return page['tools'] unless page['layout'] == 'gateway_entity'

page['tools'].dup << 'ui'
end
end
end
Expand Down

0 comments on commit 2839cdc

Please sign in to comment.