Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
bitmask-vpn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
anna petry
bitmask-vpn
Commits
e901381e
Commit
e901381e
authored
3 years ago
by
Kali Kaneko
Browse files
Options
Downloads
Patches
Plain Diff
add urgency
parent
82364eb7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
branding/motd-cli/README.md
+4
-1
4 additions, 1 deletion
branding/motd-cli/README.md
branding/motd-cli/main.go
+16
-2
16 additions, 2 deletions
branding/motd-cli/main.go
branding/motd-cli/motd-example.json
+1
-0
1 addition, 0 deletions
branding/motd-cli/motd-example.json
with
21 additions
and
3 deletions
branding/motd-cli/README.md
+
4
−
1
View file @
e901381e
...
...
@@ -19,6 +19,7 @@ The structure of the `motd.json` file is like follows:
"end": "Dec 31 2021 23:59:00",
"type": "daily",
"platform": "all",
"urgency": "normal",
"text": [
{ "lang": "en",
"str": "This is a <a href='https://leap.se'>test!</a>"},
...
...
@@ -33,7 +34,8 @@ Valid values are:
*
Begin, End are date strings, like "Jan 1 2021 00:00:00".
*
Type: "once" for a one-shot message, "daily" for a message that is displayed daily during the specified duration.
*
Platform: one of "windows", "linux", "osx" or "all".
*
Platform: one of "windows", "osx", "snap", "linux", or "all".
*
Urgency: either "normal" or "critical".
The text message can contain links.
...
...
@@ -48,6 +50,7 @@ Message 1 ✓
-----------
Type: daily ✓
Platform: all ✓
Urgency: normal ✓
Languages: 2 ✓
```
...
...
This diff is collapsed.
Click to expand it.
branding/motd-cli/main.go
+
16
−
2
View file @
e901381e
...
...
@@ -28,20 +28,24 @@ type Message struct {
End
string
`json:"end"`
Type
string
`json:"type"`
Platform
string
`json:"platform"`
Urgency
string
`json:"urgency"`
Text
[]
LocalizedText
`json:"text"`
}
func
(
m
*
Message
)
IsValid
()
bool
{
valid
:=
(
m
.
IsValidBegin
()
&&
m
.
IsValidEnd
()
&&
m
.
IsValidType
()
&&
m
.
IsValidPlatform
()
&&
m
.
HasLocalizedText
())
m
.
IsValidType
()
&&
m
.
IsValidPlatform
()
&&
m
.
IsValidUrgency
()
&&
m
.
HasLocalizedText
())
return
valid
}
func
(
m
*
Message
)
IsValidBegin
()
bool
{
// FIXME check that begin is before 1y for instance
return
true
}
func
(
m
*
Message
)
IsValidEnd
()
bool
{
// FIXME check end is within next year/months
return
true
}
...
...
@@ -63,8 +67,17 @@ func (m *Message) IsValidPlatform() bool {
}
}
func
(
m
*
Message
)
IsValidUrgency
()
bool
{
switch
m
.
Urgency
{
case
"normal"
,
"critical"
:
return
true
default
:
return
false
}
}
func
(
m
*
Message
)
HasLocalizedText
()
bool
{
return
true
return
len
(
m
.
Text
)
>
0
}
type
LocalizedText
struct
{
...
...
@@ -89,6 +102,7 @@ func main() {
fmt
.
Printf
(
"Message %d %v
\n
-----------
\n
"
,
i
+
1
,
mark
(
msg
.
IsValid
()))
fmt
.
Printf
(
"Type: %s %v
\n
"
,
msg
.
Type
,
mark
(
msg
.
IsValidType
()))
fmt
.
Printf
(
"Platform: %s %v
\n
"
,
msg
.
Platform
,
mark
(
msg
.
IsValidPlatform
()))
fmt
.
Printf
(
"Urgency: %s %v
\n
"
,
msg
.
Urgency
,
mark
(
msg
.
IsValidUrgency
()))
fmt
.
Printf
(
"Languages: %d %v
\n
"
,
len
(
msg
.
Text
),
mark
(
msg
.
HasLocalizedText
()))
if
!
msg
.
IsValid
()
{
os
.
Exit
(
1
)
...
...
This diff is collapsed.
Click to expand it.
branding/motd-cli/motd-example.json
+
1
−
0
View file @
e901381e
...
...
@@ -4,6 +4,7 @@
"end"
:
"Dec 31 2021 23:59:00"
,
"type"
:
"daily"
,
"platform"
:
"all"
,
"urgency"
:
"normal"
,
"text"
:
[
{
"lang"
:
"en"
,
"str"
:
"This is a <a href='https://leap.se'>test!</a>"
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment