aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/OsRelease.java
blob: fdcda9e540378d886b1cb49e13b4873b0f439635 (plain) (blame)
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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.deployment;

import com.yahoo.component.Version;

import java.time.Duration;
import java.time.Instant;
import java.util.Objects;

/**
 * An OS release and its tag.
 *
 * @author mpolden
 */
public record OsRelease(Version version, Tag tag, Instant taggedAt) {

    public OsRelease {
        Objects.requireNonNull(version);
        Objects.requireNonNull(tag);
        Objects.requireNonNull(taggedAt);
    }

    /** The version number */
    public Version version() {
        return version;
    }

    /** The tag of this */
    public Tag tag() {
        return tag;
    }

    /** Returns the time this was tagged */
    public Instant taggedAt() {
        return taggedAt;
    }

    /** Returns the age of this at given instant */
    public Duration age(Instant instant) {
        return Duration.between(taggedAt, instant);
    }

    @Override
    public String toString() {
        return "os release " + version + ", tagged " + tag + " at " + taggedAt;
    }

    /** Known release tags */
    public enum Tag {
        latest,
        stable,
    }

}