diff --git a/.cspell/custom-dictionary.txt b/.cspell/custom-dictionary.txt new file mode 100644 index 0000000..d5847bd --- /dev/null +++ b/.cspell/custom-dictionary.txt @@ -0,0 +1,20 @@ +datolabs +stretchr +gock +davecgh +pmezard +parth +difflib +gopkg +exampleentities +examplelocations +gomod +dryrun +dylib +testdata +Exampler +tiernan +covermode +coverprofile +roadiehq +testdata diff --git a/.gitattributes b/.gitattributes index 840baeb..d29d0b0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ * text=auto eol=lf -go.sum linguist-generated=true -backstage/testdata/ linguist-generated=true +go.sum linguist-generated=true +testdata/* linguist-generated=true +.cspell/custom-dictionary.txt linguist-generated=true diff --git a/CODEOWNERS b/CODEOWNERS index a3d1cfd..9a38400 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @tdabasinskas +* @datolabs-io/go-backstage-maintainers diff --git a/README.md b/README.md index bdf340e..95ceed1 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # go-backstage -[![CI](https://github.com/tdabasinskas/go-backstage/actions/workflows/ci.yml/badge.svg)](https://github.com/tdabasinskas/go-backstage/actions/workflows/ci.yml) -[![codecov](https://codecov.io/gh/tdabasinskas/go-backstage/branch/main/graph/badge.svg?token=4CVNSX7UOZ)](https://codecov.io/gh/tdabasinskas/go-backstage) -[![Go Reference](https://pkg.go.dev/badge/github.com/tdabasinskas/go-backstage/backstage.svg)](https://pkg.go.dev/github.com/tdabasinskas/go-backstage/backstage) +[![CI](https://github.com/datolabs-io/go-backstage/actions/workflows/ci.yml/badge.svg)](https://github.com/datolabs-io/go-backstage/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/datolabs-io/go-backstage/branch/main/graph/badge.svg?token=4CVNSX7UOZ)](https://codecov.io/gh/datolabs-io/go-backstage) +[![Go Reference](https://pkg.go.dev/badge/github.com/datolabs-io/go-backstage/backstage.svg)](https://pkg.go.dev/github.com/datolabs-io/go-backstage/backstage) **go-backstage** is a Go client library for accessing the [Backstage REST API](https://backstage.io/docs/features/software-catalog/software-catalog-api). @@ -15,13 +15,13 @@ the low-level details of making HTTP requests and parsing responses, allowing de With Go installed, run the following to add the package to your project, along with its dependencies: ```bash -go get github.com/tdabasinskas/go-backstage/v2 +go get github.com/datolabs-io/go-backstage/v3 ``` Alternatively, you can add import the package as following and run `go get` to install it: ```go -import "github.com/tdabasinskas/go-backstage/v2" +import "github.com/datolabs-io/go-backstage/v3" ``` ## Usage @@ -29,7 +29,7 @@ import "github.com/tdabasinskas/go-backstage/v2" Add the package to your project as following: ```go -import "github.com/tdabasinskas/go-backstage/v2" +import "github.com/datolabs-io/go-backstage/v3" ``` Once imported, create a new Backstage API client to access different parts of Backstage API: @@ -37,6 +37,7 @@ Once imported, create a new Backstage API client to access different parts of Ba ```go client, err := backstage.NewClient(baseURL, "default", nil) ``` + If you want to use a custom HTTP client (for example, to handle authentication, retries or different timeouts), you can pass it as the third argument: diff --git a/backstage/backstage.go b/backstage.go similarity index 100% rename from backstage/backstage.go rename to backstage.go diff --git a/backstage/backstage_test.go b/backstage_test.go similarity index 100% rename from backstage/backstage_test.go rename to backstage_test.go diff --git a/backstage/catalog.go b/catalog.go similarity index 100% rename from backstage/catalog.go rename to catalog.go diff --git a/backstage/catalog_test.go b/catalog_test.go similarity index 100% rename from backstage/catalog_test.go rename to catalog_test.go diff --git a/cspell.json b/cspell.json new file mode 100644 index 0000000..c93be37 --- /dev/null +++ b/cspell.json @@ -0,0 +1,17 @@ +{ + "version": "0.2", + "ignorePaths": [], + "dictionaryDefinitions": [ + { + "name": "custom-dictionary", + "path": "./.cspell/custom-dictionary.txt", + "addWords": true + } + ], + "dictionaries": [ + "custom-dictionary" + ], + "words": [], + "ignoreWords": [], + "import": [] +} diff --git a/backstage/doc.go b/doc.go similarity index 60% rename from backstage/doc.go rename to doc.go index d01421f..38bd259 100644 --- a/backstage/doc.go +++ b/doc.go @@ -5,25 +5,35 @@ Package backstage provides a client for the Backstage API. Add the package to your project as following: - import "github.com/tdabasinskas/go-backstage" +```go +import "github.com/datolabs-io/go-backstage/v3" +``` Once imported, create a new Backstage API client to access different parts of Backstage API: - client, err := backstage.NewClient(baseURL, "default", nil) +```go +client, err := backstage.NewClient(baseURL, "default", nil) +``` If you want to use a custom HTTP client (for example, to handle authentication, retries or different timeouts), you can pass it as the third argument: - httpClient := &http.Client{} - client, err := backstage.NewClient(baseURL, "default", httpClient) +```go +httpClient := &http.Client{} +client, err := backstage.NewClient(baseURL, "default", httpClient) +``` The client than can be used to access different parts of the API, e.g. get the list of entities, sorted in specific order: +```go + entities, response, err := c.Catalog.Entities.s.List(context.Background(), &ListEntityOptions{ - Filters: ListEntityFilter{}, - Fields: []string{}, - Order: []ListEntityOrder{{ Direction: OrderDescending, Field: "metadata.name" }, - }, + Filters: []string{}, + Fields: []string{}, + Order: []ListEntityOrder{{ Direction: OrderDescending, Field: "metadata.name" }, + }, }) + +``` */ package backstage diff --git a/backstage/entity.go b/entity.go similarity index 100% rename from backstage/entity.go rename to entity.go diff --git a/backstage/entity_test.go b/entity_test.go similarity index 100% rename from backstage/entity_test.go rename to entity_test.go diff --git a/examples/entities/go.mod b/examples/entities/go.mod index 4f7fb43..101ac07 100644 --- a/examples/entities/go.mod +++ b/examples/entities/go.mod @@ -1,7 +1,7 @@ module exampleentities -go 1.22 +go 1.23 -replace github.com/tdabasinskas/go-backstage/v2 => ../.. +replace github.com/datolabs-io/go-backstage/v3 => ../.. -require github.com/tdabasinskas/go-backstage/v2 v2.0.0-preview.2 +require github.com/datolabs-io/go-backstage/v3 v3.0.0-00010101000000-000000000000 diff --git a/examples/entities/go.sum b/examples/entities/go.sum index cb54f3d..36c46fd 100644 --- a/examples/entities/go.sum +++ b/examples/entities/go.sum @@ -6,7 +6,7 @@ github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslC github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/examples/entities/main.go b/examples/entities/main.go index a216926..3ed370d 100644 --- a/examples/entities/main.go +++ b/examples/entities/main.go @@ -2,9 +2,10 @@ package main import ( "context" - "github.com/tdabasinskas/go-backstage/v2/backstage" "log" "os" + + "github.com/datolabs-io/go-backstage/v3" ) func main() { diff --git a/examples/locations/go.mod b/examples/locations/go.mod index 32f341c..1659012 100644 --- a/examples/locations/go.mod +++ b/examples/locations/go.mod @@ -1,7 +1,7 @@ module examplelocations -go 1.22 +go 1.23 -replace github.com/tdabasinskas/go-backstage/v2 => ../.. +replace github.com/datolabs-io/go-backstage/v3 => ../.. -require github.com/tdabasinskas/go-backstage/v2 v2.0.0-preview.2 +require github.com/datolabs-io/go-backstage/v3 v3.0.0-00010101000000-000000000000 diff --git a/examples/locations/main.go b/examples/locations/main.go index 7bc421f..eb147fb 100644 --- a/examples/locations/main.go +++ b/examples/locations/main.go @@ -6,11 +6,11 @@ import ( "net/http" "os" - "github.com/tdabasinskas/go-backstage/v2/backstage" + "github.com/datolabs-io/go-backstage/v3" ) func main() { - const locationTarget = "https://github.com/tdabasinskas/go-backstage/tree/main/backstage/testdata" + const locationTarget = "https://github.com/datolabs-io/go-backstage/tree/main/backstage/testdata" baseURL, ok := os.LookupEnv("BACKSTAGE_BASE_URL") if !ok { diff --git a/go.mod b/go.mod index 42ae7be..75f311a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/tdabasinskas/go-backstage/v2 +module github.com/datolabs-io/go-backstage/v3 go 1.23 diff --git a/backstage/kind_api.go b/kind_api.go similarity index 100% rename from backstage/kind_api.go rename to kind_api.go diff --git a/backstage/kind_api_test.go b/kind_api_test.go similarity index 100% rename from backstage/kind_api_test.go rename to kind_api_test.go diff --git a/backstage/kind_component.go b/kind_component.go similarity index 97% rename from backstage/kind_component.go rename to kind_component.go index f30b407..759c862 100644 --- a/backstage/kind_component.go +++ b/kind_component.go @@ -42,7 +42,7 @@ type ComponentEntityV1alpha1Spec struct { ProvidesApis []string `json:"providesApis,omitempty" yaml:"providesApis,omitempty"` // ConsumesApis is an array of entity references to the APIs that are consumed by the component. - ConsumesApis []string `json:"consumesApis,omitempty" yaml:"onsumesApis,omitempty"` + ConsumesApis []string `json:"consumesApis,omitempty" yaml:"consumesApis,omitempty"` // DependsOn is an array of entity references to the components and resources that the component depends on. DependsOn []string `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty"` diff --git a/backstage/kind_component_test.go b/kind_component_test.go similarity index 100% rename from backstage/kind_component_test.go rename to kind_component_test.go diff --git a/backstage/kind_domain.go b/kind_domain.go similarity index 100% rename from backstage/kind_domain.go rename to kind_domain.go diff --git a/backstage/kind_domain_test.go b/kind_domain_test.go similarity index 100% rename from backstage/kind_domain_test.go rename to kind_domain_test.go diff --git a/backstage/kind_group.go b/kind_group.go similarity index 100% rename from backstage/kind_group.go rename to kind_group.go diff --git a/backstage/kind_group_test.go b/kind_group_test.go similarity index 100% rename from backstage/kind_group_test.go rename to kind_group_test.go diff --git a/backstage/kind_location.go b/kind_location.go similarity index 100% rename from backstage/kind_location.go rename to kind_location.go diff --git a/backstage/kind_location_test.go b/kind_location_test.go similarity index 98% rename from backstage/kind_location_test.go rename to kind_location_test.go index 80a6afc..8565389 100644 --- a/backstage/kind_location_test.go +++ b/kind_location_test.go @@ -48,7 +48,7 @@ func TestKindLocationGet(t *testing.T) { // TestKindLocationCreateByID tests functionality of creating a new location. func TestKindLocationCreateByID(t *testing.T) { const dataFile = "testdata/location_create.json" - const target = "https://github.com/tdabasinskas/go/backstage/test" + const target = "https://github.com/datolabs-io/go-backstage/test" expected := LocationCreateResponse{} expectedData, _ := os.ReadFile(dataFile) @@ -88,7 +88,7 @@ func TestKindLocationCreateByID(t *testing.T) { // TestKindLocationCreateByID_DryRun tests functionality of creating a new location. func TestKindLocationCreateByID_DryRun(t *testing.T) { const dataFile = "testdata/location_create_dryrun.json" - const target = "https://github.com/tdabasinskas/go/backstage/test" + const target = "https://github.com/datolabs-io/go-backstage/test" expected := LocationCreateResponse{} expectedData, _ := os.ReadFile(dataFile) diff --git a/backstage/kind_resource.go b/kind_resource.go similarity index 100% rename from backstage/kind_resource.go rename to kind_resource.go diff --git a/backstage/kind_resource_test.go b/kind_resource_test.go similarity index 100% rename from backstage/kind_resource_test.go rename to kind_resource_test.go diff --git a/backstage/kind_system.go b/kind_system.go similarity index 100% rename from backstage/kind_system.go rename to kind_system.go diff --git a/backstage/kind_system_test.go b/kind_system_test.go similarity index 100% rename from backstage/kind_system_test.go rename to kind_system_test.go diff --git a/backstage/kind_user.go b/kind_user.go similarity index 100% rename from backstage/kind_user.go rename to kind_user.go diff --git a/backstage/kind_user_test.go b/kind_user_test.go similarity index 100% rename from backstage/kind_user_test.go rename to kind_user_test.go diff --git a/backstage/testdata/api.json b/testdata/api.json similarity index 100% rename from backstage/testdata/api.json rename to testdata/api.json diff --git a/backstage/testdata/catalog-info.yaml b/testdata/catalog-info.yaml similarity index 100% rename from backstage/testdata/catalog-info.yaml rename to testdata/catalog-info.yaml diff --git a/backstage/testdata/component.json b/testdata/component.json similarity index 100% rename from backstage/testdata/component.json rename to testdata/component.json diff --git a/backstage/testdata/domain.json b/testdata/domain.json similarity index 100% rename from backstage/testdata/domain.json rename to testdata/domain.json diff --git a/backstage/testdata/entities.json b/testdata/entities.json similarity index 100% rename from backstage/testdata/entities.json rename to testdata/entities.json diff --git a/backstage/testdata/entities_fields.json b/testdata/entities_fields.json similarity index 100% rename from backstage/testdata/entities_fields.json rename to testdata/entities_fields.json diff --git a/backstage/testdata/entities_filter.json b/testdata/entities_filter.json similarity index 100% rename from backstage/testdata/entities_filter.json rename to testdata/entities_filter.json diff --git a/backstage/testdata/entities_order.json b/testdata/entities_order.json similarity index 100% rename from backstage/testdata/entities_order.json rename to testdata/entities_order.json diff --git a/backstage/testdata/entities_single.json b/testdata/entities_single.json similarity index 100% rename from backstage/testdata/entities_single.json rename to testdata/entities_single.json diff --git a/backstage/testdata/group.json b/testdata/group.json similarity index 100% rename from backstage/testdata/group.json rename to testdata/group.json diff --git a/backstage/testdata/location.json b/testdata/location.json similarity index 100% rename from backstage/testdata/location.json rename to testdata/location.json diff --git a/backstage/testdata/location_by_id.json b/testdata/location_by_id.json similarity index 51% rename from backstage/testdata/location_by_id.json rename to testdata/location_by_id.json index 23312e8..6ddfb4d 100644 --- a/backstage/testdata/location_by_id.json +++ b/testdata/location_by_id.json @@ -1,5 +1,5 @@ { "id": "830d2354-8bbb-42d1-a751-2959f6da5416", "type": "url", - "target": "https://github.com/tdabasinskas/go/backstage/test" + "target": "https://github.com/datolabs-io/go-backstage/test" } diff --git a/backstage/testdata/location_create.json b/testdata/location_create.json similarity index 62% rename from backstage/testdata/location_create.json rename to testdata/location_create.json index 2196798..4da3beb 100644 --- a/backstage/testdata/location_create.json +++ b/testdata/location_create.json @@ -2,7 +2,7 @@ "location": { "id": "830d2354-8bbb-42d1-a751-2959f6da5416", "type": "url", - "target": "https://github.com/tdabasinskas/go/backstage/test" + "target": "https://github.com/datolabs-io/go-backstage/test" }, "entities": [] } diff --git a/backstage/testdata/location_create_dryrun.json b/testdata/location_create_dryrun.json similarity index 66% rename from backstage/testdata/location_create_dryrun.json rename to testdata/location_create_dryrun.json index 947f4f1..3cb0ea7 100644 --- a/backstage/testdata/location_create_dryrun.json +++ b/testdata/location_create_dryrun.json @@ -3,7 +3,7 @@ "location": { "id": "830d2354-8bbb-42d1-a751-2959f6da5416", "type": "url", - "target": "https://github.com/tdabasinskas/go/backstage/test" + "target": "https://github.com/datolabs-io/go-backstage/test" }, "entities": [] } diff --git a/backstage/testdata/locations.json b/testdata/locations.json similarity index 59% rename from backstage/testdata/locations.json rename to testdata/locations.json index 3f6bb19..e9a648c 100644 --- a/backstage/testdata/locations.json +++ b/testdata/locations.json @@ -2,14 +2,14 @@ { "data": { "id": "650a7ec5-9813-4f42-ae8a-cde84653daf4", - "target": "https://github.com/tdabasinskas/test", + "target": "https://github.com/datolabs-io/go-backstage/test", "type": "url" } }, { "data": { "id": "ab31518c-91a4-49b8-a65a-3a12c7f92055", - "target": "https://github.com/tdabasinskas/example", + "target": "https://github.com/datolabs-io/go-backstage/example", "type": "url" } } diff --git a/backstage/testdata/resource.json b/testdata/resource.json similarity index 100% rename from backstage/testdata/resource.json rename to testdata/resource.json diff --git a/backstage/testdata/system.json b/testdata/system.json similarity index 100% rename from backstage/testdata/system.json rename to testdata/system.json diff --git a/backstage/testdata/user.json b/testdata/user.json similarity index 100% rename from backstage/testdata/user.json rename to testdata/user.json