Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Changing read logic for rulesets. #81

Merged
merged 8 commits into from
Sep 18, 2017
Merged

Changing read logic for rulesets. #81

merged 8 commits into from
Sep 18, 2017

Conversation

dgromov
Copy link
Contributor

@dgromov dgromov commented Sep 12, 2017

Instead of relying on unmarshalling json, will now use Mapping and
Rollup Views. These views represent a state of ruleset ready to be
looked at by a human on a screen.

Instead of relying on unmarshalling json, will now use Mapping and
Rollup Views. These views represent a state of ruleset ready to be
looked at by a human on a screen.
@dgromov dgromov changed the title Chaning read logic for rulesets. Changing read logic for rulesets. Sep 12, 2017
@@ -160,6 +131,40 @@ func (mrs *mappingRuleSnapshot) Schema() (*schema.MappingRuleSnapshot, error) {
return res, nil
}

// MappingRuleView is a human friendly representation of a mapping rule at a given point in time.
type MappingRuleView struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you wrapping the struct access w/ methods to ensure the fields are immutable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I kind of rather just make all the fields exposed. They can't be used for anything.

@coveralls
Copy link

coveralls commented Sep 12, 2017

Coverage Status

Coverage decreased (-1.5%) to 87.396% when pulling c3eced2 on dgromov/ruleset_view into b2891d3 on master.

@coveralls
Copy link

coveralls commented Sep 14, 2017

Coverage Status

Coverage decreased (-1.3%) to 87.604% when pulling fa13c45 on dgromov/ruleset_view into b2891d3 on master.

@coveralls
Copy link

coveralls commented Sep 14, 2017

Coverage Status

Coverage decreased (-1.4%) to 87.564% when pulling fa13c45 on dgromov/ruleset_view into b2891d3 on master.

func newRollupTargetView(target RollupTarget) RollupTargetView {
return RollupTargetView{
Name: string(target.Name),
Tags: stringArrayFromBytesArray(target.Tags),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: technically it's a slice not an array

Copy link
Contributor Author

@dgromov dgromov Sep 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That naming convention was established before I started touching this code base. I can change it but would like to do that in a separate pr if possible.

rules/rollup.go Outdated
return RollupTarget{
Name: []byte(rtv.Name),
Tags: bytesArrayFromStringArray(rtv.Tags),
Policies: rtv.Policies}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: newline before }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool

rules/ruleset.go Outdated
return rollupRules
}

//UpdateMetadata contains descriptive information that needs to be updated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space after //

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also move this outside of the sections where you define all the ruleSet methods? maybe closer to its constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

rules/ruleset.go Outdated
}
rs.updateMetadata(meta)
return nil
}

func (rs *ruleSet) DeleteMappingRule(d DeleteData) error {
m, err := rs.getMappingRuleByID(d.ID)
func (rs *ruleSet) DeleteMappingRule(ID string, meta UpdateMetadata) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ID/id ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

Copy link
Contributor

@cw9 cw9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a nit

rules/ruleset.go Outdated
@@ -598,7 +612,7 @@ func (rs *ruleSet) ToMutableRuleSet() MutableRuleSet {
return rs
}

// Schema returns the protobuf representation fo a ruleset
// Schema returns the protobuf representation fo a ruleset.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/fo/of?

@coveralls
Copy link

coveralls commented Sep 18, 2017

Coverage Status

Coverage decreased (-0.2%) to 88.726% when pulling 1e8b7f8 on dgromov/ruleset_view into b2891d3 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 88.726% when pulling 1e8b7f8 on dgromov/ruleset_view into b2891d3 on master.

1 similar comment
@coveralls
Copy link

coveralls commented Sep 18, 2017

Coverage Status

Coverage decreased (-0.2%) to 88.726% when pulling 1e8b7f8 on dgromov/ruleset_view into b2891d3 on master.

@dgromov dgromov merged commit d903d15 into master Sep 18, 2017
@dgromov dgromov deleted the dgromov/ruleset_view branch September 18, 2017 19:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants