use crate::types::chatservice::*;
use crate::types::minioinstance::*;
use crate::types::webservice::*;

pub fn test_webservice() -> WebService {
    WebService {
        metadata: kube::api::ObjectMeta {
            name: Some("txt".to_string()),
            namespace: Some("test-ns".to_string()),
            uid: Some("test-uid-ws".to_string()),
            ..Default::default()
        },
        spec: WebServiceSpec {
            image: "image-registry.openshift-image-registry.svc:5000/irc-josie-cloud/paste:latest"
                .to_string(),
            host: "txt.irc.now".to_string(),
            tls: Some(TlsSpec {
                issuer_ref: IssuerRef {
                    name: "letsencrypt-prod".to_string(),
                    kind: "ClusterIssuer".to_string(),
                },
                dns_names: vec!["txt.irc.now".to_string()],
            }),
            resources: Some(ResourceRequirements {
                requests: Some(ResourceList {
                    memory: Some("64Mi".to_string()),
                    cpu: Some("50m".to_string()),
                }),
                limits: Some(ResourceList {
                    memory: Some("256Mi".to_string()),
                    cpu: Some("500m".to_string()),
                }),
            }),
            database: Some(DatabaseSpec {
                secret_ref: "paste-db-app".to_string(),
                host: "paste-db-rw.irc-josie-cloud".to_string(),
                name: "paste".to_string(),
                port: 5432,
                env_prefix: Some("PASTE_DB".to_string()),
            }),
            oidc: Some(OidcSpec {
                issuer_url: "https://auth.irc.now/realms/irc-now".to_string(),
                secret_ref: "oidc-paste".to_string(),
                redirect_url: "https://txt.irc.now/auth/callback".to_string(),
            }),
            ..Default::default()
        },
        status: None,
    }
}

pub fn test_webservice_minimal() -> WebService {
    WebService {
        metadata: kube::api::ObjectMeta {
            name: Some("web-landing".to_string()),
            namespace: Some("test-ns".to_string()),
            uid: Some("test-uid-wl".to_string()),
            ..Default::default()
        },
        spec: WebServiceSpec {
            image: "image-registry.openshift-image-registry.svc:5000/irc-josie-cloud/web-landing:latest"
                .to_string(),
            host: "irc.now".to_string(),
            tls: Some(TlsSpec {
                issuer_ref: IssuerRef {
                    name: "letsencrypt-prod".to_string(),
                    kind: "ClusterIssuer".to_string(),
                },
                dns_names: vec!["irc.now".to_string()],
            }),
            resources: Some(ResourceRequirements {
                requests: Some(ResourceList {
                    memory: Some("32Mi".to_string()),
                    cpu: Some("10m".to_string()),
                }),
                limits: Some(ResourceList {
                    memory: Some("64Mi".to_string()),
                    cpu: Some("100m".to_string()),
                }),
            }),
            ..Default::default()
        },
        status: None,
    }
}

pub fn test_chatservice() -> ChatService {
    ChatService {
        metadata: kube::api::ObjectMeta {
            name: Some("chat".to_string()),
            namespace: Some("test-ns".to_string()),
            uid: Some("test-uid-cs".to_string()),
            ..Default::default()
        },
        spec: ChatServiceSpec {
            image: "image-registry.openshift-image-registry.svc:5000/irc-josie-cloud/chat:latest"
                .to_string(),
            host: "chat.irc.now".to_string(),
            tls: Some(TlsSpec {
                issuer_ref: IssuerRef {
                    name: "letsencrypt-prod".to_string(),
                    kind: "ClusterIssuer".to_string(),
                },
                dns_names: vec!["chat.irc.now".to_string()],
            }),
            resources: Some(ResourceRequirements {
                requests: Some(ResourceList {
                    memory: Some("32Mi".to_string()),
                    cpu: Some("10m".to_string()),
                }),
                limits: Some(ResourceList {
                    memory: Some("64Mi".to_string()),
                    cpu: Some("100m".to_string()),
                }),
            }),
            websocket_timeout: 600,
            ..Default::default()
        },
        status: None,
    }
}

pub fn test_minioinstance() -> MinioInstance {
    MinioInstance {
        metadata: kube::api::ObjectMeta {
            name: Some("minio".to_string()),
            namespace: Some("test-ns".to_string()),
            uid: Some("test-uid-mi".to_string()),
            ..Default::default()
        },
        spec: MinioInstanceSpec {
            storage_size: "10Gi".to_string(),
            storage_class_name: Some("customer-workload-storage".to_string()),
            credentials_secret: "minio-credentials".to_string(),
            resources: Some(ResourceRequirements {
                requests: Some(ResourceList {
                    memory: Some("256Mi".to_string()),
                    cpu: Some("100m".to_string()),
                }),
                limits: Some(ResourceList {
                    memory: Some("512Mi".to_string()),
                    cpu: Some("500m".to_string()),
                }),
            }),
        },
        status: None,
    }
}
