blob: 271130f88c91b12033941e157f6ab8a511d24576 [file] [log] [blame]
// Copyright 2022 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
use std::{collections::HashMap, path::PathBuf};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct Manifest {
/// Information about the project to which the manifest belongs.
pub project: Project,
#[serde(default)]
pub providers: HashMap<String, ProviderDescriptor>,
}
/// A qg-based project.
#[derive(Debug, Deserialize, Serialize)]
pub struct Project {
/// The name of the project.
pub name: String,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct ProviderDescriptor {
pub manifest: Option<PathBuf>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct ProviderFile {
#[serde(default)]
pub packages: HashMap<String, Package>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Package {
#[serde(flatten)]
pub desc: PackageType,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum PackageType {
Cipd(CipdPackage),
}
#[derive(Debug, Deserialize, Serialize)]
pub struct CipdPackage {
/// The location on of the package in CIPD's repositories.
pub path: String,
/// Platforms the package supports.
#[serde(default)]
pub platforms: Vec<String>,
/// CIPD tags to match against when finding a package revision.
#[serde(default)]
pub tags: Vec<String>,
/// Local subdirectory under the CIPD installation root into which the
/// package is installed.
pub subdir: Option<PathBuf>,
}
impl Manifest {
pub fn new(name: &str) -> Self {
Self {
project: Project {
name: name.to_owned(),
},
providers: HashMap::new(),
}
}
}