Merge pull request #1318 from prymitive/hide-hash

fix(api): hash is not used by the UI, don't expose it
This commit is contained in:
Łukasz Mierzwa
2020-01-06 22:44:23 +00:00
committed by GitHub
8 changed files with 1 additions and 47 deletions

View File

@@ -954,9 +954,6 @@ func testAlert(version string, t *testing.T, expectedAlert, gotAlert models.Aler
}
func testAlertGroup(version string, t *testing.T, testCase groupTest, group models.APIAlertGroup) {
if group.Hash == "" {
t.Errorf("Empty hash for group %v", group.Labels)
}
if testCase.id != group.ID {
t.Errorf("[%s] Alert group.ID mismatch, expected '%s' but got '%s' for group %v",
version, testCase.id, group.ID, group.Labels)

View File

@@ -41,7 +41,7 @@ type AlertGroup struct {
Labels map[string]string `json:"labels"`
Alerts AlertList `json:"alerts"`
ID string `json:"id"`
Hash string `json:"hash"`
Hash string `json:"-"`
AlertmanagerCount map[string]int `json:"alertmanagerCount"`
StateCount map[string]int `json:"stateCount"`
LatestStartsAt time.Time `json:"-"`

View File

@@ -198,7 +198,6 @@ func TestDedupSharedMaps(t *testing.T) {
}
],
"id": "",
"hash": "",
"alertmanagerCount": null,
"stateCount": null,
"shared": {

View File

@@ -61,10 +61,8 @@ const MockGroupList = (count, alertPerGroup) => {
let groups = [];
for (let i = 1; i <= count; i++) {
let id = `id${i}`;
let hash = `hash${i}`;
let group = MockGroup(`group${i}`, alertPerGroup);
group.id = id;
group.hash = hash;
groups.push(group);
}
alertStore.data.upstreams = {

View File

@@ -33,7 +33,6 @@ const APIGroup = PropTypes.exact({
labels: PropTypes.object.isRequired,
alerts: PropTypes.arrayOf(APIAlert),
id: PropTypes.string.isRequired,
hash: PropTypes.string.isRequired,
alertmanagerCount: PropTypes.objectOf(PropTypes.number).isRequired,
stateCount: PropTypes.exact({
active: PropTypes.number.isRequired,

View File

@@ -485,21 +485,6 @@ describe("AlertStore.fetch", () => {
expect(store.data.groups).toMatchObject({ foo: "foo", bar: "bar" });
});
it("is no-op for groups that didn't change", () => {
const store = new AlertStore(["label=value"]);
store.data.groups = { foo: { hash: "foo" }, bar: { hash: "bar" } };
const response = EmptyAPIResponse();
response.groups = { foo: { hash: "foo" }, bar: { hash: "bar" } };
store.parseAPIResponse(response);
expect(Object.keys(store.data.groups)).toHaveLength(2);
expect(store.data.groups).toMatchObject({
foo: { hash: "foo" },
bar: { hash: "bar" }
});
});
it("removes old groups from the store after fetch", () => {
const store = new AlertStore(["label=value"]);
store.data.groups = { foo: "foo", delete: "me", bar: "bar" };
@@ -512,25 +497,4 @@ describe("AlertStore.fetch", () => {
expect(Object.keys(store.data.groups)).toHaveLength(2);
expect(store.data.groups).toMatchObject({ foo: "foo", bar: "bar" });
});
it("updates groups with new hash after fetch", () => {
const store = new AlertStore(["label=value"]);
store.data.groups = [
{ id: "foo", hash: "foo" },
{ id: "bar", hash: "bar" }
];
const response = EmptyAPIResponse();
response.groups = [
{ id: "foo", hash: "newFoo" },
{ id: "bar", hash: "newBar" }
];
store.parseAPIResponse(response);
expect(store.data.groups).toHaveLength(2);
expect(store.data.groups).toMatchObject([
{ id: "foo", hash: "newFoo" },
{ id: "bar", hash: "newBar" }
]);
});
});

View File

@@ -35,7 +35,6 @@ const MockAlertGroup = (
labels: rootLabels,
alerts: alerts,
id: "099c5ca6d1c92f615b13056b935d0c8dee70f18c",
hash: "53a4bb3d7e916450b3bda550976f9578db5b2ad3",
alertmanagerCount: {
default: 1
},

View File

@@ -185,7 +185,6 @@ const MockGrid = alertStore => {
const unprocessed = Math.max(0, i - active - suppressed);
const id = `id${i}`;
const hash = `hash${i}`;
const group = MockGroup(`group${i}`, i, active, suppressed, unprocessed);
for (let j = 0; j < group.alerts.length; j++) {
@@ -207,7 +206,6 @@ const MockGrid = alertStore => {
}
group.id = id;
group.hash = hash;
group.stateCount.active = active;
group.stateCount.suppressed = suppressed;
group.stateCount.unprocessed = unprocessed;