From 3152078aec8334357a61171838f664eb03299211 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 6 Feb 2024 16:26:59 +0100 Subject: Config: New state file Caches less. Also convert the V1 state file --- internal/config/v1/v1.go | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 internal/config/v1/v1.go (limited to 'internal/config/v1') diff --git a/internal/config/v1/v1.go b/internal/config/v1/v1.go new file mode 100644 index 0000000..1e374b1 --- /dev/null +++ b/internal/config/v1/v1.go @@ -0,0 +1,60 @@ +// Package v1 implements a minimum set of the v1 config to convert it to a v2 config +// In version 1 of the config we used the internal state as the config +// This was bad as now if we want to change some internal representation the config also changes +// This package can be removed when most people have migrated from v1 to v2 +package v1 + +import ( + "time" + + "github.com/eduvpn/eduvpn-common/internal/api/profiles" + "github.com/eduvpn/eduvpn-common/internal/discovery" + "github.com/eduvpn/eduvpn-common/types/server" +) + +type Profiles struct { + profiles.Info + Current string `json:"current_profile"` +} + +type Base struct { + BaseURL string `json:"base_url"` + Profiles Profiles `json:"profiles"` + StartTime time.Time `json:"start_time"` + StartTimeOAuth time.Time `json:"start_time_oauth"` + ExpireTime time.Time `json:"expire_time"` +} + +type InstituteServer struct { + Base Base `json:"base"` + Profiles Profiles `json:"profiles"` +} + +type InstituteServers struct { + Map map[string]InstituteServer `json:"map"` + CurrentURL string `json:"current_url"` +} + +type ( + CustomServer = InstituteServer + CustomServers = InstituteServers +) + +type SecureInternetHome struct { + BaseMap map[string]*Base `json:"base_map"` + DisplayName map[string]string `json:"display_name"` + HomeOrganizationID string `json:"home_organization_id"` + CurrentLocation string `json:"current_location"` +} + +type Servers struct { + Custom CustomServers `json:"custom_servers"` + Institute InstituteServers `json:"institute_servers"` + SecureInternetHome SecureInternetHome `json:"secure_internet_home"` + IsType server.Type `json:"is_secure_internet"` +} + +type V1 struct { + Discovery discovery.Discovery `json:"discovery"` + Servers Servers `json:"servers"` +} -- cgit v1.2.3