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
Update for Functions GA #1136
Merged
Merged
Update for Functions GA #1136
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:enhancement | ||
pages: Updates bindings and other Functions related propreties. Service bindings, secrets, fail open/close and usage model are all now supported. | ||
``` | ||
|
||
```release-note:breaking-change | ||
pages: Changed the type of EnvVars in PagesProjectDeploymentConfigEnvironment & PagesProjectDeployment in order to properly support secrets. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,18 +67,17 @@ type PagesProjectDeploymentConfigs struct { | |
|
||
// PagesProjectDeploymentConfigEnvironment represents the configuration for preview or production deploys. | ||
type PagesProjectDeploymentConfigEnvironment struct { | ||
EnvVars map[string]PagesProjectDeploymentVar `json:"env_vars"` | ||
CompatibilityDate string `json:"compatibility_date,omitempty"` | ||
CompatibilityFlags []string `json:"compatibility_flags,omitempty"` | ||
KvNamespaces NamespaceBindingMap `json:"kv_namespaces,omitempty"` | ||
DoNamespaces NamespaceBindingMap `json:"durable_object_namespaces,omitempty"` | ||
D1Databases D1BindingMap `json:"d1_databases,omitempty"` | ||
R2Bindings R2BindingMap `json:"r2_buckets,omitempty"` | ||
} | ||
|
||
// PagesProjectDeploymentVar represents a deployment environment variable. | ||
type PagesProjectDeploymentVar struct { | ||
Value string `json:"value"` | ||
EnvVars EnvironmentVariableMap `json:"env_vars,omitempty"` | ||
KvNamespaces NamespaceBindingMap `json:"kv_namespaces,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar with these types. as we are breaking changes already, can we fix these up? |
||
DoNamespaces NamespaceBindingMap `json:"durable_object_namespaces,omitempty"` | ||
D1Databases D1BindingMap `json:"d1_databases,omitempty"` | ||
R2Bindings R2BindingMap `json:"r2_buckets,omitempty"` | ||
ServiceBindings ServiceBindingMap `json:"services,omitempty"` | ||
CompatibilityDate string `json:"compatibility_date,omitempty"` | ||
CompatibilityFlags []string `json:"compatibility_flags,omitempty"` | ||
FailOpen bool `json:"fail_open"` | ||
AlwaysUseLatestCompatibilityDate bool `json:"always_use_latest_compatibility_date"` | ||
UsageModel UsageModel `json:"usage_model,omitempty"` | ||
} | ||
|
||
// PagesProjectDeployment represents a deployment to a Pages project. | ||
|
@@ -93,13 +92,20 @@ type PagesProjectDeployment struct { | |
ModifiedOn *time.Time `json:"modified_on"` | ||
Aliases []string `json:"aliases,omitempty"` | ||
LatestStage PagesProjectDeploymentStage `json:"latest_stage"` | ||
EnvVars map[string]map[string]string `json:"env_vars"` | ||
EnvVars EnvironmentVariableMap `json:"env_vars"` | ||
KvNamespaces NamespaceBindingMap `json:"kv_namespaces,omitempty"` | ||
DoNamespaces NamespaceBindingMap `json:"durable_object_namespaces,omitempty"` | ||
D1Databases D1BindingMap `json:"d1_databases,omitempty"` | ||
R2Bindings R2BindingMap `json:"r2_buckets,omitempty"` | ||
ServiceBindings ServiceBindingMap `json:"services,omitempty"` | ||
DeploymentTrigger PagesProjectDeploymentTrigger `json:"deployment_trigger"` | ||
Stages []PagesProjectDeploymentStage `json:"stages"` | ||
BuildConfig PagesProjectBuildConfig `json:"build_config"` | ||
Source PagesProjectSource `json:"source"` | ||
CompatibilityDate string `json:"compatibility_date,omitempty"` | ||
CompatibilityFlags []string `json:"compatibility_flags,omitempty"` | ||
UsageModel UsageModel `json:"usage_model,omitempty"` | ||
IsSkipped bool `json:"is_skipped"` | ||
ProductionBranch string `json:"production_branch,omitempty"` | ||
} | ||
|
||
|
@@ -135,6 +141,21 @@ type pagesProjectListResponse struct { | |
ResultInfo `json:"result_info"` | ||
} | ||
|
||
type EnvironmentVariableMap map[string]*EnvironmentVariable | ||
|
||
// PagesProjectDeploymentVar represents a deployment environment variable. | ||
type EnvironmentVariable struct { | ||
Value string `json:"value"` | ||
Type EnvVarType `json:"type"` | ||
} | ||
|
||
type EnvVarType string | ||
|
||
const ( | ||
PlainText EnvVarType = "plain_text" | ||
SecretText EnvVarType = "secret_text" | ||
) | ||
|
||
type NamespaceBindingMap map[string]*NamespaceBindingValue | ||
|
||
type NamespaceBindingValue struct { | ||
|
@@ -153,6 +174,20 @@ type D1Binding struct { | |
ID string `json:"id"` | ||
} | ||
|
||
type ServiceBindingMap map[string]*ServiceBinding | ||
|
||
type ServiceBinding struct { | ||
Service string `json:"service"` | ||
Environment string `json:"environment"` | ||
} | ||
|
||
type UsageModel string | ||
|
||
const ( | ||
Bundled UsageModel = "bundled" | ||
Unbound UsageModel = "unbound" | ||
) | ||
|
||
// ListPagesProjects returns all Pages projects for an account. | ||
// | ||
// API reference: https://api.cloudflare.com/#pages-project-get-projects | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in a typed language, this is a bit of a code smell. instead of including the type (map) in the name, could we call it EnvVars that expects a
[]map[string]EnvironmentVariable
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use these types internally, so I'd personally like to keep this consistent. I can change if you really want though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, let's keep them for consistency but the only caveat is once we start looking at codegen'ing the library, this will be changed again to be the concrete type of
map[string]*EnvironmentVariable
so we'll be inconsistent there once that happens.