Files
zeekay bd81b9f2e2 canonical: hanzoai imports + hanzo.ai CRD group (de-fission)
Module github.com/fission/fission -> github.com/hanzoai/functions (288 files).
CRD API group fission.io -> hanzo.ai (67 files): functions.hanzo.ai,
environments.hanzo.ai, httptriggers.hanzo.ai, messagequeuetriggers.hanzo.ai,
joining apps.hanzo.ai under the one house group. Doc URLs preserved. Builds green.

Matches the cloud contract: clients/functions, /v1/functions, App CR role
"function". Remaining: fork the env images + the live CRD-group migration
(demo-only today, low risk).
2026-07-19 23:37:32 -07:00

103 lines
4.2 KiB
Go

/*
Copyright 2022 The Fission Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package app
import (
"fmt"
"github.com/spf13/cobra"
"github.com/hanzoai/functions/pkg/fission-cli/cliwrapper/cli"
wrapper "github.com/hanzoai/functions/pkg/fission-cli/cliwrapper/driver/cobra"
"github.com/hanzoai/functions/pkg/fission-cli/cliwrapper/driver/cobra/helptemplate"
"github.com/hanzoai/functions/pkg/fission-cli/cmd"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/archive"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/canaryconfig"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/check"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/environment"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/function"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/httptrigger"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/kubewatch"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/mqtrigger"
_package "github.com/hanzoai/functions/pkg/fission-cli/cmd/package"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/spec"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/support"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/timetrigger"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/token"
"github.com/hanzoai/functions/pkg/fission-cli/cmd/version"
"github.com/hanzoai/functions/pkg/fission-cli/console"
"github.com/hanzoai/functions/pkg/fission-cli/flag"
flagkey "github.com/hanzoai/functions/pkg/fission-cli/flag/key"
_ "github.com/hanzoai/functions/pkg/mqtrigger/messageQueue/kafka"
)
const (
usage = `Fission: Fast and Simple Serverless Functions for Kubernetes
* GitHub: https://github.com/hanzoai/functions
* Documentation: https://fission.io/docs
`
)
func App(clientOptions cmd.ClientOptions) *cobra.Command {
cobra.EnableCommandSorting = false
rootCmd := &cobra.Command{
Use: "fission",
Long: usage,
//SilenceUsage: true,
PersistentPreRunE: wrapper.Wrapper(
func(input cli.Input) error {
console.Verbosity = input.Int(flagkey.Verbosity)
clientOptions.KubeContext = input.String(flagkey.KubeContext)
// TODO: use fake rest client for offline spec generation
// if input.IsSet(flagkey.ClientOnly) || input.IsSet(flagkey.PreCheckOnly) {
// }
client, err := cmd.NewClient(clientOptions)
if err != nil {
return fmt.Errorf("failed to get fission client: %w", err)
}
cmd.SetClientset(*client)
return nil
},
),
}
// Workaround fix for not to show help command
// https://github.com/spf13/cobra/issues/587
rootCmd.SetHelpCommand(&cobra.Command{
Use: "no-help",
Hidden: true,
})
wrapper.SetFlags(rootCmd, flag.FlagSet{
Global: []flag.Flag{flag.GlobalVerbosity, flag.KubeContext, flag.Namespace},
})
groups := helptemplate.CommandGroups{}
groups = append(groups, helptemplate.CreateCmdGroup("Auth Commands(Note: Authentication should be enabled to use a command in this group.)", token.Commands()))
groups = append(groups, helptemplate.CreateCmdGroup("Basic Commands", environment.Commands(), _package.Commands(), function.Commands(), archive.Commands()))
groups = append(groups, helptemplate.CreateCmdGroup("Trigger Commands", httptrigger.Commands(), mqtrigger.Commands(), timetrigger.Commands(), kubewatch.Commands()))
groups = append(groups, helptemplate.CreateCmdGroup("Deploy Strategies Commands", canaryconfig.Commands()))
groups = append(groups, helptemplate.CreateCmdGroup("Declarative Application Commands", spec.Commands()))
groups = append(groups, helptemplate.CreateCmdGroup("Other Commands", support.Commands(), version.Commands(), check.Commands()))
groups.Add(rootCmd)
flagExposer := helptemplate.ActsAsRootCommand(rootCmd, nil, groups...)
// show global options in usage
flagExposer.ExposeFlags(rootCmd, flagkey.Server, flagkey.Verbosity, flagkey.KubeContext, flagkey.Namespace)
return rootCmd
}