From 0e413b69d1444ece3df370e3b2c9de084cf77680 Mon Sep 17 00:00:00 2001 From: chrisghill Date: Fri, 20 Jun 2025 22:30:49 -0600 Subject: [PATCH] Check for and extract name when publish artifact definition --- .github/CODEOWNERS | 2 +- cmd/definition.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0f649b69..577bbee8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @coryodaniel @massdriver-cloud/platform +* @coryodaniel @chrisghill diff --git a/cmd/definition.go b/cmd/definition.go index 2700385d..1f55b55c 100644 --- a/cmd/definition.go +++ b/cmd/definition.go @@ -130,13 +130,18 @@ func runDefinitionPublish(cmd *cobra.Command, args []string) error { return fmt.Errorf("error initializing massdriver client: %w", mdClientErr) } + // TODO: All the logic from here to Publish should be moved into the commands package def := map[string]any{} jsonErr := json.Unmarshal(defBytes, &def) if jsonErr != nil { return jsonErr } - _, nameExists := def["name"].(string) + mdBlock, mdExists := def["$md"].(map[string]any) + if !mdExists { + return fmt.Errorf("artifact definition must have a '$md' block with a 'name' field") + } + _, nameExists := mdBlock["name"].(string) if !nameExists { return fmt.Errorf("artifact definition must have a 'name' field") }