Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes segment export/import match_type #711

Merged
merged 3 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
This format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v1.6.2](https://github.com/markphelps/flipt/releases/tag/v1.6.2) - 2022-02-19

### Fixed

- Issue with missing Segment.MatchType in export [https://github.com/markphelps/flipt/issues/710](https://github.com/markphelps/flipt/issues/710)
- Issue with version not showing in UI (again)

## [v1.6.1](https://github.com/markphelps/flipt/releases/tag/v1.6.1) - 2022-02-13

### Fixed
Expand Down
25 changes: 9 additions & 16 deletions cmd/flipt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,21 +462,13 @@ func run(_ []string) error {
r.Mount("/debug", middleware.Profiler())

info := info{
Commit: commit,
BuildDate: date,
GoVersion: goVersion,
}

emptyVersion := semver.Version{}

if cv.Validate() != nil && cv.GE(emptyVersion) {
info.Version = cv.FinalizeVersion()
}
if lv.Validate() != nil && cv.GE(emptyVersion) {
info.LatestVersion = lv.FinalizeVersion()
}
if updateAvailable {
info.UpdateAvailable = true
Commit: commit,
BuildDate: date,
GoVersion: goVersion,
Version: cv.String(),
LatestVersion: lv.String(),
IsRelease: isRelease,
UpdateAvailable: updateAvailable,
}

r.Route("/meta", func(r chi.Router) {
Expand Down Expand Up @@ -590,10 +582,11 @@ func isRelease() bool {
type info struct {
Version string `json:"version,omitempty"`
LatestVersion string `json:"latestVersion,omitempty"`
UpdateAvailable bool `json:"updateAvailable,omitempty"`
Commit string `json:"commit,omitempty"`
BuildDate string `json:"buildDate,omitempty"`
GoVersion string `json:"goVersion,omitempty"`
UpdateAvailable bool `json:"updateAvailable"`
IsRelease bool `json:"isRelease"`
}

func (i info) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Expand Down
1 change: 1 addition & 0 deletions internal/ext/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Segment struct {
Name string `yaml:"name,omitempty"`
Description string `yaml:"description,omitempty"`
Constraints []*Constraint `yaml:"constraints,omitempty"`
MatchType string `yaml:"match_type,omitempty"`
}

type Constraint struct {
Expand Down
1 change: 1 addition & 0 deletions internal/ext/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func (e *Exporter) Export(ctx context.Context, w io.Writer) error {
Key: s.Key,
Name: s.Name,
Description: s.Description,
MatchType: s.MatchType.String(),
}

for _, c := range s.Constraints {
Expand Down
1 change: 1 addition & 0 deletions internal/ext/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestExport(t *testing.T) {
Key: "segment1",
Name: "segment1",
Description: "description",
MatchType: flipt.MatchType_ANY_MATCH_TYPE,
Constraints: []*flipt.Constraint{
{
Id: "1",
Expand Down
1 change: 1 addition & 0 deletions internal/ext/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (i *Importer) Import(ctx context.Context, r io.Reader) error {
Key: s.Key,
Name: s.Name,
Description: s.Description,
MatchType: flipt.MatchType(flipt.MatchType_value[s.MatchType]),
})

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/ext/importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestImport(t *testing.T) {
assert.Equal(t, "segment1", segment.Key)
assert.Equal(t, "segment1", segment.Name)
assert.Equal(t, "description", segment.Description)
assert.Equal(t, flipt.MatchType_ALL_MATCH_TYPE, segment.MatchType)
assert.Equal(t, flipt.MatchType_ANY_MATCH_TYPE, segment.MatchType)

assert.NotEmpty(t, creator.constraintReqs)
assert.Equal(t, 1, len(creator.constraintReqs))
Expand Down
1 change: 1 addition & 0 deletions internal/ext/testdata/export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ flags:
segments:
- key: segment1
name: segment1
match_type: "ANY_MATCH_TYPE"
description: description
constraints:
- type: STRING_COMPARISON_TYPE
Expand Down
1 change: 1 addition & 0 deletions internal/ext/testdata/import.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ flags:
segments:
- key: segment1
name: segment1
match_type: "ANY_MATCH_TYPE"
description: description
constraints:
- type: STRING_COMPARISON_TYPE
Expand Down
1 change: 1 addition & 0 deletions internal/ext/testdata/import_no_attachment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ flags:
segments:
- key: segment1
name: segment1
match_type: "ANY_MATCH_TYPE"
description: description
constraints:
- type: STRING_COMPARISON_TYPE
Expand Down
3 changes: 1 addition & 2 deletions ui/build/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use strict";
import path from "path";
import { dev, build } from "../config/index.js";
import packageConfig from "../package.json";
import notifier from "node-notifier";

export const assetsPath = function (_path) {
Expand Down Expand Up @@ -87,7 +86,7 @@ export const createNotifierCallback = () => {
const filename = error.file && error.file.split("!").pop();

notifier.notify({
title: packageConfig.name,
title: "flipt-ui",
message: severity + ": " + error.name,
subtitle: filename || "",
icon: path.join(__dirname, "logo.png"),
Expand Down
8 changes: 5 additions & 3 deletions ui/src/components/Nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,18 @@ export default {
computed: {
...mapGetters(["info"]),
refURL() {
if (this.info.version) {
if (this.info.isRelease && this.info.version) {
return (
"https://github.com/markphelps/flipt/releases/tag/" +
this.info.version
);
} else if (this.info.commit) {
return "https://github.com/markphelps/flipt/commit/" + this.info.commit;
}
return "https://github.com/markphelps/flipt/commit/" + this.info.commit;
return "https://github.com/markphelps/flipt";
},
ref() {
if (this.info.version) {
if (this.info.isRelease && this.info.version) {
return this.info.version;
} else if (this.info.commit) {
return this.info.commit.substring(0, 7);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/UpdateNotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
);
},
show() {
return this.info.updateAvailable && !this.isHidden;
return this.info.isRelease && this.info.updateAvailable && !this.isHidden;
},
},
methods: {
Expand Down