Skip to content

Commit

Permalink
Refactor 'name' field to ID on style guide and manifest proto definit…
Browse files Browse the repository at this point in the history
…ion (#315)

* Refactor 'name' field to ID on style guide and manifest proto definition
  • Loading branch information
muhammadharis authored Sep 29, 2021
1 parent f979214 commit c8b9dcc
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 107 deletions.
12 changes: 6 additions & 6 deletions cmd/registry/cmd/resolve/testdata/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: "test-manifest"
id: "test-manifest"
generated_resources:
- pattern: apis/-/versions/-/specs/-/artifacts/complexity
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute complexity $resource.spec"
- pattern: apis/-/versions/-/specs/-/artifacts/complexity
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute complexity $resource.spec"
12 changes: 6 additions & 6 deletions cmd/registry/cmd/resolve/testdata/manifest_receipt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: "test-manifest"
id: "test-manifest"
generated_resources:
- pattern: apis/-/versions/-/specs/-/artifacts/test-receipt-artifact
receipt: true
dependencies:
- pattern: $resource.spec
action: "echo test-receipt-artifact"
- pattern: apis/-/versions/-/specs/-/artifacts/test-receipt-artifact
receipt: true
dependencies:
- pattern: $resource.spec
action: "echo test-receipt-artifact"
2 changes: 1 addition & 1 deletion cmd/registry/cmd/upload/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func manifestCommand(ctx context.Context) *cobra.Command {
}

artifact := &rpc.Artifact{
Name: "projects/" + projectID + "/locations/global/artifacts/" + manifest.Name,
Name: "projects/" + projectID + "/locations/global/artifacts/" + manifest.GetId(),
MimeType: core.MimeTypeForMessageType("google.cloud.apigee.registry.applications.v1alpha1.Manifest"),
Contents: manifestData,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/registry/cmd/upload/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestManifestUpload(t *testing.T) {
project: "upload-manifest-demo",
filePath: filepath.Join("testdata", "manifest.yaml"),
want: &rpc.Manifest{
Name: "test-manifest",
Id: "test-manifest",
GeneratedResources: []*rpc.GeneratedResource{
{
Pattern: "apis/-/versions/-/specs/-/artifacts/complexity",
Expand Down
2 changes: 1 addition & 1 deletion cmd/registry/cmd/upload/styleguide.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func styleGuideCommand(ctx context.Context) *cobra.Command {
Name: "projects/" +
projectID +
"/locations/global/artifacts/" +
styleGuide.GetName(),
styleGuide.GetId(),
MimeType: core.MimeTypeForMessageType(
"google.cloud.apigee.registry.applications.v1alpha1.styleguide",
),
Expand Down
6 changes: 3 additions & 3 deletions cmd/registry/cmd/upload/styleguide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ func TestStyleGuideUpload(t *testing.T) {
project: "upload-styleguide-demo",
filePath: filepath.Join("testdata", "styleguide.yaml"),
want: &rpc.StyleGuide{
Name: "test-styleguide",
Id: "test-styleguide",
MimeTypes: []string{
"application/x.openapi+gzip;version=2",
},
Guidelines: []*rpc.Guideline{
{
Name: "refproperties",
Id: "refproperties",
DisplayName: "Govern Ref Properties",
Description: "This guideline governs properties for ref fields on specs.",
Rules: []*rpc.Rule{
{
Name: "norefsiblings",
Id: "norefsiblings",
Description: "An object exposing a $ref property cannot be further extended with additional properties.",
Linter: "spectral",
LinterRulename: "no-$ref-siblings",
Expand Down
12 changes: 6 additions & 6 deletions cmd/registry/cmd/upload/testdata/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: "test-manifest"
id: "test-manifest"
generated_resources:
- pattern: apis/-/versions/-/specs/-/artifacts/complexity
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "compute complexity $resource.spec"
- pattern: apis/-/versions/-/specs/-/artifacts/complexity
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "compute complexity $resource.spec"
6 changes: 3 additions & 3 deletions cmd/registry/cmd/upload/testdata/styleguide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: test-styleguide
id: test-styleguide
mime_types:
- application/x.openapi+gzip;version=2
guidelines:
- name: refproperties
- id: refproperties
display_name: Govern Ref Properties
description: This guideline governs properties for ref fields on specs.
rules:
- name: norefsiblings
- id: norefsiblings
description: An object exposing a $ref property cannot be further extended with additional properties.
linter: spectral
linter_rulename: no-$ref-siblings
Expand Down
10 changes: 5 additions & 5 deletions cmd/registry/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func TestArtifacts(t *testing.T) {
test.setup(ctx, registryClient)

manifest := &rpc.Manifest{
Name: "controller-test",
Id: "controller-test",
GeneratedResources: []*rpc.GeneratedResource{
{
Pattern: "apis/-/versions/-/specs/-/artifacts/lint-gnostic",
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestAggregateArtifacts(t *testing.T) {

manifest := &rpc.Manifest{

Name: "controller-test",
Id: "controller-test",
GeneratedResources: []*rpc.GeneratedResource{
{
Pattern: "apis/-/artifacts/vocabulary",
Expand Down Expand Up @@ -454,7 +454,7 @@ func TestDerivedArtifacts(t *testing.T) {
test.setup(ctx, registryClient)

manifest := &rpc.Manifest{
Name: "controller-test",
Id: "controller-test",
GeneratedResources: []*rpc.GeneratedResource{
{
Pattern: "apis/-/versions/-/specs/-/artifacts/summary",
Expand Down Expand Up @@ -540,7 +540,7 @@ func TestReceiptArtifacts(t *testing.T) {
test.setup(ctx, registryClient)

manifest := &rpc.Manifest{
Name: "controller-test",
Id: "controller-test",
GeneratedResources: []*rpc.GeneratedResource{
{
Pattern: "apis/-/versions/-/specs/-/artifacts/custom-artifact",
Expand Down Expand Up @@ -642,7 +642,7 @@ func TestReceiptAggArtifacts(t *testing.T) {
test.setup(ctx, registryClient)

manifest := &rpc.Manifest{
Name: "controller-test",
Id: "controller-test",
GeneratedResources: []*rpc.GeneratedResource{
{
Pattern: "artifacts/search-index",
Expand Down
56 changes: 28 additions & 28 deletions cmd/registry/controller/testdata/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: "test-manifest"
id: "test-manifest"
generated_resources:
- pattern: apis/-/versions/-/specs/-/artifacts/lint-gnostic
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute lint $resource.spec --linter gnostic"
- pattern: apis/-/versions/-/specs/-/artifacts/lint-aip
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('protobuf')"
action: "registry compute lint $resource.spec --linter aip"
- pattern: apis/-/versions/-/specs/-/artifacts/lintstats-gnostic
dependencies:
- pattern: $resource.spec/artifacts/lint-gnostic
action: "registry compute lintstats $resource.spec/artifacts/lint-gnostic --linter gnostic"
- pattern: apis/-/artifacts/vocabulary
dependencies:
- pattern: $resource.api/versions/-/specs/-
action: "registry compute vocabulary $resource.api"
- pattern: apis/-/versions/-/artifacts/vocabulary
dependencies:
- pattern: $resource.version/-/specs/-
action: "registry compute vocabulary $resource.version"
- pattern: apis/-/versions/-/specs/-/artifacts/score
dependencies:
- pattern: $resource.spec/artifacts/lint-gnostic
- pattern: $resource.spec/artifacts/complexity
action: "registry compute score $resource.spec/artifacts/lint-gnostic $resource.spec/artifacts/complexity"
- pattern: apis/-/versions/-/specs/-/artifacts/lint-gnostic
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute lint $resource.spec --linter gnostic"
- pattern: apis/-/versions/-/specs/-/artifacts/lint-aip
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('protobuf')"
action: "registry compute lint $resource.spec --linter aip"
- pattern: apis/-/versions/-/specs/-/artifacts/lintstats-gnostic
dependencies:
- pattern: $resource.spec/artifacts/lint-gnostic
action: "registry compute lintstats $resource.spec/artifacts/lint-gnostic --linter gnostic"
- pattern: apis/-/artifacts/vocabulary
dependencies:
- pattern: $resource.api/versions/-/specs/-
action: "registry compute vocabulary $resource.api"
- pattern: apis/-/versions/-/artifacts/vocabulary
dependencies:
- pattern: $resource.version/-/specs/-
action: "registry compute vocabulary $resource.version"
- pattern: apis/-/versions/-/specs/-/artifacts/score
dependencies:
- pattern: $resource.spec/artifacts/lint-gnostic
- pattern: $resource.spec/artifacts/complexity
action: "registry compute score $resource.spec/artifacts/lint-gnostic $resource.spec/artifacts/complexity"
12 changes: 6 additions & 6 deletions cmd/registry/controller/testdata/manifest_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: "test-manifest"
id: "test-manifest"
generated_resources:
- pattern: apis/-/versions/-/specs/-/artifacts/complexity
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute complexity $resource.spec"
- pattern: apis/-/versions/-/specs/-/artifacts/complexity
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute complexity $resource.spec"
12 changes: 6 additions & 6 deletions cmd/registry/controller/testdata/manifest_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: "test-manifest"
id: "test-manifest"
generated_resources:
- pattern: apis/-/versions/-/specs/-/artifacts/lint-gnostic
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute lint $resource.spec --linter gnostic"
- pattern: apis/-/versions/-/specs/-/artifacts/lint-gnostic
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute lint $resource.spec --linter gnostic"
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ option go_package = "github.com/apigee/registry/rpc;rpc";
// in a registry and is used by the controller to keep these resources up-to-date.
message Manifest {
// Name of manifest entry
string name = 1 [
string id = 1 [
(google.api.field_behavior) = REQUIRED
];
// List of Generated resources.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ option go_package = "github.com/apigee/registry/rpc;rpc";
// StyleGuide defines a set of guidelines and linters that govern the
// static analysis of API Specs with specified mime types.
message StyleGuide {
// Resource name of the style guide.
string name = 1 [
// Identifier of the style guide.
string id = 1 [
(google.api.field_behavior) = REQUIRED
];

// Human-meaningful name of the style guide.
string display_name = 2 [
(google.api.field_behavior) = REQUIRED
];

Expand All @@ -39,26 +44,26 @@ message StyleGuide {
// with possible suffixes representing compression types. These hypothetical
// names are defined in the vendor tree defined in RFC6838
// (https://tools.ietf.org/html/rfc6838) and are not final.
repeated string mime_types = 2 [
repeated string mime_types = 3 [
(google.api.field_behavior) = REQUIRED
];

// A list of guidelines that are specified by this style guide.
repeated Guideline guidelines = 3;
repeated Guideline guidelines = 4;

// A list of linters that this style guide uses.
repeated Linter linters = 4;
repeated Linter linters = 5;
}

// Guideline defines a set of rules that achieve a common design
// goal for API specs.
message Guideline {
// Resource name of the guideline.
string name = 1 [
// Identifier of the guideline.
string id = 1 [
(google.api.field_behavior) = REQUIRED
];

// Human-meaningful name.
// Human-meaningful name of the guideline.
string display_name = 2 [
(google.api.field_behavior) = REQUIRED
];
Expand Down Expand Up @@ -95,12 +100,12 @@ message Guideline {
// Rule is a specific design rule that can be applied to an API spec,
// and is enforced by a specified linter.
message Rule {
// Resource name of the rule.
string name = 1 [
// Identifier of the rule.
string id = 1 [
(google.api.field_behavior) = REQUIRED
];

// Human-meaningful name.
// Human-meaningful name of the rule.
string display_name = 2;

// A detailed description of the rule.
Expand Down
46 changes: 23 additions & 23 deletions tests/controller/testdata/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: "test-manifest"
id: "test-manifest"
generated_resources:
- pattern: apis/-/versions/-/specs/-/artifacts/lint-gnostic
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute lint $resource.spec --linter gnostic"
- pattern: apis/-/versions/-/specs/-/artifacts/lint-aip
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('protobuf')"
action: "registry compute lint $resource.spec --linter aip"
- pattern: apis/-/versions/-/specs/-/artifacts/lintstats-gnostic
dependencies:
- pattern: $resource.spec/artifacts/lint-gnostic
action: "registry compute lintstats $resource.spec --linter gnostic"
- pattern: apis/-/versions/-/specs/-/artifacts/vocabulary
dependencies:
- pattern: $resource.spec
action: "registry compute vocabulary $resource.spec"
- pattern: apis/-/versions/-/specs/-/artifacts/complexity
dependencies:
- pattern: $resource.spec
action: "registry compute complexity $resource.spec"
- pattern: apis/-/versions/-/specs/-/artifacts/lint-gnostic
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('openapi')"
action: "registry compute lint $resource.spec --linter gnostic"
- pattern: apis/-/versions/-/specs/-/artifacts/lint-aip
dependencies:
- pattern: $resource.spec
filter: "mime_type.contains('protobuf')"
action: "registry compute lint $resource.spec --linter aip"
- pattern: apis/-/versions/-/specs/-/artifacts/lintstats-gnostic
dependencies:
- pattern: $resource.spec/artifacts/lint-gnostic
action: "registry compute lintstats $resource.spec --linter gnostic"
- pattern: apis/-/versions/-/specs/-/artifacts/vocabulary
dependencies:
- pattern: $resource.spec
action: "registry compute vocabulary $resource.spec"
- pattern: apis/-/versions/-/specs/-/artifacts/complexity
dependencies:
- pattern: $resource.spec
action: "registry compute complexity $resource.spec"

0 comments on commit c8b9dcc

Please sign in to comment.