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

Abierto
#6,684 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

  • #6744 de @madmecodes — cerrado sin fusionar

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
38/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Tranquilo
Stack tecnológico
go
Área
cloud, devops

Línea de trabajo

Comienza revisando la configuración de ECS UpdateService y el enfoque propuesto de generación con github.com/invopop/jsonschema. Aclara si el proyecto debe mantener un esquema oficial de ECS o admitir también otros proveedores, y define el alcance de la validación y el autocompletado antes de la implementación.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

good first issue

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

Lenguaje dominante
Go
Estrellas
1.4k
Forks
391
Merge medio
4 d 1 h
PR fusionados (30 d)
58

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pipe-cd/pipecd

Todos los issues de pipe-cd/pipecd

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.