Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Wksctl
Commits
bf28f2ea
Commit
bf28f2ea
authored
5 years ago
by
Bryan Boreham
Browse files
Options
Download
Email Patches
Plain Diff
Re-use machine.GetKubernetesVersionFromManifest()
parent
cf562d2b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/wksctl/registrysynccommands/registrysynccommands.go
+1
-20
cmd/wksctl/registrysynccommands/registrysynccommands.go
with
1 addition
and
20 deletions
+1
-20
cmd/wksctl/registrysynccommands/registrysynccommands.go
+
1
-
20
View file @
bf28f2ea
...
...
@@ -10,11 +10,7 @@ import (
"github.com/weaveworks/wksctl/pkg/cluster/machine"
"github.com/weaveworks/wksctl/pkg/kubernetes"
"github.com/weaveworks/wksctl/pkg/registry"
"github.com/weaveworks/wksctl/pkg/utilities"
v
"github.com/weaveworks/wksctl/pkg/utilities/version"
"k8s.io/apimachinery/pkg/util/validation/field"
clusterv1
"sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
apierrors
"sigs.k8s.io/cluster-api/pkg/errors"
)
var
Cmd
=
&
cobra
.
Command
{
...
...
@@ -78,7 +74,7 @@ func registrySyncRun(cmd *cobra.Command, args []string) {
func
kubernetesVersionsRange
()
string
{
if
registrySyncOptions
.
machinesManifestPath
!=
""
{
version
,
err
:=
extrac
tKubernetesVersionFromMa
chin
es
(
registrySyncOptions
.
machinesManifestPath
)
version
,
_
,
err
:=
machine
.
Ge
tKubernetesVersionFromMa
nif
es
t
(
registrySyncOptions
.
machinesManifestPath
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to extract Kubernetes version from machines manifest: %s"
,
err
)
}
...
...
@@ -89,18 +85,3 @@ func kubernetesVersionsRange() string {
}
return
v
.
AnyRange
}
func
extractKubernetesVersionFromMachines
(
machinesManifestPath
string
)
(
string
,
error
)
{
errorsHandler
:=
func
(
machines
[]
*
clusterv1
.
Machine
,
errors
field
.
ErrorList
)
([]
*
clusterv1
.
Machine
,
error
)
{
if
len
(
errors
)
>
0
{
utilities
.
PrintErrors
(
errors
)
return
nil
,
apierrors
.
InvalidMachineConfiguration
(
"%s failed validation"
,
machinesManifestPath
)
}
return
machines
,
nil
}
machines
,
err
:=
machine
.
ParseAndDefaultAndValidate
(
machinesManifestPath
,
errorsHandler
)
if
err
!=
nil
{
return
""
,
err
}
return
machines
[
0
]
.
Spec
.
Versions
.
Kubelet
,
nil
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment