mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Move defaultAccess to static property
This commit is contained in:
2 files changed
+6
-6
No files matched your search
@@ -198,6 +198,9 @@ export class Config<
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Defines the default access locations for the config class */
|
||||||
|
static defaultAccess: ConfigLocation[] = ["controller", "host", "control"];
|
||||||
|
|
||||||
fields: Fields;
|
fields: Fields;
|
||||||
_unknownFields: Record<string, FieldValue> = {};
|
_unknownFields: Record<string, FieldValue> = {};
|
||||||
|
|
||||||
@@ -217,7 +220,6 @@ export class Config<
|
|||||||
constructor(
|
constructor(
|
||||||
public location: ConfigLocation,
|
public location: ConfigLocation,
|
||||||
fields?: Static<typeof Config.jsonSchema>,
|
fields?: Static<typeof Config.jsonSchema>,
|
||||||
public defaultAccess: ConfigLocation[] = ["controller", "host", "control"],
|
|
||||||
) {
|
) {
|
||||||
if (typeof location !== "string") {
|
if (typeof location !== "string") {
|
||||||
throw new Error("location must be a string");
|
throw new Error("location must be a string");
|
||||||
@@ -262,7 +264,7 @@ export class Config<
|
|||||||
|| (
|
|| (
|
||||||
(!def.credential || mode & ConfigAccess.write)
|
(!def.credential || mode & ConfigAccess.write)
|
||||||
&& (!def.readonly || mode & ConfigAccess.read)
|
&& (!def.readonly || mode & ConfigAccess.read)
|
||||||
&& !(def.access ?? this.defaultAccess).includes(location)
|
&& !(def.access ?? this.constructor.defaultAccess).includes(location)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ const CA = lib.ConfigAccess;
|
|||||||
describe("lib/config/classes", function() {
|
describe("lib/config/classes", function() {
|
||||||
describe("Config", function() {
|
describe("Config", function() {
|
||||||
class TestConfig extends lib.Config {
|
class TestConfig extends lib.Config {
|
||||||
|
static defaultAccess = ["local", "remote"];
|
||||||
|
|
||||||
static migrations(config) {
|
static migrations(config) {
|
||||||
if (config.hasOwnProperty("test.migration")) {
|
if (config.hasOwnProperty("test.migration")) {
|
||||||
config["alpha.foo"] = config["test.migration"];
|
config["alpha.foo"] = config["test.migration"];
|
||||||
@@ -38,10 +40,6 @@ describe("lib/config/classes", function() {
|
|||||||
"test.cred": { credential: ["local"] },
|
"test.cred": { credential: ["local"] },
|
||||||
"test.rdo": { readonly: ["local"] },
|
"test.rdo": { readonly: ["local"] },
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(location, fields) {
|
|
||||||
super(location, fields, ["local", "remote"]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("constructor", function() {
|
describe("constructor", function() {
|
||||||
|
|||||||
Reference in new issue
Block a user