Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Revert "Revert "Allow site key to be configured by environment (#1573)…
Browse files Browse the repository at this point in the history
…" (#1626)"

This reverts commit ab440ef.
  • Loading branch information
ObsidianMinor committed Nov 2, 2020
1 parent da72960 commit a6c07c2
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/settings/toml/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,24 @@ impl Manifest {
None => self.target_type.clone(),
};

/*
From https://developers.cloudflare.com/workers/cli-wrangler/configuration#keys
Top level: required to be configured at the top level of your wrangler.toml only; multiple environments on the same project must share this property
Inherited: Can be configured at the top level and/or environment. If the property is defined only at the top level, the environment will use the property value from the top level. If the property is defined in the environment, the environment value will override the top level value.
Not inherited: Must be defined for every environment individually.
*/
let mut target = Target {
target_type, // MUST inherit
account_id: self.account_id.clone(), // MAY inherit
webpack_config: self.webpack_config.clone(), // MAY inherit
target_type, // Top level
account_id: self.account_id.clone(), // Inherited
webpack_config: self.webpack_config.clone(), // Inherited
// importantly, the top level name will be modified
// to include the name of the environment
name: self.name.clone(), // MAY inherit
kv_namespaces: get_namespaces(self.kv_namespaces.clone(), preview)?, // MUST NOT inherit
site: self.site.clone(), // MUST NOT inherit
vars: self.vars.clone(), // MAY inherit,
name: self.name.clone(), // Inherited
kv_namespaces: get_namespaces(self.kv_namespaces.clone(), preview)?, // Not inherited
site: self.site.clone(), // Inherited
vars: self.vars.clone(), // Not inherited
};

let environment = self.get_environment(environment_name)?;
Expand All @@ -303,6 +311,10 @@ impl Manifest {
// don't inherit kv namespaces because it is an anti-pattern to use the same namespaces across multiple environments
target.kv_namespaces = get_namespaces(environment.kv_namespaces.clone(), preview)?;

if let Some(site) = &environment.site {
target.site = Some(site.clone());
}

// don't inherit vars
target.vars = environment.vars.clone();
}
Expand Down

0 comments on commit a6c07c2

Please sign in to comment.