Skip to content

Commit 7081131

Browse files
authored
Merge pull request #10 from demeter-run/9-chore-refactor-folder-structure
Updated folder structure
2 parents da507a1 + 6b95229 commit 7081131

26 files changed

+180
-57
lines changed

.github/workflows/clippy.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ on:
1111
jobs:
1212
lint:
1313
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: ./operator
1417
steps:
15-
- uses: actions/checkout@v3
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
1621
- name: Clippy check lints
1722
run: cargo clippy -- -D warnings

.github/workflows/validate.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
jobs:
1212
run-controller:
1313
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: ./operator
1417
steps:
1518
- name: Checkout
1619
uses: actions/checkout@v3

bootstrap/crds/main.tf

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
resource "kubernetes_manifest" "customresourcedefinition_dbsyncports_demeter_run" {
2+
manifest = {
3+
"apiVersion" = "apiextensions.k8s.io/v1"
4+
"kind" = "CustomResourceDefinition"
5+
"metadata" = {
6+
"name" = "dbsyncports.demeter.run"
7+
}
8+
"spec" = {
9+
"group" = "demeter.run"
10+
"names" = {
11+
"categories" = []
12+
"kind" = "DbSyncPort"
13+
"plural" = "dbsyncports"
14+
"shortNames" = []
15+
"singular" = "dbsyncport"
16+
}
17+
"scope" = "Namespaced"
18+
"versions" = [
19+
{
20+
"additionalPrinterColumns" = [
21+
{
22+
"jsonPath" = ".spec.network"
23+
"name" = "Network"
24+
"type" = "string"
25+
},
26+
{
27+
"jsonPath" = ".status.username"
28+
"name" = "Username"
29+
"type" = "string"
30+
},
31+
{
32+
"jsonPath" = ".status.password"
33+
"name" = "Password"
34+
"type" = "string"
35+
},
36+
]
37+
"name" = "v1alpha1"
38+
"schema" = {
39+
"openAPIV3Schema" = {
40+
"description" = "Auto-generated derived type for DbSyncPortSpec via `CustomResource`"
41+
"properties" = {
42+
"spec" = {
43+
"properties" = {
44+
"network" = {
45+
"enum" = [
46+
"mainnet",
47+
"preprod",
48+
"preview",
49+
]
50+
"type" = "string"
51+
}
52+
}
53+
"required" = [
54+
"network",
55+
]
56+
"type" = "object"
57+
}
58+
"status" = {
59+
"nullable" = true
60+
"properties" = {
61+
"password" = {
62+
"type" = "string"
63+
}
64+
"username" = {
65+
"type" = "string"
66+
}
67+
}
68+
"required" = [
69+
"password",
70+
"username",
71+
]
72+
"type" = "object"
73+
}
74+
}
75+
"required" = [
76+
"spec",
77+
]
78+
"title" = "DbSyncPort"
79+
"type" = "object"
80+
}
81+
}
82+
"served" = true
83+
"storage" = true
84+
"subresources" = {
85+
"status" = {}
86+
}
87+
},
88+
]
89+
}
90+
}
91+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
2-
.env
2+
.env
3+
ci
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/controller.rs renamed to operator/src/controller.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use serde_json::json;
1616
use std::{sync::Arc, time::Duration};
1717
use tracing::error;
1818

19-
use crate::{postgres::Postgres, Config, Error, Metrics, State, Network};
19+
use crate::{postgres::Postgres, Config, Error, Metrics, Network, State};
2020

2121
pub static DB_SYNC_PORT_FINALIZER: &str = "dbsyncports.demeter.run";
2222

@@ -36,8 +36,18 @@ impl Context {
3636
}
3737

3838
#[derive(CustomResource, Deserialize, Serialize, Clone, Debug, JsonSchema)]
39-
#[kube(kind = "DbSyncPort", group = "demeter.run", version = "v1", namespaced)]
39+
#[kube(
40+
kind = "DbSyncPort",
41+
group = "demeter.run",
42+
version = "v1alpha1",
43+
namespaced
44+
)]
4045
#[kube(status = "DbSyncPortStatus")]
46+
#[kube(printcolumn = r#"
47+
{"name": "Network", "jsonPath": ".spec.network", "type": "string"},
48+
{"name": "Username", "jsonPath": ".status.username", "type": "string"},
49+
{"name": "Password", "jsonPath": ".status.password", "type": "string"}
50+
"#)]
4151
pub struct DbSyncPortSpec {
4252
pub network: Network,
4353
}
@@ -70,7 +80,7 @@ impl DbSyncPort {
7080
};
7181

7282
let new_status = Patch::Apply(json!({
73-
"apiVersion": "demeter.run/v1",
83+
"apiVersion": "demeter.run/v1alpha1",
7484
"kind": "DbSyncPort",
7585
"status": DbSyncPortStatus {
7686
username: username.clone(),
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/manifest.yaml renamed to operator/test/manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ spec:
197197
targetPort: 80
198198
protocol: TCP
199199
---
200-
apiVersion: demeter.run/v1
200+
apiVersion: demeter.run/v1alpha1
201201
kind: DbSyncPort
202202
metadata:
203203
name: ci-user
File renamed without changes.

operator/yaml/dbsyncport.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: dbsyncports.demeter.run
5+
spec:
6+
group: demeter.run
7+
names:
8+
categories: []
9+
kind: DbSyncPort
10+
plural: dbsyncports
11+
shortNames: []
12+
singular: dbsyncport
13+
scope: Namespaced
14+
versions:
15+
- additionalPrinterColumns:
16+
- jsonPath: .spec.network
17+
name: Network
18+
type: string
19+
- jsonPath: .status.username
20+
name: Username
21+
type: string
22+
- jsonPath: .status.password
23+
name: Password
24+
type: string
25+
name: v1alpha1
26+
schema:
27+
openAPIV3Schema:
28+
description: Auto-generated derived type for DbSyncPortSpec via `CustomResource`
29+
properties:
30+
spec:
31+
properties:
32+
network:
33+
enum:
34+
- mainnet
35+
- preprod
36+
- preview
37+
type: string
38+
required:
39+
- network
40+
type: object
41+
status:
42+
nullable: true
43+
properties:
44+
password:
45+
type: string
46+
username:
47+
type: string
48+
required:
49+
- password
50+
- username
51+
type: object
52+
required:
53+
- spec
54+
title: DbSyncPort
55+
type: object
56+
served: true
57+
storage: true
58+
subresources:
59+
status: {}

yaml/user-access.yaml renamed to operator/yaml/user-access.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: demeter.run/v1
1+
apiVersion: demeter.run/v1alpha1
22
kind: DbSyncPort
33
metadata:
44
name: mainnet-user
File renamed without changes.

scripts/crd.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
cd ../operator
3+
cargo run --bin crdgen | tfk8s > ../bootstrap/crds/main.tf
4+

yaml/dbsyncport.yaml

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)