File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/python_gardenlinux_lib Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -83,5 +83,29 @@ def get_minimal_feature_set(graph):
8383 return set ([node for (node , degree ) in graph .in_degree () if degree == 0 ])
8484
8585
86+ def get_flavor_from_cname (cname : str , get_arch : bool = True ) -> str :
87+ """
88+ Extracts the flavor from a canonical name.
89+
90+ :param str cname: Canonical name of an image
91+ :param bool get_arch: Whether to include the architecture in the flavor
92+ :return: Flavor string
93+ """
94+
95+ # cname:
96+ # azure-gardener_prod_tpm2_trustedboot-amd64-1312.2-80ffcc87
97+ # transform to flavor:
98+ # azure-gardener_prod_tpm2_trustedboot-amd64
99+
100+ platform = cname .split ("-" )[0 ]
101+ features = cname .split ("-" )[1 :- 1 ]
102+ arch = cname .split ("-" )[- 1 ]
103+
104+ if get_arch :
105+ return f"{ platform } -{ features } -{ arch } "
106+ else :
107+ return f"{ platform } -{ features } "
108+
109+
86110if __name__ == "__main__" :
87111 main ()
You can’t perform that action at this time.
0 commit comments