Skip to content

Commit

Permalink
Add javascript template type (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Jan 11, 2023
1 parent 846a4c1 commit 5e55877
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion apps/core/lib/core/schema/dependencies.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ defmodule Core.Schema.Dependencies do
field :breaking, :boolean, default: false
field :wait, :boolean, default: false
field :provider_vsn, :string
field :cli_vsn, :string

embeds_many :dependencies, Dependency, on_replace: :delete
embeds_one :instructions, ChangeInstructions
embeds_one :wirings, Wirings, on_replace: :update
end

@valid ~w(providers provider_wirings application outputs secrets breaking provider_vsn wait)a
@valid ~w(providers provider_wirings application outputs secrets breaking provider_vsn cli_vsn wait)a

def changeset(model, attrs \\ %{}) do
model
Expand Down
2 changes: 1 addition & 1 deletion apps/core/lib/core/schema/version.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Core.Schema.Version do
PackageScan
}

defenum TemplateType, gotemplate: 0, lua: 1
defenum TemplateType, gotemplate: 0, lua: 1, javascript: 2

schema "versions" do
field :version, :string
Expand Down
10 changes: 6 additions & 4 deletions apps/core/lib/core/services/charts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,12 @@ defmodule Core.Services.Charts do
end

def find_template(result, chart) do
Enum.find_value([
{:gotemplate, String.to_charlist("#{chart}/values.yaml.tpl")},
{:lua, String.to_charlist("#{chart}/values.yaml.lua")}
], fn {type, path} ->
Enum.map([
{:gotemplate, "#{chart}/values.yaml.tpl"},
{:lua, "#{chart}/values.yaml.lua"},
{:javascript, "#{chart}/values.yaml.js"}
], fn {type, path} -> {type, String.to_charlist(path)} end)
|> Enum.find_value(fn {type, path} ->
case Enum.find(result, &elem(&1, 0) == path) do
{_, contents} -> {type, contents}
_ -> nil
Expand Down
1 change: 1 addition & 0 deletions apps/graphql/lib/graphql/schema/version.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ defmodule GraphQl.Schema.Version do
field :providers, list_of(:provider)
field :secrets, list_of(:string)
field :provider_vsn, :string
field :cli_vsn, :string
field :application, :boolean
field :provider_wirings, :map
field :outputs, :map
Expand Down

0 comments on commit 5e55877

Please sign in to comment.