Skip to content

Commit b583e16

Browse files
committed
feat: #171 Adding metadata and examples files, adjusting doc
Signed-off-by: Laurent Broudoux <[email protected]>
1 parent 2a0ab43 commit b583e16

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

cmd/importDir.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ func NewImportDirCommand(globalClientOpts *connectors.ClientOptions) *cobra.Comm
183183
fmt.Printf("✗ Failed: %s - %s\n", file, errorMsg)
184184
}
185185
} else {
186+
fmt.Println("\nImport results:")
186187
for _, file := range result.SuccessFiles {
187188
fmt.Printf("✓ Imported: %s\n", file)
188189
}
@@ -230,12 +231,18 @@ func ImportDirectory(client MicrocksClient, fs FileSystem, dirPath string, confi
230231
for _, file := range files {
231232
fileType := detectFileType(file)
232233

233-
_, err := client.UploadArtifact(file, fileType.IsPrimary)
234+
msg, err := client.UploadArtifact(file, fileType.IsPrimary)
234235
if err != nil {
235236
result.FailedCount++
236237
result.FailedFiles = append(result.FailedFiles, file)
237238
result.Errors = append(result.Errors, fmt.Sprintf("error importing %s: %v", file, err))
238239
continue
240+
} else {
241+
action := "discovered"
242+
if !fileType.IsPrimary {
243+
action = "completed"
244+
}
245+
fmt.Printf("Microcks has %s '%s'\n", action, msg)
239246
}
240247

241248
result.SuccessCount++
@@ -308,7 +315,7 @@ func detectFileType(filePath string) FileType {
308315
// Default to primary for most files
309316
isPrimary := true
310317

311-
if strings.Contains(fileName, "postman") || strings.Contains(fileName, "collection") {
318+
if strings.Contains(fileName, "postman") || strings.Contains(fileName, "collection") || strings.Contains(fileName, "metadata") || strings.Contains(fileName, "examples") {
312319
isPrimary = false
313320
}
314321

documentation/cmd/import.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ microcks import ./api.yaml \
2424
--keycloakClientSecret <client-secret>
2525

2626
# Import specification to microcks running without authentication (ie. local uber instance typically)
27-
microcks import ./api.yaml --micrcoksURL <microcks-url>
27+
microcks import ./api.yaml --microcksURL <microcks-url>
2828
```
2929

3030
### Options

documentation/cmd/importDir.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ The `import-dir` command in Microcks CLI is used to import multiple API specific
44

55
📝 Description
66

7-
The `import-dir` command provides a convenient way to bulk import API specifications from a local directory. It automatically scans for supported file types and imports them into Microcks. This is particularly useful for CI/CD pipelines, bulk operations, and managing large collections of API specifications.
7+
The `import-dir` command provides a convenient way to bulk import API specifications from a local directory. It automatically scans for supported file types and imports them into Microcks.
8+
This is particularly useful for CI/CD pipelines, bulk operations, and managing large collections of API specifications.
89

910
📌 Usage
1011
```bash
@@ -42,6 +43,19 @@ microcks import-dir ./api-specs --pattern "*.yaml"
4243
microcks import-dir ./api-specs --recursive --pattern "openapi.*"
4344
```
4445

46+
- Import specification to microcks without first running `microcks login`
47+
```bash
48+
microcks import-dir ./api-spec \
49+
--microcksURL <microcks-url> \
50+
--keycloakClientId <client-id> \
51+
--keycloakClientSecret <client-secret>
52+
```
53+
54+
- Import specification to microcks running without authentication (ie. local uber instance typically)
55+
```bash
56+
microcks import-dir ./api-spec --microcksURL <microcks-url>
57+
```
58+
4559
📋 Supported File Types
4660

4761
The command automatically detects and imports the following file types:
@@ -53,7 +67,7 @@ The command automatically detects and imports the following file types:
5367

5468
The command automatically determines which files should be marked as primary artifacts:
5569
- Files containing "openapi" or "swagger" in the filename are marked as primary
56-
- Files containing "postman" or "collection" in the filename are marked as secondary
70+
- Files containing "postman", "collection", "metadata" or "examples" in the filename are marked as secondary
5771
- All other files default to primary
5872

5973
📊 Output

0 commit comments

Comments
 (0)