Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
GitlabRSSSync
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
open-source
GitlabRSSSync
Commits
be32f4a3
Commit
be32f4a3
authored
6 years ago
by
Adam Harrison-Fuller
Browse files
Options
Downloads
Patches
Plain Diff
Adding added_since
Signed-off-by:
Adam Harrison-Fuller
<
adam@adamhf.io
>
parent
5e565238
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config.yaml
+2
-0
2 additions, 0 deletions
config.yaml
main.go
+12
-6
12 additions, 6 deletions
main.go
with
14 additions
and
6 deletions
config.yaml
+
2
−
0
View file @
be32f4a3
...
...
@@ -10,6 +10,7 @@ feeds:
feed_url
:
https://cloud.google.com/feeds/kubernetes-engine-release-notes.xml
name
:
GKE release notes
gitlab_project_id
:
11494338
added_since
:
"
2019-03-27T15:00:00Z"
labels
:
-
GKEReleaseNotes
-
Needs/Triage
...
...
@@ -17,6 +18,7 @@ feeds:
feed_url
:
https://cloud.google.com/feeds/kubernetes-engine-security-bulletins.xml
name
:
GKE Security Updates
gitlab_project_id
:
11494338
added_since
:
"
2019-03-27T15:00:00Z"
labels
:
-
GKESecurityUpdates
-
Needs/Triage
This diff is collapsed.
Click to expand it.
main.go
+
12
−
6
View file @
be32f4a3
...
...
@@ -33,6 +33,7 @@ type Feed struct {
Name
string
GitlabProjectID
int
`yaml:"gitlab_project_id"`
Labels
[]
string
AddedSince
time
.
Time
`yaml:"added_since"`
}
type
SyncedItems
struct
{
...
...
@@ -59,13 +60,11 @@ func (feed Feed) checkFeed(db *gorm.DB, gitlabClient *gitlab.Client) {
var
newArticle
[]
*
gofeed
.
Item
var
oldArticle
[]
*
gofeed
.
Item
for
_
,
item
:=
range
rss
.
Items
{
found
:=
!
db
.
First
(
&
SyncedItems
{},
"feed = ? AND uuid = ?"
,
feed
.
ID
,
item
.
GUID
)
.
RecordNotFound
()
if
found
==
true
{
oldArticle
=
append
(
oldArticle
,
item
)
}
else
{
newArticle
=
append
(
newArticle
,
item
)
}
}
...
...
@@ -90,11 +89,16 @@ func (feed Feed) checkFeed(db *gorm.DB, gitlabClient *gitlab.Client) {
time
=
item
.
PublishedParsed
}
if
time
.
Before
(
feed
.
AddedSince
)
{
fmt
.
Printf
(
"Ignoring %s as its date is < the specified AddedSince (Item: %s vs AddedSince: %s)
\n
"
,
item
.
Title
,
time
,
feed
.
AddedSince
)
continue
}
issueOptions
:=
&
gitlab
.
CreateIssueOptions
{
Title
:
gitlab
.
String
(
item
.
Title
),
Description
:
gitlab
.
String
(
body
),
Labels
:
feed
.
Labels
,
CreatedAt
:
time
,
CreatedAt
:
time
,
}
//fmt.Println(issueOptions)
...
...
@@ -120,12 +124,14 @@ func readConfig(path string) *Config {
err
=
yaml
.
Unmarshal
(
data
,
config
)
if
err
!=
nil
{
log
.
Fatalln
(
"Unable to parse config YAML
\n
"
)
fmt
.
Printf
(
"Unable to parse config YAML
\n
%s
\n
"
,
err
)
panic
(
err
)
}
return
config
}
func
initialise
(
env
EnvValues
)
(
db
*
gorm
.
DB
,
client
*
gitlab
.
Client
,
config
*
Config
){
func
initialise
(
env
EnvValues
)
(
db
*
gorm
.
DB
,
client
*
gitlab
.
Client
,
config
*
Config
)
{
gaugeOpts
:=
prometheus
.
GaugeOpts
{
Name
:
"last_run_time"
,
Help
:
"Last Run Time in Unix Seconds"
,
...
...
@@ -156,7 +162,7 @@ func initialise(env EnvValues) (db *gorm.DB, client *gitlab.Client, config *Conf
func
main
()
{
env
:=
readEnv
()
db
,
gitlabClient
,
config
:=
initialise
(
env
)
//
defer db.Close()
defer
db
.
Close
()
go
func
()
{
for
{
...
...
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