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

Enable API Gateway v2 (HTTP) for expose #246

Merged
merged 5 commits into from
Feb 16, 2023
Merged
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
40 changes: 34 additions & 6 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type (
}
Expose struct {
Type string `json:"type" yaml:"type" toml:"type"`
ApiType string `json:"api_type" yaml:"api_type" toml:"api_type"`
ContentDeliveryNetwork ContentDeliveryNetwork `json:"content_delivery_network,omitempty" yaml:"content_delivery_network,omitempty" toml:"content_delivery_network,omitempty"`
InfraParams InfraParams `json:"pulumi_params,omitempty" yaml:"pulumi_params,omitempty" toml:"pulumi_params,omitempty"`
}
Expand Down Expand Up @@ -70,7 +71,7 @@ type (
Defaults struct {
ExecutionUnit KindDefaults `json:"execution_unit" yaml:"execution_unit" toml:"execution_unit"`
StaticUnit KindDefaults `json:"static_unit" yaml:"static_unit" toml:"static_unit"`
Expose KindDefaults `json:"expose" yaml:"expose" toml:"expose"`
Expose ExposeDefaults `json:"expose" yaml:"expose" toml:"expose"`
Persist PersistKindDefaults `json:"persist" yaml:"persist" toml:"persist"`
PubSub KindDefaults `json:"pubsub" yaml:"pubsub" toml:"pubsub"`
}
Expand All @@ -80,6 +81,12 @@ type (
InfraParamsByType map[string]InfraParams `json:"pulumi_params_by_type,omitempty" yaml:"pulumi_params_by_type,omitempty" toml:"pulumi_params_by_type,omitempty"`
}

ExposeDefaults struct {
KindDefaults
ApiType string `json:"api_type" yaml:"api_type" toml:"api_type"`
ContentDeliveryNetwork ContentDeliveryNetwork `json:"content_delivery_network,omitempty" yaml:"content_delivery_network,omitempty" toml:"content_delivery_network,omitempty"`
}

PersistKindDefaults struct {
KV KindDefaults `json:"kv" yaml:"kv" toml:"kv"`
FS KindDefaults `json:"fs" yaml:"fs" toml:"fs"`
Expand Down Expand Up @@ -157,6 +164,14 @@ func (cfg *KindDefaults) Merge(other KindDefaults) {
}
}

func (cfg *ExposeDefaults) Merge(other ExposeDefaults) {
cfg.KindDefaults.Merge(other.KindDefaults)
cfg.ContentDeliveryNetwork.Merge(other.ContentDeliveryNetwork)
if other.ApiType != "" {
cfg.ApiType = other.ApiType
}
}

func (cfg *ExecutionUnit) Merge(other ExecutionUnit) {
if other.Type != "" {
cfg.Type = other.Type
Expand All @@ -176,11 +191,20 @@ func (cfg *ExecutionUnit) Merge(other ExecutionUnit) {
cfg.InfraParams.Merge(other.InfraParams)
}

func (cfg *ContentDeliveryNetwork) Merge(other ContentDeliveryNetwork) {
if other.Id != "" {
cfg.Id = other.Id
}
}

func (cfg *Expose) Merge(other Expose) {
if other.Type != "" {
cfg.Type = other.Type
}
cfg.ContentDeliveryNetwork = other.ContentDeliveryNetwork
if other.ApiType != "" {
cfg.ApiType = other.ApiType
}
cfg.ContentDeliveryNetwork.Merge(other.ContentDeliveryNetwork)
cfg.InfraParams.Merge(other.InfraParams)
}

Expand Down Expand Up @@ -297,17 +321,21 @@ func (a Application) GetExposed(id string) Expose {
exposeType = defaultType
}
defaults := Expose{
Type: exposeType,
InfraParams: a.Defaults.Expose.InfraParamsByType[exposeType],
Type: exposeType,
ApiType: a.Defaults.Expose.ApiType,
ContentDeliveryNetwork: a.Defaults.Expose.ContentDeliveryNetwork,
InfraParams: a.Defaults.Expose.InfraParamsByType[exposeType],
}
if ecfg.Type == defaults.Type || ecfg.Type == "" {
cfg.Merge(defaults)
}
cfg.Merge(*ecfg)
} else {
defaults := Expose{
Type: defaultType,
InfraParams: a.Defaults.Expose.InfraParamsByType[defaultType],
Type: defaultType,
ApiType: a.Defaults.Expose.ApiType,
ContentDeliveryNetwork: a.Defaults.Expose.ContentDeliveryNetwork,
InfraParams: a.Defaults.Expose.InfraParamsByType[defaultType],
}
cfg.Merge(defaults)
}
Expand Down
Loading