Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated folder structure #10

Merged
merged 12 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./operator
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- name: Clippy check lints
run: cargo clippy -- -D warnings
3 changes: 3 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
jobs:
run-controller:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./operator
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
91 changes: 91 additions & 0 deletions bootstrap/crds/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
resource "kubernetes_manifest" "customresourcedefinition_dbsyncports_demeter_run" {
manifest = {
"apiVersion" = "apiextensions.k8s.io/v1"
"kind" = "CustomResourceDefinition"
"metadata" = {
"name" = "dbsyncports.demeter.run"
}
"spec" = {
"group" = "demeter.run"
"names" = {
"categories" = []
"kind" = "DbSyncPort"
"plural" = "dbsyncports"
"shortNames" = []
"singular" = "dbsyncport"
}
"scope" = "Namespaced"
"versions" = [
{
"additionalPrinterColumns" = [
{
"jsonPath" = ".spec.network"
"name" = "Network"
"type" = "string"
},
{
"jsonPath" = ".status.username"
"name" = "Username"
"type" = "string"
},
{
"jsonPath" = ".status.password"
"name" = "Password"
"type" = "string"
},
]
"name" = "v1alpha1"
"schema" = {
"openAPIV3Schema" = {
"description" = "Auto-generated derived type for DbSyncPortSpec via `CustomResource`"
"properties" = {
"spec" = {
"properties" = {
"network" = {
"enum" = [
"mainnet",
"preprod",
"preview",
]
"type" = "string"
}
}
"required" = [
"network",
]
"type" = "object"
}
"status" = {
"nullable" = true
"properties" = {
"password" = {
"type" = "string"
}
"username" = {
"type" = "string"
}
}
"required" = [
"password",
"username",
]
"type" = "object"
}
}
"required" = [
"spec",
]
"title" = "DbSyncPort"
"type" = "object"
}
}
"served" = true
"storage" = true
"subresources" = {
"status" = {}
}
},
]
}
}
}
3 changes: 2 additions & 1 deletion .gitignore → operator/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
.env
.env
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.
16 changes: 13 additions & 3 deletions src/controller.rs → operator/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use serde_json::json;
use std::{sync::Arc, time::Duration};
use tracing::error;

use crate::{postgres::Postgres, Config, Error, Metrics, State, Network};
use crate::{postgres::Postgres, Config, Error, Metrics, Network, State};

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

Expand All @@ -36,8 +36,18 @@ impl Context {
}

#[derive(CustomResource, Deserialize, Serialize, Clone, Debug, JsonSchema)]
#[kube(kind = "DbSyncPort", group = "demeter.run", version = "v1", namespaced)]
#[kube(
kind = "DbSyncPort",
group = "demeter.run",
version = "v1alpha1",
namespaced
)]
#[kube(status = "DbSyncPortStatus")]
#[kube(printcolumn = r#"
{"name": "Network", "jsonPath": ".spec.network", "type": "string"},
{"name": "Username", "jsonPath": ".status.username", "type": "string"},
{"name": "Password", "jsonPath": ".status.password", "type": "string"}
"#)]
pub struct DbSyncPortSpec {
pub network: Network,
}
Expand Down Expand Up @@ -70,7 +80,7 @@ impl DbSyncPort {
};

let new_status = Patch::Apply(json!({
"apiVersion": "demeter.run/v1",
"apiVersion": "demeter.run/v1alpha1",
"kind": "DbSyncPort",
"status": DbSyncPortStatus {
username: username.clone(),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/manifest.yaml → operator/test/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ spec:
targetPort: 80
protocol: TCP
---
apiVersion: demeter.run/v1
apiVersion: demeter.run/v1alpha1
kind: DbSyncPort
metadata:
name: ci-user
Expand Down
File renamed without changes.
59 changes: 59 additions & 0 deletions operator/yaml/dbsyncport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: dbsyncports.demeter.run
spec:
group: demeter.run
names:
categories: []
kind: DbSyncPort
plural: dbsyncports
shortNames: []
singular: dbsyncport
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.network
name: Network
type: string
- jsonPath: .status.username
name: Username
type: string
- jsonPath: .status.password
name: Password
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: Auto-generated derived type for DbSyncPortSpec via `CustomResource`
properties:
spec:
properties:
network:
enum:
- mainnet
- preprod
- preview
type: string
required:
- network
type: object
status:
nullable: true
properties:
password:
type: string
username:
type: string
required:
- password
- username
type: object
required:
- spec
title: DbSyncPort
type: object
served: true
storage: true
subresources:
status: {}
2 changes: 1 addition & 1 deletion yaml/user-access.yaml → operator/yaml/user-access.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: demeter.run/v1
apiVersion: demeter.run/v1alpha1
kind: DbSyncPort
metadata:
name: mainnet-user
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions scripts/crd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
cd ../operator
cargo run --bin crdgen | tfk8s > ../bootstrap/crds/main.tf

50 changes: 0 additions & 50 deletions yaml/dbsyncport.yaml

This file was deleted.