-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,005 additions
and
398 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
pipeline { | ||
|
||
agent any | ||
|
||
tools { | ||
go '1.17.4' | ||
} | ||
|
||
environment { | ||
REGISTRY_CREDENTIAL_ID = 'docker-hub' | ||
} | ||
|
||
stages { | ||
stage('Install') { | ||
steps { | ||
sh 'go mod download' | ||
} | ||
} | ||
stage('Build') { | ||
steps { | ||
sh 'go build -o hetzner-ddns ./cmd/hetzner-ddns' | ||
} | ||
} | ||
stage('Test') { | ||
steps { | ||
sh 'go test ./pkg/*' | ||
} | ||
} | ||
stage('Package') { | ||
when { | ||
anyOf { | ||
branch 'develop'; | ||
branch 'release/*' | ||
} | ||
} | ||
steps { | ||
script { | ||
docker.build("kutzilla/hetzner-ddns:latest") | ||
} | ||
} | ||
} | ||
stage('Publish') { | ||
when { | ||
branch 'release/*' | ||
} | ||
steps { | ||
script { | ||
def buildVersion = env.BRANCH_NAME.split('\\/') | ||
if (buildVersion.length > 1) { | ||
def version = buildVersion[1] | ||
docker.withRegistry('', env.REGISTRY_CREDENTIAL_ID) { | ||
def image = docker.build("kutzilla/hetzner-ddns:${version}") | ||
image.push() | ||
} | ||
} else { | ||
exit('No version to publish provided') | ||
} | ||
|
||
} | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"matthias-kutz.com/hetzner-ddns/pkg/args" | ||
"matthias-kutz.com/hetzner-ddns/pkg/ddns" | ||
"matthias-kutz.com/hetzner-ddns/pkg/dns" | ||
"matthias-kutz.com/hetzner-ddns/pkg/ip" | ||
) | ||
|
||
func main() { | ||
// Set args by cli values or env variables | ||
var zoneName, apiToken, recordType string | ||
args.SetArgs(&zoneName, &apiToken, &recordType) | ||
|
||
// Validate args | ||
args.ValidateArgs(zoneName, apiToken, recordType) | ||
|
||
// Set optional args or set the default values | ||
var recordName, cronExpression string | ||
args.SetOptionalArgs(&recordName, &cronExpression) | ||
|
||
dnsProvider := dns.Hetzner{ | ||
ApiToken: apiToken, | ||
} | ||
|
||
ipProvider := ip.Ipify{} | ||
|
||
ddnsParameter := ddns.Parameter{ | ||
ZoneName: zoneName, | ||
RecordName: recordName, | ||
RecordType: recordType, | ||
TTL: 0, | ||
} | ||
|
||
ddnsService := ddns.Service{ | ||
DnsProvider: dnsProvider, | ||
IpProvider: ipProvider, | ||
Parameter: ddnsParameter, | ||
} | ||
|
||
ddnsScheduler := ddns.Scheduler{ | ||
CronExpression: cronExpression, | ||
Service: ddnsService, | ||
} | ||
|
||
ddnsScheduler.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/namsral/flag v1.7.4-pre h1:b2ScHhoCUkbsq0d2C15Mv+VU8bl8hAXV8arnWiOHNZs= | ||
github.com/namsral/flag v1.7.4-pre/go.mod h1:OXldTctbM6SWH1K899kPZcf65KxJiD7MsceFUpB5yDo= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/robfig/cron/v3 v3.0.0 h1:kQ6Cb7aHOHTSzNVNEhmp8EcWKLb4CbiMW9h9VyIhO4E= | ||
github.com/robfig/cron/v3 v3.0.0/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= | ||
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Oops, something went wrong.