Fix fission check command doesnt work for namespace other than fission (#2932)
* Fix `fission check` command which does not work outside of `fission` namespace If user provide namespace then use it for running `fission check` command. If user does not provide namespace then use `fission` as default namespace. * Update go version to 1.22.2 --------- Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module github.com/fission/fission
|
||||
|
||||
go 1.22
|
||||
go 1.22.2
|
||||
|
||||
require (
|
||||
dario.cat/mergo v1.0.0
|
||||
|
||||
@@ -14,6 +14,8 @@ limitations under the License.
|
||||
package check
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
@@ -32,13 +34,18 @@ func (opts *CheckSubCommand) do(input cli.Input) error {
|
||||
|
||||
checks := []healthcheck.CategoryID{}
|
||||
|
||||
userProvidedNS, _, err := opts.GetResourceNamespace(input, flagkey.Namespace)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error retrieving user provided namespace information: %w", err)
|
||||
}
|
||||
|
||||
if input.IsSet(flagkey.PreCheckOnly) {
|
||||
checks = append(checks, healthcheck.Kubernetes)
|
||||
} else {
|
||||
checks = append(checks, healthcheck.FissionServices, healthcheck.FissionVersion)
|
||||
}
|
||||
|
||||
hc := healthcheck.NewHealthChecker(opts.Client(), checks)
|
||||
hc := healthcheck.NewHealthChecker(opts.Client(), checks, userProvidedNS)
|
||||
|
||||
healthcheck.RunChecks(input.Context(), input, opts.Client(), hc)
|
||||
return nil
|
||||
|
||||
@@ -18,11 +18,12 @@ package util
|
||||
|
||||
// fission-cli options
|
||||
const (
|
||||
SPEC_IGNORE_FILE = ".specignore"
|
||||
COMMIT_LABEL = "commit"
|
||||
FISSION_AUTH_URI = "/auth/login"
|
||||
FISSION_AUTH_TOKEN = "FISSION_AUTH_TOKEN"
|
||||
FISSION_STORAGE_URI = "/v1/archive"
|
||||
SPEC_IGNORE_FILE = ".specignore"
|
||||
COMMIT_LABEL = "commit"
|
||||
FISSION_AUTH_URI = "/auth/login"
|
||||
FISSION_AUTH_TOKEN = "FISSION_AUTH_TOKEN"
|
||||
FISSION_STORAGE_URI = "/v1/archive"
|
||||
FISSION_DEFAULT_NAMESPACE = "fission"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -203,10 +203,14 @@ func (hc *HealthChecker) allCategories() []*Category {
|
||||
}
|
||||
}
|
||||
|
||||
func NewHealthChecker(cmd cmd.Client, categoryIDs []CategoryID) *HealthChecker {
|
||||
func NewHealthChecker(cmd cmd.Client, categoryIDs []CategoryID, fissionNamespace string) *HealthChecker {
|
||||
if fissionNamespace == "" {
|
||||
fissionNamespace = util.FISSION_DEFAULT_NAMESPACE
|
||||
}
|
||||
|
||||
hc := &HealthChecker{
|
||||
kubeAPI: cmd.KubernetesClient,
|
||||
fissionNamespace: "fission",
|
||||
fissionNamespace: fissionNamespace,
|
||||
}
|
||||
|
||||
hc.categories = hc.allCategories()
|
||||
|
||||
@@ -366,6 +366,11 @@ func TestFissionCLI(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("check --namespace", func(t *testing.T) {
|
||||
_, err := cli.ExecCommand(f, ctx, "check", "--namespace", "default")
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("version", func(t *testing.T) {
|
||||
_, err := cli.ExecCommand(f, ctx, "version")
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user