• Rostislav M. Georgiev's avatar
    kubeadm: Introduce ValidateSupportedVersion in place of DetectUnsupportedVersion · e10dcf07
    Rostislav M. Georgiev authored
    DetectUnsupportedVersion is somewhat uncomfortable, complex and inefficient
    function to use. It takes an entire YAML document as bytes, splits it up to
    byte slices of the different YAML sub-documents and group-version-kinds and
    searches through those to detect an unsupported kubeadm config. If such config
    is detected, the function returns an error, if it is not (i.e. the normal
    function operation) everything done so far is discarded.
    
    This could have been acceptable, if not the fact, that in all cases that this
    function is called, the YAML document bytes are split up and an iteration on
    GVK map is performed yet again. Hence, we don't need DetectUnsupportedVersion
    in its current form as it's inefficient, complex and takes only YAML document
    bytes.
    
    This change replaces DetectUnsupportedVersion with ValidateSupportedVersion,
    which takes a GroupVersion argument and checks if it is on the list of
    unsupported config versions. In that case an error is returned.
    ValidateSupportedVersion relies on the caller to read and split the YAML
    document and then iterate on its GVK map checking if the particular
    GroupVersion is supported or not.
    Signed-off-by: 's avatarRostislav M. Georgiev <rostislavg@vmware.com>
    e10dcf07
initconfiguration.go 15.1 KB