File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -24,31 +24,37 @@ use crate::utils::update::{self, LatestRelease};
2424use chrono:: Duration ;
2525use chrono_humanize:: { Accuracy , Tense } ;
2626use crossterm:: style:: Stylize ;
27- use once_cell:: sync:: OnceCell ;
27+ use once_cell:: sync:: { Lazy , OnceCell } ;
2828use std:: env;
2929use std:: path:: Path ;
3030use sysinfo:: System ;
3131use ulid:: Ulid ;
32+
3233// Expose some static variables for internal usage
3334pub static LATEST_RELEASE : OnceCell < Option < LatestRelease > > = OnceCell :: new ( ) ;
34- static K8S_ENV_TO_CHECK : & str = "KUBERNETES_SERVICE_HOST" ;
35-
36- fn is_docker ( ) -> bool {
37- Path :: new ( "/.dockerenv" ) . exists ( )
38- }
3935
36+ static K8S_ENV_TO_CHECK : & str = "KUBERNETES_SERVICE_HOST" ;
4037fn is_k8s ( ) -> bool {
4138 env:: var ( K8S_ENV_TO_CHECK ) . is_ok ( )
4239}
4340
44- pub fn platform ( ) -> & ' static str {
41+ static DOCKERENV_FILE : & str = "/.dockerenv" ;
42+ fn is_docker ( ) -> bool {
43+ Path :: new ( DOCKERENV_FILE ) . exists ( )
44+ }
45+
46+ static PLATFORM : Lazy < & ' static str > = Lazy :: new ( || {
4547 if is_k8s ( ) {
4648 "Kubernetes"
4749 } else if is_docker ( ) {
4850 "Docker"
4951 } else {
5052 "Native"
5153 }
54+ } ) ;
55+
56+ pub fn platform ( ) -> & ' static str {
57+ PLATFORM . as_ref ( )
5258}
5359
5460pub fn set_latest_release ( latest_release : Option < LatestRelease > ) {
You can’t perform that action at this time.
0 commit comments