Skip to content

Commit

Permalink
refactor: rename constants package to osvschema
Browse files Browse the repository at this point in the history
Signed-off-by: Gareth Jones <[email protected]>
  • Loading branch information
G-Rath committed Oct 23, 2024
1 parent 5f4cffa commit 663e736
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
10 changes: 5 additions & 5 deletions bindings/go/ecosystem/ecosystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import (
"encoding/json"
"strings"

"github.com/ossf/osv-schema/bindings/go/constants"
"github.com/ossf/osv-schema/bindings/go/osvschema"
)

// Parsed represents an ecosystem-with-suffix string as defined by the [spec], parsed into
// a structured format.
//
// The suffix is optional and is separated from the ecosystem by a colon.
//
// For example, "Debian:7" would be parsed into Parsed{Ecosystem: constants.EcosystemDebian, Suffix: "7"}
// For example, "Debian:7" would be parsed into Parsed{Ecosystem: osvschema.EcosystemDebian, Suffix: "7"}
//
// [spec]: https://ossf.github.io/osv-schema/
type Parsed struct {
Ecosystem constants.Ecosystem
Ecosystem osvschema.Ecosystem
Suffix string
}

Expand Down Expand Up @@ -58,9 +58,9 @@ func (p *Parsed) String() string {
return str
}

// Parse parses a string into a constants.Ecosystem and an optional suffix specified with a ":"
// Parse parses a string into an osvschema.Ecosystem and an optional suffix specified with a ":"
func Parse(str string) Parsed {
ecosystem, suffix, _ := strings.Cut(str, ":")

return Parsed{constants.Ecosystem(ecosystem), suffix}
return Parsed{osvschema.Ecosystem(ecosystem), suffix}
}
42 changes: 21 additions & 21 deletions bindings/go/ecosystem/ecosystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"reflect"
"testing"

"github.com/ossf/osv-schema/bindings/go/constants"
"github.com/ossf/osv-schema/bindings/go/ecosystem"
"github.com/ossf/osv-schema/bindings/go/osvschema"
)

type testCase struct {
Expand All @@ -21,140 +21,140 @@ func buildCases(t *testing.T) []testCase {
{
string: "crates.io",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemCratesIO,
Ecosystem: osvschema.EcosystemCratesIO,
Suffix: "",
},
},
{
string: "crates.io: ",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemCratesIO,
Ecosystem: osvschema.EcosystemCratesIO,
Suffix: " ",
},
},
{
string: "crates.io::",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemCratesIO,
Ecosystem: osvschema.EcosystemCratesIO,
Suffix: ":",
},
},
{
string: "npm",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemNPM,
Ecosystem: osvschema.EcosystemNPM,
Suffix: "",
},
},
{
string: "npm:abc",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemNPM,
Ecosystem: osvschema.EcosystemNPM,
Suffix: "abc",
},
},
{
string: "Alpine",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemAlpine,
Ecosystem: osvschema.EcosystemAlpine,
Suffix: "",
},
},
{
string: "Alpine:v",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemAlpine,
Ecosystem: osvschema.EcosystemAlpine,
Suffix: "v",
},
},
{
string: "Alpine:v3.16",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemAlpine,
Ecosystem: osvschema.EcosystemAlpine,
Suffix: "v3.16",
},
},
{
string: "Alpine:3.16",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemAlpine,
Ecosystem: osvschema.EcosystemAlpine,
Suffix: "3.16",
},
},
{
string: "Maven",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemMaven,
Ecosystem: osvschema.EcosystemMaven,
Suffix: "",
},
},
{
string: "Maven:https://maven.google.com",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemMaven,
Ecosystem: osvschema.EcosystemMaven,
Suffix: "https://maven.google.com",
},
},
{
string: "Photon OS",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemPhotonOS,
Ecosystem: osvschema.EcosystemPhotonOS,
Suffix: "",
},
},
{
string: "Photon OS:abc",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemPhotonOS,
Ecosystem: osvschema.EcosystemPhotonOS,
Suffix: "abc",
},
},
{
string: "Photon OS:3.0",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemPhotonOS,
Ecosystem: osvschema.EcosystemPhotonOS,
Suffix: "3.0",
},
},
{
string: "Red Hat",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemRedHat,
Ecosystem: osvschema.EcosystemRedHat,
Suffix: "",
},
},
{
string: "Red Hat:abc",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemRedHat,
Ecosystem: osvschema.EcosystemRedHat,
Suffix: "abc",
},
},
{
string: "Red Hat:rhel_aus:8.4::appstream",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemRedHat,
Ecosystem: osvschema.EcosystemRedHat,
Suffix: "rhel_aus:8.4::appstream",
},
},
{
string: "Ubuntu",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemUbuntu,
Ecosystem: osvschema.EcosystemUbuntu,
Suffix: "",
},
},
{
string: "Ubuntu:Pro",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemUbuntu,
Ecosystem: osvschema.EcosystemUbuntu,
Suffix: "Pro",
},
},
{
string: "Ubuntu:Pro:18.04:LTS",
parsed: ecosystem.Parsed{
Ecosystem: constants.EcosystemUbuntu,
Ecosystem: osvschema.EcosystemUbuntu,
Suffix: "Pro:18.04:LTS",
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package constants
package osvschema

type Ecosystem string

Expand Down

0 comments on commit 663e736

Please sign in to comment.