@@ -1854,3 +1854,50 @@ func TestBuildSafeToEvictPluginMetadataOverride(t *testing.T) {
18541854 assert .Equal (t , "true" , kjob .Annotations ["cluster-autoscaler.kubernetes.io/safe-to-evict" ])
18551855 assert .Equal (t , "true" , kjob .Spec .Template .Annotations ["cluster-autoscaler.kubernetes.io/safe-to-evict" ])
18561856}
1857+
1858+ func TestBuildPodTemplateAnnotation (t * testing.T ) {
1859+ t .Parallel ()
1860+
1861+ pluginsYAML := `- github.com/buildkite-plugins/kubernetes-buildkite-plugin:
1862+ podTemplate: my-pod-template`
1863+
1864+ pluginsJSON , err := yaml .YAMLToJSONStrict ([]byte (pluginsYAML ))
1865+ require .NoError (t , err )
1866+
1867+ job := & api.AgentJob {
1868+ ID : "abc" ,
1869+ Command : "echo hello world" ,
1870+ Env : map [string ]string {"BUILDKITE_PLUGINS" : string (pluginsJSON )},
1871+ }
1872+ sjob := & api.AgentScheduledJob {}
1873+ worker := New (slog .Default (), nil , nil , Config {
1874+ Image : "buildkite/agent:latest" ,
1875+ })
1876+ inputs , err := worker .ParseJob (job , sjob )
1877+ require .NoError (t , err )
1878+ kjob , err := worker .Build (& corev1.PodSpec {}, false , inputs )
1879+ require .NoError (t , err )
1880+
1881+ require .Equal (t , "my-pod-template" , kjob .Annotations [config .PodTemplateAnnotation ])
1882+ require .Equal (t , "my-pod-template" , kjob .Spec .Template .Annotations [config .PodTemplateAnnotation ])
1883+ }
1884+
1885+ func TestBuildNoPodTemplateAnnotationWhenAbsent (t * testing.T ) {
1886+ t .Parallel ()
1887+
1888+ job := & api.AgentJob {
1889+ ID : "abc" ,
1890+ Command : "echo hello world" ,
1891+ }
1892+ sjob := & api.AgentScheduledJob {}
1893+ worker := New (slog .Default (), nil , nil , Config {
1894+ Image : "buildkite/agent:latest" ,
1895+ })
1896+ inputs , err := worker .ParseJob (job , sjob )
1897+ require .NoError (t , err )
1898+ kjob , err := worker .Build (& corev1.PodSpec {}, false , inputs )
1899+ require .NoError (t , err )
1900+
1901+ require .Empty (t , kjob .Annotations [config .PodTemplateAnnotation ])
1902+ require .Empty (t , kjob .Spec .Template .Annotations [config .PodTemplateAnnotation ])
1903+ }
0 commit comments