diff --git a/src/k8s/cmd/k8s/k8s_bootstrap.go b/src/k8s/cmd/k8s/k8s_bootstrap.go index e8b2b3371..9ba6525d3 100644 --- a/src/k8s/cmd/k8s/k8s_bootstrap.go +++ b/src/k8s/cmd/k8s/k8s_bootstrap.go @@ -60,7 +60,7 @@ func newBootstrapCmd(env cmdutil.ExecutionEnvironment) *cobra.Command { env.Exit(1) return } - if microk8sInfo.StatusCode == 200 && !microk8sInfo.Result.InstallDate.IsZero() { + if microk8sInfo.StatusCode == 200 && microk8sInfo.HasInstallDate() { cmd.PrintErrln("Error: microk8s snap is installed. Please remove it using the following command and try again:\n\n sudo snap remove microk8s") env.Exit(1) return diff --git a/src/k8s/pkg/client/snapd/snap_info.go b/src/k8s/pkg/client/snapd/snap_info.go index b78eda0bc..b09f61ec4 100644 --- a/src/k8s/pkg/client/snapd/snap_info.go +++ b/src/k8s/pkg/client/snapd/snap_info.go @@ -35,3 +35,7 @@ func (c *Client) GetSnapInfo(snap string) (*SnapInfoResponse, error) { return &snapInfoResponse, nil } + +func (s SnapInfoResponse) HasInstallDate() bool { + return !s.Result.InstallDate.IsZero() +}