Skip to content

Commit

Permalink
Add support for Secret values on general places
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck committed Jul 12, 2020
1 parent 846a49f commit aa9e01a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
22 changes: 14 additions & 8 deletions src/language-service/src/schemas/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { HomeAssistantRoot } from "./homeassistant";
import { DeviceClasses, IncludeNamed, UnitSystem, TimeZone } from "./types";
import {
DeviceClasses,
IncludeNamed,
UnitSystem,
Secret,
TimeZone,
} from "./types";

export interface Core {
auth_mfa_modules?: Array<any> | IncludeNamed; // TODO: Extract similar as in integrations
Expand Down Expand Up @@ -29,7 +35,7 @@ export interface Core {
*
* @TJS-type integer
*/
elevation?: number;
elevation?: number | Secret;

/**
* Latitude of your location required to calculate the time the sun rises and sets.
Expand All @@ -38,7 +44,7 @@ export interface Core {
* @minimum -90
* @maximum 90
*/
latitude?: number;
latitude?: number | Secret;

/**
* Longitude of your location required to calculate the time the sun rises and sets.
Expand All @@ -47,13 +53,13 @@ export interface Core {
* @minimum -180
* @maximum 180
*/
longitude?: number;
longitude?: number | Secret;

/**
* Name of the location where Home Assistant is running.
* https://www.home-assistant.io/docs/configuration/basic/#name
*/
name?: string;
name?: string | Secret;

/**
* Packages in Home Assistant provide a way to bundle different component’s configuration together. It allows for "splitting" your configuration.
Expand All @@ -66,20 +72,20 @@ export interface Core {
* https://www.home-assistant.io/docs/configuration/basic/#time_zone
* https://www.wikiwand.com/en/List_of_tz_database_time_zones
*/
time_zone?: TimeZone;
time_zone?: TimeZone | Secret;

/**
* "metric" for Metric, "imperial" for Imperial.
* This also sets temperature unit Home Assistant will use.
* https://www.home-assistant.io/docs/configuration/basic/#unit_system
*/
unit_system?: UnitSystem;
unit_system?: UnitSystem | Secret;

/**
* List of folders that can be used as sources for sending files.
* https://www.home-assistant.io/docs/configuration/basic/#whitelist_external_dirs
*/
whitelist_external_dirs?: string[];
whitelist_external_dirs?: string[] | Secret;
}

export interface CoreCustomize {
Expand Down
4 changes: 3 additions & 1 deletion src/language-service/src/schemas/integrations/hacs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* https://hacs.xyz/
* Source: https://github.com/hacs/integration/blob/1.1.2/custom_components/hacs/configuration_schema.py
*/
import { Secret } from "../types";

export type Domain = "hacs";
export interface Schema {
/**
Expand All @@ -11,7 +13,7 @@ export interface Schema {
*
* @TJS-pattern ^[0-9a-fA-F]{40}$
*/
token: string;
token: string | Secret;

/**
* Enable tracking of AppDaemon apps.
Expand Down
4 changes: 2 additions & 2 deletions src/language-service/src/schemas/integrations/panel_iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* iframe Panel integration
* Source: https://github.com/home-assistant/core/blob/dev/homeassistant/components/panel_iframe/__init__.py
*/
import { IncludeNamed } from "../types";
import { IncludeNamed, Secret } from "../types";

export type Domain = "panel_iframe";
export interface Schema {
Expand Down Expand Up @@ -34,5 +34,5 @@ interface Item {
*
* @TJS-format uri
*/
url: string;
url: string | Secret;
}
5 changes: 5 additions & 0 deletions src/language-service/src/schemas/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ export type IncludeNamed = string;
*/
export type Integer = number;

/**
* @TJS-pattern ^!secret\s([a-zA-Z0-9_-]+)$
*/
export type Secret = string;

/**
* @TJS-type string
* @TJS-pattern [.]yaml|[.]yml$
Expand Down

0 comments on commit aa9e01a

Please sign in to comment.