1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#![recursion_limit = "1024"]
#![allow(renamed_and_removed_lints)]
#![allow(non_snake_case)]
#![warn(rust_2018_idioms)]

#[macro_use] extern crate serde_derive;
#[macro_use] extern crate log;
#[macro_use] extern crate maplit;

#[macro_use] extern crate error_chain; // bail and error_chain macro
error_chain! {
    types {
        Error, ErrorKind, ResultExt, Result;
    }
    links {}
    foreign_links {
        Fmt(::std::fmt::Error);
        Io(::std::io::Error) #[cfg(unix)];
        Float(::std::num::ParseFloatError);
        Int(::std::num::ParseIntError);
        Tmpl(tera::Error);
        SerdeY(serde_yaml::Error);
        SerdeJ(serde_json::Error);
        UrlP(url::ParseError);
        Reqe(reqwest::Error);
        Time(::std::time::SystemTimeError);
        Chrono(chrono::format::ParseError);
    }
    errors {
        MissingVaultAddr {
            description("VAULT_ADDR not specified")
            display("VAULT_ADDR not specified")
        }
        MissingVaultToken {
            description("VAULT_TOKEN not specified")
            display("VAULT_TOKEN not specified")
        }
        UnexpectedHttpStatus(status: reqwest::StatusCode) {
            description("unexpected HTTP status")
            display("unexpected HTTP status: {}", &status)
        }
        NoHomeDirectory {
            description("can't find home directory")
            display("can't find home directory")
        }
        // TODO: rename
        Url(url: reqwest::Url) {
            description("could not access URL")
            display("could not access URL '{}'", &url)
        }
        InvalidTemplate(svc: String) {
            description("invalid template")
            display("service '{}' has invalid templates", svc)
        }
        InvalidOneOffTemplate(tpl: String) {
            description("invalid template")
            display("template '{}' is invalid", tpl)
        }
        InvalidManifest(svc: String) {
            description("manifest does not validate")
            display("manifest for {} does not validate", &svc)
        }
        InvalidSecretForm(key: String) {
            description("secret is of incorrect form")
            display("secret '{}' not have the 'value' key", &key)
        }
        SecretNotAccessible(key: String) {
            description("secret could not be reached or accessed")
            display("secret '{}'", &key)
        }
        FailedToBuildManifest(service_name: String, region_name: String) {
            description("failed to build manifest")
            display("failed to build manifest for {} in {}", &service_name, &region_name)
        }
    }
}

/// Config with regional data
pub mod region;
pub use crate::region::{Environment, KongConfig, ReconciliationMode, Region, VaultConfig, VersionScheme};
/// Master config with cross-region data
pub mod config;
pub use crate::config::{Cluster, Config, ConfigFallback, ShipcatConfig};

/// Structs for the manifest
pub mod structs;

pub mod manifest;
pub use crate::manifest::{Manifest, ShipcatManifest};

pub mod base;
pub use crate::base::BaseManifest;

/// Definitions of teams/squads/tribes (via ewok or otherwise)
pub mod teams;

/// Crd wrappers
mod crds;
pub use crate::crds::gen_all_crds;

/// Status objects
pub mod status;
pub use status::ManifestStatus;

/// Internal classifications and states
mod states;
pub use crate::states::{ConfigState, PrimaryWorkload};

/// Computational helpers
pub mod math;

/// A renderer of `tera` templates (jinja style)
///
/// Used for small app configs that are inlined in the completed manifests.
pub mod template;

/// A Hashicorp Vault HTTP client using `reqwest`
pub mod vault;
pub use crate::vault::Vault;

pub mod deserializers;