Skip to content
Merged
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
17 changes: 10 additions & 7 deletions cmd/publisher/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,17 @@ func createServerJSON(
}

// Create repository with optional subfolder
repo := model.Repository{
URL: repoURL,
Source: repoSource,
}
var repo *model.Repository
if repoURL != "" && repoSource != "" {
repo = &model.Repository{
URL: repoURL,
Source: repoSource,
}

// Only set subfolder if we're actually in a subdirectory
if subfolder != "" {
repo.Subfolder = subfolder
// Only set subfolder if we're actually in a subdirectory
if subfolder != "" {
repo.Subfolder = subfolder
}
}

// Create server structure
Expand Down
2 changes: 1 addition & 1 deletion cmd/publisher/commands/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestPublishCommand_DeprecatedSchema(t *testing.T) {
Name: "com.example/test-server",
Description: "A test server",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test",
Source: "github",
},
Expand Down
12 changes: 6 additions & 6 deletions internal/api/handlers/v0/edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestEditServerEndpoint(t *testing.T) {
Name: "io.github.testuser/editable-server",
Description: "Server that can be edited",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/testuser/editable-server",
Source: "github",
ID: "testuser/editable-server",
Expand All @@ -57,7 +57,7 @@ func TestEditServerEndpoint(t *testing.T) {
Name: "io.github.otheruser/other-server",
Description: "Server owned by another user",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/otheruser/other-server",
Source: "github",
ID: "otheruser/other-server",
Expand All @@ -77,7 +77,7 @@ func TestEditServerEndpoint(t *testing.T) {
Name: "io.github.testuser/deleted-server",
Description: "Server that was deleted",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/testuser/deleted-server",
Source: "github",
ID: "testuser/deleted-server",
Expand All @@ -96,7 +96,7 @@ func TestEditServerEndpoint(t *testing.T) {
Name: "io.github.testuser/build-metadata-server",
Description: "Server with build metadata version",
Version: "1.0.0+20130313144700",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/testuser/build-metadata-server",
Source: "github",
ID: "testuser/build-metadata-server",
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestEditServerEndpoint(t *testing.T) {
Name: "io.github.testuser/editable-server",
Description: "Updated server description",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/testuser/editable-server",
Source: "github",
ID: "testuser/editable-server",
Expand Down Expand Up @@ -347,7 +347,7 @@ func TestEditServerEndpoint(t *testing.T) {
Name: "io.github.testuser/build-metadata-server",
Description: "Updated server with build metadata",
Version: "1.0.0+20130313144700",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/testuser/build-metadata-server",
Source: "github",
ID: "testuser/build-metadata-server",
Expand Down
6 changes: 3 additions & 3 deletions internal/api/handlers/v0/publish_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestPublishIntegration(t *testing.T) {
Schema: model.CurrentSchemaURL,
Name: "io.github.testuser/test-mcp-server",
Description: "A test MCP server for integration testing",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/testuser/test-mcp-server",
Source: "github",
ID: "testuser/test-mcp-server",
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestPublishIntegration(t *testing.T) {
Schema: model.CurrentSchemaURL,
Name: "com.example/test-mcp-server-no-auth",
Description: "A test MCP server without authentication",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestPublishIntegration(t *testing.T) {
Name: "io.github.other/test-server",
Description: "A test server",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
Expand Down
14 changes: 7 additions & 7 deletions internal/api/handlers/v0/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestPublishEndpoint(t *testing.T) {
Schema: model.CurrentSchemaURL,
Name: "io.github.example/test-server",
Description: "A test server",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
Expand All @@ -84,7 +84,7 @@ func TestPublishEndpoint(t *testing.T) {
Schema: model.CurrentSchemaURL,
Name: "example/test-server",
Description: "A test server without auth",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestPublishEndpoint(t *testing.T) {
Name: "io.github.other/test-server",
Description: "A test server",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
Expand All @@ -174,7 +174,7 @@ func TestPublishEndpoint(t *testing.T) {
Name: "example/test-server",
Description: "A test server",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
Expand All @@ -193,7 +193,7 @@ func TestPublishEndpoint(t *testing.T) {
Name: "example/test-server",
Description: "Existing test server",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server-existing",
Source: "github",
ID: "example/test-server-existing",
Expand Down Expand Up @@ -239,7 +239,7 @@ func TestPublishEndpoint(t *testing.T) {
Name: "com.example/server/path",
Description: "Server with multiple slashes in name",
Version: "1.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
Expand Down Expand Up @@ -334,7 +334,7 @@ func TestPublishEndpoint(t *testing.T) {
Name: "com.example/test/server/v2",
Description: "Complex server with invalid name",
Version: "2.0.0",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
Expand Down
2 changes: 1 addition & 1 deletion internal/api/handlers/v0/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestPrometheusHandler(t *testing.T) {
Schema: model.CurrentSchemaURL,
Name: "io.github.example/test-server",
Description: "Test server detail",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/example/test-server",
Source: "github",
ID: "example/test-server",
Expand Down
4 changes: 2 additions & 2 deletions internal/importer/importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestImportService_LocalFile(t *testing.T) {
Schema: model.CurrentSchemaURL,
Name: "io.github.test/test-server-1",
Description: "Test server 1",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/test/repo1",
Source: "github",
ID: "123",
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestImportService_HTTPFile(t *testing.T) {
Schema: model.CurrentSchemaURL,
Name: "io.github.test/http-test-server",
Description: "HTTP test server",
Repository: model.Repository{
Repository: &model.Repository{
URL: "https://github.com/test/http-repo",
Source: "github",
ID: "456",
Expand Down
6 changes: 3 additions & 3 deletions internal/validators/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func ValidateServerJSON(serverJSON *apiv0.ServerJSON) error {
}

// Validate repository
if err := validateRepository(&serverJSON.Repository); err != nil {
if err := validateRepository(serverJSON.Repository); err != nil {
return err
}

Expand Down Expand Up @@ -122,8 +122,8 @@ func ValidateServerJSON(serverJSON *apiv0.ServerJSON) error {
}

func validateRepository(obj *model.Repository) error {
// Skip validation for empty repository (optional field)
if obj.URL == "" && obj.Source == "" {
// Skip validation if repository is nil or empty (optional field)
if obj == nil || (obj.URL == "" && obj.Source == "") {
return nil
}

Expand Down
Loading