From 88027c23ae6283a197fd387dea3a1aaba13cfaf4 Mon Sep 17 00:00:00 2001 From: Mark Phelps Date: Sat, 19 Feb 2022 14:36:26 +0000 Subject: [PATCH 1/3] Fixes segment export/import MATCH_ANY type --- internal/ext/common.go | 1 + internal/ext/exporter.go | 1 + internal/ext/exporter_test.go | 1 + internal/ext/importer.go | 1 + internal/ext/importer_test.go | 2 +- internal/ext/testdata/export.yml | 1 + internal/ext/testdata/import.yml | 1 + internal/ext/testdata/import_no_attachment.yml | 1 + 8 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/ext/common.go b/internal/ext/common.go index 4ee9db3e2f..1585cd0968 100644 --- a/internal/ext/common.go +++ b/internal/ext/common.go @@ -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 { diff --git a/internal/ext/exporter.go b/internal/ext/exporter.go index 3361d79acd..d298f2206d 100644 --- a/internal/ext/exporter.go +++ b/internal/ext/exporter.go @@ -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 { diff --git a/internal/ext/exporter_test.go b/internal/ext/exporter_test.go index c681dfed01..01adb8974e 100644 --- a/internal/ext/exporter_test.go +++ b/internal/ext/exporter_test.go @@ -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", diff --git a/internal/ext/importer.go b/internal/ext/importer.go index 57f4bda22a..5fe4069933 100644 --- a/internal/ext/importer.go +++ b/internal/ext/importer.go @@ -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 { diff --git a/internal/ext/importer_test.go b/internal/ext/importer_test.go index c6598115ba..825d1073a1 100644 --- a/internal/ext/importer_test.go +++ b/internal/ext/importer_test.go @@ -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)) diff --git a/internal/ext/testdata/export.yml b/internal/ext/testdata/export.yml index 30dd1b76ad..bccb28a661 100644 --- a/internal/ext/testdata/export.yml +++ b/internal/ext/testdata/export.yml @@ -30,6 +30,7 @@ flags: segments: - key: segment1 name: segment1 + match_type: "ANY_MATCH_TYPE" description: description constraints: - type: STRING_COMPARISON_TYPE diff --git a/internal/ext/testdata/import.yml b/internal/ext/testdata/import.yml index 9b4c39246a..5d83302277 100644 --- a/internal/ext/testdata/import.yml +++ b/internal/ext/testdata/import.yml @@ -28,6 +28,7 @@ flags: segments: - key: segment1 name: segment1 + match_type: "ANY_MATCH_TYPE" description: description constraints: - type: STRING_COMPARISON_TYPE diff --git a/internal/ext/testdata/import_no_attachment.yml b/internal/ext/testdata/import_no_attachment.yml index 9264ffc6fb..b9a5e9086f 100644 --- a/internal/ext/testdata/import_no_attachment.yml +++ b/internal/ext/testdata/import_no_attachment.yml @@ -15,6 +15,7 @@ flags: segments: - key: segment1 name: segment1 + match_type: "ANY_MATCH_TYPE" description: description constraints: - type: STRING_COMPARISON_TYPE From fc30866216e65998185aa9b97ddbb179a1c357ca Mon Sep 17 00:00:00 2001 From: Mark Phelps Date: Sat, 19 Feb 2022 15:01:31 +0000 Subject: [PATCH 2/3] Fix version info; fix js build --- cmd/flipt/main.go | 25 +++++++++--------------- ui/build/utils.js | 3 +-- ui/src/components/Nav.vue | 8 +++++--- ui/src/components/UpdateNotification.vue | 2 +- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/cmd/flipt/main.go b/cmd/flipt/main.go index f89dd76a80..14d08b766c 100644 --- a/cmd/flipt/main.go +++ b/cmd/flipt/main.go @@ -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) { @@ -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) { diff --git a/ui/build/utils.js b/ui/build/utils.js index 29e463ab20..426fa592bf 100644 --- a/ui/build/utils.js +++ b/ui/build/utils.js @@ -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) { @@ -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"), diff --git a/ui/src/components/Nav.vue b/ui/src/components/Nav.vue index a0687a317e..fcb1317f07 100644 --- a/ui/src/components/Nav.vue +++ b/ui/src/components/Nav.vue @@ -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); diff --git a/ui/src/components/UpdateNotification.vue b/ui/src/components/UpdateNotification.vue index 00d20fd77e..28c6f51e2e 100644 --- a/ui/src/components/UpdateNotification.vue +++ b/ui/src/components/UpdateNotification.vue @@ -26,7 +26,7 @@ export default { ); }, show() { - return this.info.updateAvailable && !this.isHidden; + return this.info.isRelease && this.info.updateAvailable && !this.isHidden; }, }, methods: { From 33430d6af5f479b526378a125d784448aa83a9e7 Mon Sep 17 00:00:00 2001 From: Mark Phelps Date: Sat, 19 Feb 2022 10:17:40 -0500 Subject: [PATCH 3/3] Bump changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4097878db7..d33f8d79f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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