pipe-cd / pipe-cd/pipecd

Proposal: Provide official JSON Schema for ECS configuration(maybe other providers too ?)

Open
#6,684 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue
Dominant language
Go
Stars
1.4k
Forks
364
Avg merge
1d 4h
Merged PRs (30d)
84

Description

What would you like to be added: A helper mechanism for validating and exploring YAML configuration fields, ideally with autocomplete and schema validation support.

Why is this needed:

  • Context: When working with the ECS UpdateService API, configuration errors can be surprisingly hard to detect, especially when they involve incorrect field names that are silently ignored or not clearly validated

Example

deploymentConfiguration:
  deploymentStrategy: BLUE_GREEN # Wrong field name, it should be strategy

There is no immediate feedback, the API does not clearly indicate the mismatch which led to significant debugging time. At one point, it even caused confusion for me about whether UpdateService API supports changing deployment strategy at all

My implication for the above example is there should be a way to enforce and robust the way we write config.

Potential solution: Leverage YAML schema validation via JSON Schema, which is already supported by tools like the Red Hat YAML Language Server

How it works ?: By adding this line at the top of a YAML file:

# yaml-language-server: $schema=<path-to-json-schema-file>

How to generate JSON schema ?: By using package github.com/invopop/jsonschema, we can generate a JSON schema like this

	// Generate schema
	r := &jsonschema.Reflector{
		KeyNamer: func(s string) string {
			if len(s) == 0 {
				return s
			}
			return strings.ToLower(s[:1]) + s[1:] // lowercase the first character
		},
		RequiredFromJSONSchemaTags: true,
	}
	schema := r.Reflect(&ecs.CreateServiceInput{})
	output, _ := json.MarshalIndent(schema, "", "  ")

	file, err := os.Create("output.json")
	if err != nil {
		panic(err)
	}
	defer file.Close()

	file.Write(output)

Example result

Image

Should we create and maintain something like this ? https://pipecd.dev/jsonschema/plugins/ecs/service.json

I would love to have discussion about this

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the ECS UpdateService configuration and the proposed github.com/invopop/jsonschema generation approach. Clarify whether the project should maintain an official ECS schema or support other providers too, and define the validation and autocomplete scope before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cloud, devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.