22
33import com .github .dockerjava .api .command .VersionCmd ;
44import com .github .dockerjava .api .exception .DockerException ;
5+ import com .github .dockerjava .api .model .VersionPlatform ;
56import io .kubernetes .client .openapi .ApiClient ;
67import io .kubernetes .client .openapi .ApiException ;
78import io .kubernetes .client .openapi .models .VersionInfo ;
89import io .kubernetes .client .util .version .Version ;
10+ import org .apache .commons .beanutils .BeanUtils ;
11+ import org .apache .commons .beanutils .PropertyUtils ;
12+ import org .apache .commons .lang .reflect .FieldUtils ;
913import org .apache .commons .lang3 .builder .ToStringBuilder ;
1014import org .apache .commons .lang3 .builder .ToStringStyle ;
1115import org .slf4j .Logger ;
1216import org .slf4j .LoggerFactory ;
1317
1418import java .io .IOException ;
19+ import java .lang .reflect .InvocationTargetException ;
20+
21+ import static org .apache .commons .beanutils .BeanUtils .setProperty ;
22+ import static org .apache .commons .lang .reflect .FieldUtils .*;
1523
1624public class VersionCmdImpl implements VersionCmd {
1725
@@ -35,6 +43,24 @@ public com.github.dockerjava.api.model.Version exec() {
3543 }
3644
3745 com .github .dockerjava .api .model .Version dockerVersion = new com .github .dockerjava .api .model .Version ();
46+ try {
47+ writeField (dockerVersion , "goVersion" , info .getGoVersion (), true );
48+ writeField (dockerVersion , "version" , info .getGitVersion (), true );
49+ writeField (dockerVersion , "gitCommit" , info .getGitCommit (), true );
50+ writeField (dockerVersion , "buildTime" , info .getBuildDate (), true );
51+
52+ writeField (dockerVersion , "platform" , new VersionPlatform ().withName (info .getPlatform ()), true );
53+ writeField (dockerVersion , "operatingSystem" , info .getPlatform ().split ("/" )[0 ], true );
54+ writeField (dockerVersion , "arch" , info .getPlatform ().split ("/" )[1 ], true );
55+
56+ writeField (dockerVersion , "apiVersion" , info .getMajor () + "." + info .getMinor (), true );
57+ writeField (dockerVersion , "version" , info .getMajor () + "." + info .getMinor (), true );
58+
59+ writeField (dockerVersion , "experimental" , Boolean .FALSE , true );
60+ } catch (IllegalAccessException e ) {
61+ throw new RuntimeException ("Unable to set bean field." , e );
62+ }
63+
3864 return dockerVersion ;
3965 }
4066
0 commit comments