Skip to content
Open
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
125 changes: 58 additions & 67 deletions schema/input.ts
Original file line number Diff line number Diff line change
@@ -1,82 +1,73 @@
import { UiConfig } from "./ui";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum and options are duplicated
also shall we standardize enum / list / options - all seem to be doing the same thing

/**
* @x-go-file input.go
*/
export interface Input {
/**
* Type defines the input type.
*/
type:
| "string"
| "number"
| "boolean"
| "array"
| "duration"
| "choice" // GitHub compatibility
| "environment" // GitHub compatibility
| "secret";

/**
* Type defines the input type.
*/
type:
"string"
| "number"
| "boolean"
| "array"
| "duration"
| "choice" // GitHub compatibility
| "environment" // GitHub compatibility
| "secret"

/**
* Description defines the input description.
*/
description?: string

/**
* @go-type: interface{}
*/
default?: any

/**
* Required indicates the input is required.
*/
required?: boolean;
/**
* Description defines the input description.
*/
description?: string;

/**
* Items defines an array type.
*/
items?: any[]
/**
* @go-type: interface{}
* Default value populated for this input
*/
default?: any;

/**
* Enum defines a list of accepted input values.
*/
enum?: any[]
/**
* Required indicates the input is required.
*/
required?: boolean;

/**
* Pattern defines a regular expression input constraint.
*/
pattern?: string;
/**
* Items defines an array type.
*/
items?: any[];

/**
* Component defines the form element that should be used to
* render the input.
*/
component?: "dropdown" | "text" | "number" | "date" | "datetime" | string;
/**
* Enum defines a list of accepted input values.
*/
enum?: any[];

/**
* Autofocus configures the form element autofocus attribute.
*/
autofocus?: boolean;
/**
* Options defines a list of accepted input values.
* This is an alias for enum.
* @github
*/
options?: any[];

/**
* Placeholder configures the form element placeholder attribute.
*/
placeholder?: string;
/**
* Pattern defines a regular expression input constraint.
*/
pattern?: string;

/**
* Tooltip configures the form element alt attribute.
*/
tooltip?: string;
/**
* Mask indicates the input should be masked.
* @deprecated
*/
mask?: boolean;

/**
* Options defines a list of accepted input values.
* This is an alias for enum.
* @github
*/
options?: any[]
/**
* Label to be displayed in the UI for this input
*/
label?: string;

/**
* Mask indicates the input should be masked.
* @deprecated
*/
mask?: boolean
/**
* Config to override default UI rendering behaviour
*/
ui?: UiConfig;
}
42 changes: 42 additions & 0 deletions schema/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,46 @@ export interface Template {
inputs?: Record<string, Input>
stage?: Stage;
step?: Step;

/**
* Provide a Layout to control ordering and grouping of inputs in the UI
*/
layout?: Layout

/**
* Base64 encoded image to be shown in the list of templates
*/
icon?: string

/**
* enum of supported logo names from Harness Design System
* https://harness-design.netlify.app/components/logo/#available-logos
*/
iconName?: string

/**
* Absolute URL to a hosted image
*/
iconUrl?: string

id?: string
name?: string
description?: string
version?: string
author?: "harness" | string
alias?: "build" | "deploy"
module?: Array<"cd" | "ci">
tags?: Record<string, string>
}

type Layout = Array<InputName | InputGroup>
type InputName = string

/*
* InputGroups will be shown as accordions in the UI if a title is provided
*/
interface InputGroup {
items: Layout // you can have nested groups within groups
title?: string
open?: boolean
}
37 changes: 37 additions & 0 deletions schema/ui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export interface UiConfig {
/**
* CEL expression to add dynamic behaviour.
* This input will be displayed only when this condition is true.
* All inputs in this template are available to reference here.
*/
visible?: string

/**
* Component defines the form element that should be used to
* override the default renderer for the input.
*/
component?: "dropdown" | "text" | "number" | "date" | "datetime" | "select" | string;

/**
* Autofocus configures the form element autofocus attribute.
*/
autofocus?: boolean;

/**
* Placeholder configures the form element placeholder attribute.
*/
placeholder?: string;

/**
* Tooltip configures the form element alt attribute.
*/
tooltip?: string;

/**
* Types of values allowed for this input.
* Fixed: User must enter value when configuring the pipeline
* Runtime: User must enter value when running the pipeline
* Expression: Value will be derived by evaluating this CEL / JEXL expression
*/
allowedValueTypes?: Array<'fixed' | 'runtime' | 'expression'>
}