Skip to content

Commit

Permalink
Updated comments and cleaned workspace (#4)
Browse files Browse the repository at this point in the history
Updated comments and cleaned workspace

- added documentation comments and license headers to most files;
- removed unused files in workspace;
- clarified some functions used in unit tests.
- linted code
  • Loading branch information
mconfalonieri authored Nov 3, 2023
1 parent 242f9b0 commit 3ff53da
Show file tree
Hide file tree
Showing 14 changed files with 265 additions and 244 deletions.
20 changes: 20 additions & 0 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2023 Marco Confalonieri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main

import (
Expand All @@ -14,6 +29,7 @@ import (
"github.com/codingconcepts/env"
)

// loop waits for a SIGTERM or a SIGINT and then shuts down the server.
func loop(status *server.HealthStatus) {
exitSignal := make(chan os.Signal, 1)
signal.Notify(exitSignal, syscall.SIGINT, syscall.SIGTERM)
Expand All @@ -24,6 +40,7 @@ func loop(status *server.HealthStatus) {
status.SetReady(false)
}

// main function
func main() {
// Read server options
serverOptions := &server.ServerOptions{}
Expand All @@ -49,6 +66,7 @@ func main() {
panic(err)
}

// Start the webhook
log.Infof("Starting webhook server on %s", serverOptions.GetWebhookAddress())
startedChan := make(chan struct{})
go webhook.StartHTTPApi(
Expand All @@ -57,6 +75,8 @@ func main() {
serverOptions.GetWriteTimeout(),
serverOptions.GetWebhookAddress(),
)

// Wait for the HTTP server to start and then set the healthy and ready flags
<-startedChan
healthStatus.SetHealth(true)
healthStatus.SetReady(true)
Expand Down
15 changes: 0 additions & 15 deletions deployments/dns-mockserver/dns-mockserver-values.yaml

This file was deleted.

54 changes: 0 additions & 54 deletions deployments/helm/local-values.yaml

This file was deleted.

52 changes: 0 additions & 52 deletions deployments/helm/remote-values.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions deployments/kind/cluster.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions deployments/kind/local-registry-configmap.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions internal/hetzner/configuration.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2023 Marco Confalonieri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package hetzner

import (
Expand Down
17 changes: 17 additions & 0 deletions internal/hetzner/configuration_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2023 Marco Confalonieri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package hetzner

import (
Expand All @@ -8,6 +23,8 @@ import (
"sigs.k8s.io/external-dns/endpoint"
)

// Test_GetDomainFilter tests that the domain filter is correctly set for all
// cases.
func Test_GetDomainFilter(t *testing.T) {
t.Setenv("HETZNER_API_KEY", "test-key")
type testCase struct {
Expand Down
25 changes: 15 additions & 10 deletions internal/hetzner/hetznerdns.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2023 Marco Confalonieri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package hetzner

import (
Expand All @@ -6,16 +21,6 @@ import (
hdns "github.com/jobstoit/hetzner-dns-go/dns"
)

/*
type apiClient interface {
GetZones(ctx context.Context, name string, searchName string, page int, perPage int) (*hdns.ZonesResponse, error)
GetRecords(ctx context.Context, zone_id string, page int, perPage int) (*hdns.RecordsResponse, error)
CreateRecord(ctx context.Context, record hdns.RecordRequest) (*hdns.RecordResponse, error)
UpdateRecord(ctx context.Context, record hdns.RecordRequest) (*hdns.RecordResponse, error)
DeleteRecord(ctx context.Context, recordId string) error
}
*/

// hetznerDNS is the DNS client API.
type hetznerDNS struct {
client *hdns.Client
Expand Down
Loading

0 comments on commit 3ff53da

Please sign in to comment.