Use code-generator to generate clientset/informer/lister (#1492)
To reduce maintenance effort and avoid writing duplicate informer code, use code-generator to generate clientset/informer/lister code.
This commit is contained in:
@@ -120,7 +120,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%v'", specDir))
|
||||
}
|
||||
obj := fr.SpecExists(&fv1.Package{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: pkgName,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -129,7 +129,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
return errors.Errorf("please create package %v spec file before referencing it", pkgName)
|
||||
}
|
||||
pkg = obj.(*fv1.Package)
|
||||
pkgMetadata = &pkg.Metadata
|
||||
pkgMetadata = &pkg.ObjectMeta
|
||||
} else {
|
||||
// use existing package
|
||||
pkg, err = opts.Client().V1().Package().Get(&metav1.ObjectMeta{
|
||||
@@ -139,7 +139,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("read package in '%v' in Namespace: %s. Package needs to be present in the same namespace as function", pkgName, fnNamespace))
|
||||
}
|
||||
pkgMetadata = &pkg.Metadata
|
||||
pkgMetadata = &pkg.ObjectMeta
|
||||
}
|
||||
|
||||
envName = pkg.Spec.Environment.Name
|
||||
@@ -161,7 +161,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%v'", specDir))
|
||||
}
|
||||
exists, err := fr.ExistsInSpecs(fv1.Environment{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: envName,
|
||||
Namespace: envNamespace,
|
||||
},
|
||||
@@ -269,7 +269,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
opts.function = &fv1.Function{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fnName,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -314,7 +314,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error creating function")
|
||||
}
|
||||
|
||||
fmt.Printf("function '%v' created\n", opts.function.Metadata.Name)
|
||||
fmt.Printf("function '%v' created\n", opts.function.ObjectMeta.Name)
|
||||
|
||||
// Allow the user to specify an HTTP trigger while creating a function.
|
||||
triggerUrl := input.String(flagkey.HtUrl)
|
||||
@@ -332,16 +332,16 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
|
||||
triggerName := uuid.NewV4().String()
|
||||
ht := &fv1.HTTPTrigger{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: triggerName,
|
||||
Namespace: opts.function.Metadata.Namespace,
|
||||
Namespace: opts.function.ObjectMeta.Namespace,
|
||||
},
|
||||
Spec: fv1.HTTPTriggerSpec{
|
||||
RelativeURL: triggerUrl,
|
||||
Method: method,
|
||||
FunctionReference: fv1.FunctionReference{
|
||||
Type: fv1.FunctionReferenceTypeFunctionName,
|
||||
Name: opts.function.Metadata.Name,
|
||||
Name: opts.function.ObjectMeta.Name,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -350,7 +350,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error creating HTTP trigger")
|
||||
}
|
||||
|
||||
fmt.Printf("route created: %v %v -> %v\n", method, triggerUrl, opts.function.Metadata.Name)
|
||||
fmt.Printf("route created: %v %v -> %v\n", method, triggerUrl, opts.function.ObjectMeta.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func (opts *GetMetaSubCommand) do(input cli.Input) error {
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
fmt.Fprintf(w, "%v\t%v\n", "NAME", "ENV")
|
||||
fmt.Fprintf(w, "%v\t%v\n", fn.Metadata.Name, fn.Spec.Environment.Name)
|
||||
fmt.Fprintf(w, "%v\t%v\n", fn.ObjectMeta.Name, fn.Spec.Environment.Name)
|
||||
w.Flush()
|
||||
|
||||
return nil
|
||||
|
||||
@@ -60,7 +60,7 @@ func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
f.Metadata.Name, f.Spec.Environment.Name,
|
||||
f.ObjectMeta.Name, f.Spec.Environment.Name,
|
||||
f.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType,
|
||||
f.Spec.InvokeStrategy.ExecutionStrategy.MinScale,
|
||||
f.Spec.InvokeStrategy.ExecutionStrategy.MaxScale,
|
||||
|
||||
@@ -80,8 +80,8 @@ func (opts *LogSubCommand) do(input cli.Input) error {
|
||||
case <-requestChan:
|
||||
logFilter := logdb.LogFilter{
|
||||
Pod: fnPod,
|
||||
Function: f.Metadata.Name,
|
||||
FuncUid: string(f.Metadata.UID),
|
||||
Function: f.ObjectMeta.Name,
|
||||
FuncUid: string(f.ObjectMeta.UID),
|
||||
Since: t,
|
||||
Reverse: logReverseQuery,
|
||||
RecordLimit: recordLimit,
|
||||
|
||||
@@ -177,7 +177,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
forceUpdate := input.Bool(flagkey.PkgForce)
|
||||
|
||||
fnList, err := _package.GetFunctionsByPackage(opts.Client(), pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
fnList, err := _package.GetFunctionsByPackage(opts.Client(), pkg.ObjectMeta.Name, pkg.ObjectMeta.Namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function list")
|
||||
}
|
||||
@@ -194,12 +194,12 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
// the package resource version of function has been changed,
|
||||
// we need to update function resource version to prevent conflict.
|
||||
// TODO: remove this block when deprecating pkg flags of function command.
|
||||
if pkg.Metadata.ResourceVersion != newPkgMeta.ResourceVersion {
|
||||
if pkg.ObjectMeta.ResourceVersion != newPkgMeta.ResourceVersion {
|
||||
var fns []fv1.Function
|
||||
// don't update the package resource version of the function we are currently
|
||||
// updating to prevent update conflict.
|
||||
for _, fn := range fnList {
|
||||
if fn.Metadata.UID != function.Metadata.UID {
|
||||
if fn.ObjectMeta.UID != function.ObjectMeta.UID {
|
||||
fns = append(fns, fn)
|
||||
}
|
||||
}
|
||||
@@ -236,6 +236,6 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error updating function")
|
||||
}
|
||||
|
||||
fmt.Printf("Function '%v' updated\n", opts.function.Metadata.Name)
|
||||
fmt.Printf("Function '%v' updated\n", opts.function.ObjectMeta.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user