Skip to content

Commit 1ef9849

Browse files
committed
Sync Namespace meta
1 parent d11851d commit 1ef9849

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

cmd/icinga-kubernetes/main.go

+6
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ func main() {
7676
).Run(ctx)
7777
})
7878

79+
g.Go(func() error {
80+
return sync.NewSync(
81+
db, schema.NewNamespace, informers.Core().V1().Namespaces().Informer(), logs.GetChildLogger("Namespaces"),
82+
).Run(ctx)
83+
})
84+
7985
if err := g.Wait(); err != nil {
8086
logging.Fatal(errors.Wrap(err, "can't sync"))
8187
}

pkg/schema/namespace.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package schema
2+
3+
import (
4+
"github.com/icinga/icinga-kubernetes/pkg/contracts"
5+
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
)
7+
8+
type Namespace struct {
9+
kmetaWithoutNamespace
10+
}
11+
12+
func NewNamespace() contracts.Resource {
13+
return &Namespace{}
14+
}
15+
16+
func (n *Namespace) Obtain(kobject kmetav1.Object) {
17+
n.kmetaWithoutNamespace.Obtain(kobject)
18+
}

schema/mysql/schema.sql

+10
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ CREATE TABLE node (
77
created bigint unsigned NOT NULL,
88
PRIMARY KEY (id)
99
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
10+
11+
CREATE TABLE namespace (
12+
id binary(20) NOT NULL,
13+
canonical_name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL,
14+
name varchar(63) COLLATE utf8mb4_unicode_ci NOT NULL,
15+
uid varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
16+
resource_version varchar(255) NOT NULL,
17+
created bigint unsigned NOT NULL,
18+
PRIMARY KEY (id)
19+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

0 commit comments

Comments
 (0)