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:
@@ -100,7 +100,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
// finally create canaryCfg in the same namespace as the functions referenced
|
||||
opts.canary = &fv1.CanaryConfig{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: fnNs,
|
||||
},
|
||||
@@ -127,6 +127,6 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error creating canary config")
|
||||
}
|
||||
|
||||
fmt.Printf("canary config '%v' created\n", opts.canary.Metadata.Name)
|
||||
fmt.Printf("canary config '%v' created\n", opts.canary.ObjectMeta.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func (opts *GetSubCommand) run(input cli.Input) error {
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", "NAME", "TRIGGER", "FUNCTION-N", "FUNCTION-N-1", "WEIGHT-INCREMENT", "INTERVAL", "FAILURE-THRESHOLD", "FAILURE-TYPE", "STATUS")
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
canaryCfg.Metadata.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.NewFunction, canaryCfg.Spec.OldFunction, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.ObjectMeta.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.NewFunction, canaryCfg.Spec.OldFunction, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.Spec.FailureThreshold, canaryCfg.Spec.FailureType, canaryCfg.Status.Status)
|
||||
|
||||
w.Flush()
|
||||
|
||||
@@ -60,7 +60,7 @@ func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", "NAME", "TRIGGER", "FUNCTION-N", "FUNCTION-N-1", "WEIGHT-INCREMENT", "INTERVAL", "FAILURE-THRESHOLD", "FAILURE-TYPE", "STATUS")
|
||||
for _, canaryCfg := range canaryCfgs {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
canaryCfg.Metadata.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.NewFunction, canaryCfg.Spec.OldFunction, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.ObjectMeta.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.NewFunction, canaryCfg.Spec.OldFunction, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.Spec.FailureThreshold, canaryCfg.Spec.FailureType, canaryCfg.Status.Status)
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,6 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating canary config")
|
||||
}
|
||||
fmt.Printf("canary config '%v' updated\n", opts.canary.Metadata.Name)
|
||||
fmt.Printf("canary config '%v' updated\n", opts.canary.ObjectMeta.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
// run write the resource to a spec file or create a fission CRD with remote fission server.
|
||||
// It also prints warning/error if necessary.
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
m := opts.env.Metadata
|
||||
m := opts.env.ObjectMeta
|
||||
|
||||
envList, err := opts.Client().V1().Environment().List(m.Namespace)
|
||||
if err != nil {
|
||||
@@ -145,7 +145,7 @@ func createEnvironmentFromCmd(input cli.Input) (*fv1.Environment, error) {
|
||||
Kind: fv1.CRD_NAME_ENVIRONMENT,
|
||||
APIVersion: fv1.CRD_VERSION,
|
||||
},
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: envName,
|
||||
Namespace: envNamespace,
|
||||
},
|
||||
|
||||
@@ -52,7 +52,7 @@ func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
|
||||
fmt.Fprintf(w, "%v\t%v\n", "NAME", "IMAGE")
|
||||
fmt.Fprintf(w, "%v\t%v\n",
|
||||
env.Metadata.Name, env.Spec.Runtime.Image)
|
||||
env.ObjectMeta.Name, env.Spec.Runtime.Image)
|
||||
|
||||
w.Flush()
|
||||
return nil
|
||||
|
||||
@@ -46,7 +46,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\n", "NAME", "IMAGE", "BUILDER_IMAGE", "POOLSIZE", "MINCPU", "MAXCPU", "MINMEMORY", "MAXMEMORY", "EXTNET", "GRACETIME")
|
||||
for _, env := range envs {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
env.Metadata.Name, env.Spec.Runtime.Image, env.Spec.Builder.Image, env.Spec.Poolsize,
|
||||
env.ObjectMeta.Name, env.Spec.Runtime.Image, env.Spec.Builder.Image, env.Spec.Poolsize,
|
||||
env.Spec.Resources.Requests.Cpu(), env.Spec.Resources.Limits.Cpu(),
|
||||
env.Spec.Resources.Requests.Memory(), env.Spec.Resources.Limits.Memory(),
|
||||
env.Spec.AllowAccessToExternalNetwork, env.Spec.TerminationGracePeriod)
|
||||
|
||||
@@ -71,7 +71,7 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error updating environment")
|
||||
}
|
||||
|
||||
fmt.Printf("environment '%v' updated\n", opts.env.Metadata.Name)
|
||||
fmt.Printf("environment '%v' updated\n", opts.env.ObjectMeta.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
for _, fn := range functionList {
|
||||
exists, err := fr.ExistsInSpecs(fv1.Function{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fn,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -138,7 +138,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
host := input.String(flagkey.HtHost)
|
||||
|
||||
opts.trigger = &fv1.HTTPTrigger{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: triggerName,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -158,7 +158,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
// if we're writing a spec, don't call the API
|
||||
if input.Bool(flagkey.SpecSave) {
|
||||
specFile := fmt.Sprintf("route-%v.yaml", opts.trigger.Metadata.Name)
|
||||
specFile := fmt.Sprintf("route-%v.yaml", opts.trigger.ObjectMeta.Name)
|
||||
err := spec.SpecSave(*opts.trigger, specFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating HTTP trigger spec")
|
||||
@@ -171,7 +171,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "create HTTP trigger")
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' created\n", opts.trigger.Metadata.Name)
|
||||
fmt.Printf("trigger '%v' created\n", opts.trigger.ObjectMeta.Name)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
for _, trigger := range triggers {
|
||||
// TODO: delete canary http triggers as well.
|
||||
if trigger.Spec.FunctionReference.Name == opts.functionName {
|
||||
triggersToDelete = append(triggersToDelete, trigger.Metadata.Name)
|
||||
triggersToDelete = append(triggersToDelete, trigger.ObjectMeta.Name)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -87,7 +87,7 @@ func printHtSummary(triggers []fv1.HTTPTrigger) {
|
||||
ann := strings.Join(msg, ", ")
|
||||
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
trigger.Metadata.Name, trigger.Spec.Method, trigger.Spec.RelativeURL, function, trigger.Spec.CreateIngress, host, path, trigger.Spec.IngressConfig.TLS, ann)
|
||||
trigger.ObjectMeta.Name, trigger.Spec.Method, trigger.Spec.RelativeURL, function, trigger.Spec.CreateIngress, host, path, trigger.Spec.IngressConfig.TLS, ann)
|
||||
}
|
||||
w.Flush()
|
||||
}
|
||||
|
||||
@@ -117,6 +117,6 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating the HTTP trigger")
|
||||
}
|
||||
fmt.Printf("trigger '%v' updated\n", opts.trigger.Metadata.Name)
|
||||
fmt.Printf("trigger '%v' updated\n", opts.trigger.ObjectMeta.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
exists, err := fr.ExistsInSpecs(fv1.Function{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fnName,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -83,7 +83,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
opts.watcher = &fv1.KubernetesWatchTrigger{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: watchName,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -104,7 +104,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
// if we're writing a spec, don't call the API
|
||||
if input.Bool(flagkey.SpecSave) {
|
||||
specFile := fmt.Sprintf("kubewatch-%v.yaml", opts.watcher.Metadata.Name)
|
||||
specFile := fmt.Sprintf("kubewatch-%v.yaml", opts.watcher.ObjectMeta.Name)
|
||||
err := spec.SpecSave(*opts.watcher, specFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating kubewatch spec")
|
||||
@@ -117,6 +117,6 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error creating kubewatch")
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' created\n", opts.watcher.Metadata.Name)
|
||||
fmt.Printf("trigger '%v' created\n", opts.watcher.ObjectMeta.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
"NAME", "NAMESPACE", "OBJTYPE", "LABELS", "FUNCTION_NAME")
|
||||
for _, wa := range ws {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n",
|
||||
wa.Metadata.Name, wa.Spec.Namespace, wa.Spec.Type, wa.Spec.LabelSelector, wa.Spec.FunctionReference.Name)
|
||||
wa.ObjectMeta.Name, wa.Spec.Namespace, wa.Spec.Type, wa.Spec.LabelSelector, wa.Spec.FunctionReference.Name)
|
||||
}
|
||||
w.Flush()
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
exists, err := fr.ExistsInSpecs(fv1.Function{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fnName,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -125,7 +125,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
opts.trigger = &fv1.MessageQueueTrigger{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: mqtName,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -149,7 +149,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
// if we're writing a spec, don't call the API
|
||||
if input.Bool(flagkey.SpecSave) {
|
||||
specFile := fmt.Sprintf("mqtrigger-%v.yaml", opts.trigger.Metadata.Name)
|
||||
specFile := fmt.Sprintf("mqtrigger-%v.yaml", opts.trigger.ObjectMeta.Name)
|
||||
err := spec.SpecSave(*opts.trigger, specFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating message queue trigger spec")
|
||||
@@ -162,7 +162,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "create message queue trigger")
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%s' created\n", opts.trigger.Metadata.Name)
|
||||
fmt.Printf("trigger '%s' created\n", opts.trigger.ObjectMeta.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
"NAME", "FUNCTION_NAME", "MESSAGE_QUEUE_TYPE", "TOPIC", "RESPONSE_TOPIC", "ERROR_TOPIC", "MAX_RETRIES", "PUB_MSG_CONTENT_TYPE")
|
||||
for _, mqt := range mqts {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
mqt.Metadata.Name, mqt.Spec.FunctionReference.Name, mqt.Spec.MessageQueueType, mqt.Spec.Topic, mqt.Spec.ResponseTopic, mqt.Spec.ErrorTopic, mqt.Spec.MaxRetries, mqt.Spec.ContentType)
|
||||
mqt.ObjectMeta.Name, mqt.Spec.FunctionReference.Name, mqt.Spec.MessageQueueType, mqt.Spec.Topic, mqt.Spec.ResponseTopic, mqt.Spec.ErrorTopic, mqt.Spec.MaxRetries, mqt.Spec.ContentType)
|
||||
}
|
||||
w.Flush()
|
||||
|
||||
|
||||
@@ -108,6 +108,6 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error updating message queue trigger")
|
||||
}
|
||||
|
||||
fmt.Printf("message queue trigger '%v' updated\n", opts.trigger.Metadata.Name)
|
||||
fmt.Printf("message queue trigger '%v' updated\n", opts.trigger.ObjectMeta.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ func (opts *CreateSubCommand) run(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,
|
||||
},
|
||||
@@ -164,14 +164,14 @@ func CreatePackage(input cli.Input, client client.Interface, pkgName string, pkg
|
||||
}
|
||||
|
||||
pkg := &fv1.Package{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: pkgName,
|
||||
Namespace: pkgNamespace,
|
||||
},
|
||||
Spec: pkgSpec,
|
||||
Status: fv1.PackageStatus{
|
||||
BuildStatus: pkgStatus,
|
||||
LastUpdateTimestamp: time.Now().UTC(),
|
||||
LastUpdateTimestamp: metav1.Time{Time: time.Now().UTC()},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -185,15 +185,15 @@ func CreatePackage(input cli.Input, client client.Interface, pkgName string, pkg
|
||||
obj := fr.SpecExists(pkg, true, true)
|
||||
if obj != nil {
|
||||
pkg := obj.(*fv1.Package)
|
||||
fmt.Printf("Re-using previously created package %v\n", pkg.Metadata.Name)
|
||||
return &pkg.Metadata, nil
|
||||
fmt.Printf("Re-using previously created package %v\n", pkg.ObjectMeta.Name)
|
||||
return &pkg.ObjectMeta, nil
|
||||
}
|
||||
|
||||
err = spec.SpecSave(*pkg, specFile)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error saving package spec")
|
||||
}
|
||||
return &pkg.Metadata, nil
|
||||
return &pkg.ObjectMeta, nil
|
||||
} else {
|
||||
pkgMetadata, err := client.V1().Package().Create(pkg)
|
||||
if err != nil {
|
||||
|
||||
@@ -106,12 +106,12 @@ func deleteOrphanPkgs(client client.Interface, pkgNamespace string) error {
|
||||
|
||||
// range through all packages and find out the ones not referenced by any function
|
||||
for _, pkg := range pkgList {
|
||||
fnList, err := GetFunctionsByPackage(client, pkg.Metadata.Name, pkgNamespace)
|
||||
fnList, err := GetFunctionsByPackage(client, pkg.ObjectMeta.Name, pkgNamespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("get functions sharing package %s", pkg.Metadata.Name))
|
||||
return errors.Wrap(err, fmt.Sprintf("get functions sharing package %s", pkg.ObjectMeta.Name))
|
||||
}
|
||||
if len(fnList) == 0 {
|
||||
err = deletePackage(client, pkg.Metadata.Name, pkgNamespace)
|
||||
err = deletePackage(client, pkg.ObjectMeta.Name, pkgNamespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
|
||||
// sort the package list by lastUpdatedTimestamp
|
||||
sort.Slice(pkgList, func(i, j int) bool {
|
||||
return pkgList[i].Status.LastUpdateTimestamp.After(pkgList[j].Status.LastUpdateTimestamp)
|
||||
return pkgList[i].Status.LastUpdateTimestamp.After(pkgList[j].Status.LastUpdateTimestamp.Time)
|
||||
})
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
@@ -75,9 +75,9 @@ func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
show := true
|
||||
// TODO improve list speed when --orphan
|
||||
if opts.listOrphans {
|
||||
fnList, err := GetFunctionsByPackage(opts.Client(), pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
fnList, err := GetFunctionsByPackage(opts.Client(), pkg.ObjectMeta.Name, pkg.ObjectMeta.Namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("get functions sharing package %s", pkg.Metadata.Name))
|
||||
return errors.Wrap(err, fmt.Sprintf("get functions sharing package %s", pkg.ObjectMeta.Name))
|
||||
}
|
||||
if len(fnList) > 0 {
|
||||
show = false
|
||||
@@ -87,7 +87,7 @@ func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
show = false
|
||||
}
|
||||
if show {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", pkg.Metadata.Name, pkg.Status.BuildStatus, pkg.Spec.Environment.Name, pkg.Status.LastUpdateTimestamp.Format(time.RFC822))
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", pkg.ObjectMeta.Name, pkg.Status.BuildStatus, pkg.Spec.Environment.Name, pkg.Status.LastUpdateTimestamp.Format(time.RFC822))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ func (opts *RebuildSubCommand) run(input cli.Input) error {
|
||||
|
||||
if pkg.Status.BuildStatus != fv1.BuildStatusFailed {
|
||||
return errors.New(fmt.Sprintf("Package %v is not in %v state.",
|
||||
pkg.Metadata.Name, fv1.BuildStatusFailed))
|
||||
pkg.ObjectMeta.Name, fv1.BuildStatusFailed))
|
||||
}
|
||||
|
||||
_, err = updatePackageStatus(opts.Client(), pkg, fv1.BuildStatusPending)
|
||||
@@ -71,7 +71,7 @@ func (opts *RebuildSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "update package status")
|
||||
}
|
||||
|
||||
fmt.Printf("Retrying build for pkg %v. Use \"fission pkg info --name %v\" to view status.\n", pkg.Metadata.Name, pkg.Metadata.Name)
|
||||
fmt.Printf("Retrying build for pkg %v. Use \"fission pkg info --name %v\" to view status.\n", pkg.ObjectMeta.Name, pkg.ObjectMeta.Name)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
|
||||
forceUpdate := input.Bool(flagkey.PkgForce)
|
||||
|
||||
fnList, err := GetFunctionsByPackage(opts.Client(), pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
fnList, err := GetFunctionsByPackage(opts.Client(), pkg.ObjectMeta.Name, pkg.ObjectMeta.Namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function list")
|
||||
}
|
||||
@@ -82,7 +82,7 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error updating package")
|
||||
}
|
||||
|
||||
if pkg.Metadata.ResourceVersion != newPkgMeta.ResourceVersion {
|
||||
if pkg.ObjectMeta.ResourceVersion != newPkgMeta.ResourceVersion {
|
||||
err = UpdateFunctionPackageResourceVersion(opts.Client(), newPkgMeta, fnList...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating function package reference resource version")
|
||||
@@ -166,7 +166,7 @@ func UpdatePackage(input cli.Input, client client.Interface, pkg *fv1.Package) (
|
||||
}
|
||||
|
||||
if !needToUpdate {
|
||||
return &pkg.Metadata, nil
|
||||
return &pkg.ObjectMeta, nil
|
||||
}
|
||||
|
||||
// Set package as pending status when needToBuild is true
|
||||
@@ -174,7 +174,7 @@ func UpdatePackage(input cli.Input, client client.Interface, pkg *fv1.Package) (
|
||||
// change into pending state to trigger package build
|
||||
pkg.Status = fv1.PackageStatus{
|
||||
BuildStatus: fv1.BuildStatusPending,
|
||||
LastUpdateTimestamp: time.Now().UTC(),
|
||||
LastUpdateTimestamp: metav1.Time{Time: time.Now().UTC()},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ func UpdateFunctionPackageResourceVersion(client client.Interface, pkgMeta *meta
|
||||
fn.Spec.Package.PackageRef.ResourceVersion = pkgMeta.ResourceVersion
|
||||
_, err := client.V1().Function().Update(&fn)
|
||||
if err != nil {
|
||||
errs = multierror.Append(errs, errors.Wrapf(err, "error updating package resource version of function '%v'", fn.Metadata.Name))
|
||||
errs = multierror.Append(errs, errors.Wrapf(err, "error updating package resource version of function '%v'", fn.ObjectMeta.Name))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func updatePackageStatus(client client.Interface, pkg *fv1.Package, status fv1.B
|
||||
case fv1.BuildStatusNone, fv1.BuildStatusPending, fv1.BuildStatusRunning, fv1.BuildStatusSucceeded, fv1.CanaryConfigStatusAborted:
|
||||
pkg.Status = fv1.PackageStatus{
|
||||
BuildStatus: status,
|
||||
LastUpdateTimestamp: time.Now().UTC(),
|
||||
LastUpdateTimestamp: metav1.Time{Time: time.Now().UTC()},
|
||||
}
|
||||
pkg, err := client.V1().Package().Update(pkg)
|
||||
return pkg, err
|
||||
|
||||
@@ -182,7 +182,7 @@ func PrintPackageSummary(writer io.Writer, pkg *fv1.Package) {
|
||||
// replace escaped line breaker character
|
||||
buildlog := strings.ReplaceAll(pkg.Status.BuildLog, `\n`, "\n")
|
||||
w := tabwriter.NewWriter(writer, 0, 0, 1, ' ', 0)
|
||||
fmt.Fprintf(w, "%v\t%v\n", "Name:", pkg.Metadata.Name)
|
||||
fmt.Fprintf(w, "%v\t%v\n", "Name:", pkg.ObjectMeta.Name)
|
||||
fmt.Fprintf(w, "%v\t%v\n", "Environment:", pkg.Spec.Environment.Name)
|
||||
fmt.Fprintf(w, "%v\t%v\n", "Status:", pkg.Status.BuildStatus)
|
||||
fmt.Fprintf(w, "%v\n%v", "Build Logs:", buildlog)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func TestPrintPackageSummary(t *testing.T) {
|
||||
|
||||
pkg := &fv1.Package{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foobar",
|
||||
Namespace: "dummy",
|
||||
},
|
||||
|
||||
@@ -367,7 +367,7 @@ func applyResources(fclient client.Interface, specDir string, fr *FissionResourc
|
||||
// that as an error, so that we encourage self-contained specs.
|
||||
// Is there a good use case for non-self contained specs?
|
||||
return nil, nil, errors.Errorf("function %v/%v references package %v/%v, which doesn't exist in the specs",
|
||||
f.Metadata.Namespace, f.Metadata.Name, f.Spec.Package.PackageRef.Namespace, f.Spec.Package.PackageRef.Name)
|
||||
f.ObjectMeta.Namespace, f.ObjectMeta.Name, f.Spec.Package.PackageRef.Namespace, f.Spec.Package.PackageRef.Name)
|
||||
}
|
||||
fr.Functions[i].Spec.Package.PackageRef.ResourceVersion = m.ResourceVersion
|
||||
}
|
||||
@@ -532,14 +532,14 @@ func waitForPackageBuild(fclient client.Interface, pkg *fv1.Package) (*fv1.Packa
|
||||
return pkg, nil
|
||||
}
|
||||
if time.Since(start) > 5*time.Minute {
|
||||
return nil, errors.Errorf("package %v has been building for a while, giving up on waiting for it", pkg.Metadata.Name)
|
||||
return nil, errors.Errorf("package %v has been building for a while, giving up on waiting for it", pkg.ObjectMeta.Name)
|
||||
}
|
||||
|
||||
// TODO watch instead
|
||||
time.Sleep(time.Second)
|
||||
|
||||
var err error
|
||||
pkg, err = fclient.V1().Package().Get(&pkg.Metadata)
|
||||
pkg, err = fclient.V1().Package().Get(&pkg.ObjectMeta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -556,7 +556,7 @@ func applyPackages(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
// filter
|
||||
objs := make([]fv1.Package, 0)
|
||||
for _, o := range allObjs {
|
||||
if hasDeploymentConfig(&o.Metadata, fr) {
|
||||
if hasDeploymentConfig(&o.ObjectMeta, fr) {
|
||||
objs = append(objs, o)
|
||||
}
|
||||
}
|
||||
@@ -564,7 +564,7 @@ func applyPackages(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
// index
|
||||
existent := make(map[string]fv1.Package)
|
||||
for _, obj := range objs {
|
||||
existent[mapKey(&obj.Metadata)] = obj
|
||||
existent[mapKey(&obj.ObjectMeta)] = obj
|
||||
}
|
||||
metadataMap := make(map[string]metav1.ObjectMeta)
|
||||
|
||||
@@ -576,13 +576,13 @@ func applyPackages(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
// create or update desired state
|
||||
for _, o := range fr.Packages {
|
||||
// apply deploymentConfig so we can find our objects on future apply invocations
|
||||
applyDeploymentConfig(&o.Metadata, fr)
|
||||
applyDeploymentConfig(&o.ObjectMeta, fr)
|
||||
|
||||
// index desired state
|
||||
desired[mapKey(&o.Metadata)] = true
|
||||
desired[mapKey(&o.ObjectMeta)] = true
|
||||
|
||||
// exists?
|
||||
existingObj, ok := existent[mapKey(&o.Metadata)]
|
||||
existingObj, ok := existent[mapKey(&o.ObjectMeta)]
|
||||
if ok {
|
||||
// ok, a resource with the same name exists, is it the same?
|
||||
keep := false
|
||||
@@ -598,10 +598,10 @@ func applyPackages(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
|
||||
if keep && existingObj.Status.BuildStatus == fv1.BuildStatusSucceeded {
|
||||
// nothing to do on the server
|
||||
metadataMap[mapKey(&o.Metadata)] = existingObj.Metadata
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = existingObj.ObjectMeta
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
o.ObjectMeta.ResourceVersion = existingObj.ObjectMeta.ResourceVersion
|
||||
|
||||
// We may be racing against the package builder to update the
|
||||
// package (a previous version might have been getting built). So,
|
||||
@@ -609,7 +609,7 @@ func applyPackages(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
pkg, err := waitForPackageBuild(fclient, &o)
|
||||
if err != nil {
|
||||
// log and ignore
|
||||
console.Warn(fmt.Sprintf("Error waiting for package '%v' build, ignoring", o.Metadata.Name))
|
||||
console.Warn(fmt.Sprintf("Error waiting for package '%v' build, ignoring", o.ObjectMeta.Name))
|
||||
pkg = &o
|
||||
}
|
||||
|
||||
@@ -625,7 +625,7 @@ func applyPackages(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
}
|
||||
ras.Updated = append(ras.Updated, newmeta)
|
||||
// keep track of metadata in case we need to create a reference to it
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
@@ -634,7 +634,7 @@ func applyPackages(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Created = append(ras.Created, newmeta)
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,14 +642,14 @@ func applyPackages(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
if delete {
|
||||
// objs is already filtered with our UID
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
_, wanted := desired[mapKey(&o.ObjectMeta)]
|
||||
if !wanted {
|
||||
err := fclient.V1().Package().Delete(&o.Metadata)
|
||||
err := fclient.V1().Package().Delete(&o.ObjectMeta)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Deleted = append(ras.Deleted, &o.Metadata)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.Metadata.Namespace, o.Metadata.Name)
|
||||
ras.Deleted = append(ras.Deleted, &o.ObjectMeta)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.ObjectMeta.Namespace, o.ObjectMeta.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -667,7 +667,7 @@ func applyFunctions(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
// filter
|
||||
objs := make([]fv1.Function, 0)
|
||||
for _, o := range allObjs {
|
||||
if hasDeploymentConfig(&o.Metadata, fr) {
|
||||
if hasDeploymentConfig(&o.ObjectMeta, fr) {
|
||||
objs = append(objs, o)
|
||||
}
|
||||
}
|
||||
@@ -675,7 +675,7 @@ func applyFunctions(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
// index
|
||||
existent := make(map[string]fv1.Function)
|
||||
for _, obj := range objs {
|
||||
existent[mapKey(&obj.Metadata)] = obj
|
||||
existent[mapKey(&obj.ObjectMeta)] = obj
|
||||
}
|
||||
metadataMap := make(map[string]metav1.ObjectMeta)
|
||||
|
||||
@@ -687,28 +687,28 @@ func applyFunctions(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
// create or update desired state
|
||||
for _, o := range fr.Functions {
|
||||
// apply deploymentConfig so we can find our objects on future apply invocations
|
||||
applyDeploymentConfig(&o.Metadata, fr)
|
||||
applyDeploymentConfig(&o.ObjectMeta, fr)
|
||||
|
||||
// index desired state
|
||||
desired[mapKey(&o.Metadata)] = true
|
||||
desired[mapKey(&o.ObjectMeta)] = true
|
||||
|
||||
// exists?
|
||||
existingObj, ok := existent[mapKey(&o.Metadata)]
|
||||
existingObj, ok := existent[mapKey(&o.ObjectMeta)]
|
||||
if ok {
|
||||
// ok, a resource with the same name exists, is it the same?
|
||||
if reflect.DeepEqual(existingObj.Spec, o.Spec) {
|
||||
// nothing to do on the server
|
||||
metadataMap[mapKey(&o.Metadata)] = existingObj.Metadata
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = existingObj.ObjectMeta
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
o.ObjectMeta.ResourceVersion = existingObj.ObjectMeta.ResourceVersion
|
||||
newmeta, err := fclient.V1().Function().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Updated = append(ras.Updated, newmeta)
|
||||
// keep track of metadata in case we need to create a reference to it
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
@@ -717,7 +717,7 @@ func applyFunctions(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Created = append(ras.Created, newmeta)
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,14 +725,14 @@ func applyFunctions(fclient client.Interface, fr *FissionResources, delete bool)
|
||||
if delete {
|
||||
// objs is already filtered with our UID
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
_, wanted := desired[mapKey(&o.ObjectMeta)]
|
||||
if !wanted {
|
||||
err := fclient.V1().Function().Delete(&o.Metadata)
|
||||
err := fclient.V1().Function().Delete(&o.ObjectMeta)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Deleted = append(ras.Deleted, &o.Metadata)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.Metadata.Namespace, o.Metadata.Name)
|
||||
ras.Deleted = append(ras.Deleted, &o.ObjectMeta)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.ObjectMeta.Namespace, o.ObjectMeta.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -750,7 +750,7 @@ func applyEnvironments(fclient client.Interface, fr *FissionResources, delete bo
|
||||
// filter
|
||||
objs := make([]fv1.Environment, 0)
|
||||
for _, o := range allObjs {
|
||||
if hasDeploymentConfig(&o.Metadata, fr) {
|
||||
if hasDeploymentConfig(&o.ObjectMeta, fr) {
|
||||
objs = append(objs, o)
|
||||
}
|
||||
}
|
||||
@@ -758,7 +758,7 @@ func applyEnvironments(fclient client.Interface, fr *FissionResources, delete bo
|
||||
// index
|
||||
existent := make(map[string]fv1.Environment)
|
||||
for _, obj := range objs {
|
||||
existent[mapKey(&obj.Metadata)] = obj
|
||||
existent[mapKey(&obj.ObjectMeta)] = obj
|
||||
}
|
||||
metadataMap := make(map[string]metav1.ObjectMeta)
|
||||
|
||||
@@ -770,28 +770,28 @@ func applyEnvironments(fclient client.Interface, fr *FissionResources, delete bo
|
||||
// create or update desired state
|
||||
for _, o := range fr.Environments {
|
||||
// apply deploymentConfig so we can find our objects on future apply invocations
|
||||
applyDeploymentConfig(&o.Metadata, fr)
|
||||
applyDeploymentConfig(&o.ObjectMeta, fr)
|
||||
|
||||
// index desired state
|
||||
desired[mapKey(&o.Metadata)] = true
|
||||
desired[mapKey(&o.ObjectMeta)] = true
|
||||
|
||||
// exists?
|
||||
existingObj, ok := existent[mapKey(&o.Metadata)]
|
||||
existingObj, ok := existent[mapKey(&o.ObjectMeta)]
|
||||
if ok {
|
||||
// ok, a resource with the same name exists, is it the same?
|
||||
if reflect.DeepEqual(existingObj.Spec, o.Spec) {
|
||||
// nothing to do on the server
|
||||
metadataMap[mapKey(&o.Metadata)] = existingObj.Metadata
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = existingObj.ObjectMeta
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
o.ObjectMeta.ResourceVersion = existingObj.ObjectMeta.ResourceVersion
|
||||
newmeta, err := fclient.V1().Environment().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Updated = append(ras.Updated, newmeta)
|
||||
// keep track of metadata in case we need to create a reference to it
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
@@ -800,7 +800,7 @@ func applyEnvironments(fclient client.Interface, fr *FissionResources, delete bo
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Created = append(ras.Created, newmeta)
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,14 +808,14 @@ func applyEnvironments(fclient client.Interface, fr *FissionResources, delete bo
|
||||
if delete {
|
||||
// objs is already filtered with our UID
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
_, wanted := desired[mapKey(&o.ObjectMeta)]
|
||||
if !wanted {
|
||||
err := fclient.V1().Environment().Delete(&o.Metadata)
|
||||
err := fclient.V1().Environment().Delete(&o.ObjectMeta)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Deleted = append(ras.Deleted, &o.Metadata)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.Metadata.Namespace, o.Metadata.Name)
|
||||
ras.Deleted = append(ras.Deleted, &o.ObjectMeta)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.ObjectMeta.Namespace, o.ObjectMeta.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -833,7 +833,7 @@ func applyHTTPTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
// filter
|
||||
objs := make([]fv1.HTTPTrigger, 0)
|
||||
for _, o := range allObjs {
|
||||
if hasDeploymentConfig(&o.Metadata, fr) {
|
||||
if hasDeploymentConfig(&o.ObjectMeta, fr) {
|
||||
objs = append(objs, o)
|
||||
}
|
||||
}
|
||||
@@ -841,7 +841,7 @@ func applyHTTPTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
// index
|
||||
existent := make(map[string]fv1.HTTPTrigger)
|
||||
for _, obj := range objs {
|
||||
existent[mapKey(&obj.Metadata)] = obj
|
||||
existent[mapKey(&obj.ObjectMeta)] = obj
|
||||
}
|
||||
metadataMap := make(map[string]metav1.ObjectMeta)
|
||||
|
||||
@@ -853,28 +853,28 @@ func applyHTTPTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
// create or update desired state
|
||||
for _, o := range fr.HttpTriggers {
|
||||
// apply deploymentConfig so we can find our objects on future apply invocations
|
||||
applyDeploymentConfig(&o.Metadata, fr)
|
||||
applyDeploymentConfig(&o.ObjectMeta, fr)
|
||||
|
||||
// index desired state
|
||||
desired[mapKey(&o.Metadata)] = true
|
||||
desired[mapKey(&o.ObjectMeta)] = true
|
||||
|
||||
// exists?
|
||||
existingObj, ok := existent[mapKey(&o.Metadata)]
|
||||
existingObj, ok := existent[mapKey(&o.ObjectMeta)]
|
||||
if ok {
|
||||
// ok, a resource with the same name exists, is it the same?
|
||||
if reflect.DeepEqual(existingObj.Spec, o.Spec) {
|
||||
// nothing to do on the server
|
||||
metadataMap[mapKey(&o.Metadata)] = existingObj.Metadata
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = existingObj.ObjectMeta
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
o.ObjectMeta.ResourceVersion = existingObj.ObjectMeta.ResourceVersion
|
||||
newmeta, err := fclient.V1().HTTPTrigger().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Updated = append(ras.Updated, newmeta)
|
||||
// keep track of metadata in case we need to create a reference to it
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
@@ -883,7 +883,7 @@ func applyHTTPTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Created = append(ras.Created, newmeta)
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,14 +891,14 @@ func applyHTTPTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
if delete {
|
||||
// objs is already filtered with our UID
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
_, wanted := desired[mapKey(&o.ObjectMeta)]
|
||||
if !wanted {
|
||||
err := fclient.V1().HTTPTrigger().Delete(&o.Metadata)
|
||||
err := fclient.V1().HTTPTrigger().Delete(&o.ObjectMeta)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Deleted = append(ras.Deleted, &o.Metadata)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.Metadata.Namespace, o.Metadata.Name)
|
||||
ras.Deleted = append(ras.Deleted, &o.ObjectMeta)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.ObjectMeta.Namespace, o.ObjectMeta.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -916,7 +916,7 @@ func applyKubernetesWatchTriggers(fclient client.Interface, fr *FissionResources
|
||||
// filter
|
||||
objs := make([]fv1.KubernetesWatchTrigger, 0)
|
||||
for _, o := range allObjs {
|
||||
if hasDeploymentConfig(&o.Metadata, fr) {
|
||||
if hasDeploymentConfig(&o.ObjectMeta, fr) {
|
||||
objs = append(objs, o)
|
||||
}
|
||||
}
|
||||
@@ -924,7 +924,7 @@ func applyKubernetesWatchTriggers(fclient client.Interface, fr *FissionResources
|
||||
// index
|
||||
existent := make(map[string]fv1.KubernetesWatchTrigger)
|
||||
for _, obj := range objs {
|
||||
existent[mapKey(&obj.Metadata)] = obj
|
||||
existent[mapKey(&obj.ObjectMeta)] = obj
|
||||
}
|
||||
metadataMap := make(map[string]metav1.ObjectMeta)
|
||||
|
||||
@@ -936,28 +936,28 @@ func applyKubernetesWatchTriggers(fclient client.Interface, fr *FissionResources
|
||||
// create or update desired state
|
||||
for _, o := range fr.KubernetesWatchTriggers {
|
||||
// apply deploymentConfig so we can find our objects on future apply invocations
|
||||
applyDeploymentConfig(&o.Metadata, fr)
|
||||
applyDeploymentConfig(&o.ObjectMeta, fr)
|
||||
|
||||
// index desired state
|
||||
desired[mapKey(&o.Metadata)] = true
|
||||
desired[mapKey(&o.ObjectMeta)] = true
|
||||
|
||||
// exists?
|
||||
existingObj, ok := existent[mapKey(&o.Metadata)]
|
||||
existingObj, ok := existent[mapKey(&o.ObjectMeta)]
|
||||
if ok {
|
||||
// ok, a resource with the same name exists, is it the same?
|
||||
if reflect.DeepEqual(existingObj.Spec, o.Spec) {
|
||||
// nothing to do on the server
|
||||
metadataMap[mapKey(&o.Metadata)] = existingObj.Metadata
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = existingObj.ObjectMeta
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
o.ObjectMeta.ResourceVersion = existingObj.ObjectMeta.ResourceVersion
|
||||
newmeta, err := fclient.V1().KubeWatcher().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Updated = append(ras.Updated, newmeta)
|
||||
// keep track of metadata in case we need to create a reference to it
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
@@ -966,7 +966,7 @@ func applyKubernetesWatchTriggers(fclient client.Interface, fr *FissionResources
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Created = append(ras.Created, newmeta)
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
}
|
||||
|
||||
@@ -974,14 +974,14 @@ func applyKubernetesWatchTriggers(fclient client.Interface, fr *FissionResources
|
||||
if delete {
|
||||
// objs is already filtered with our UID
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
_, wanted := desired[mapKey(&o.ObjectMeta)]
|
||||
if !wanted {
|
||||
err := fclient.V1().KubeWatcher().Delete(&o.Metadata)
|
||||
err := fclient.V1().KubeWatcher().Delete(&o.ObjectMeta)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Deleted = append(ras.Deleted, &o.Metadata)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.Metadata.Namespace, o.Metadata.Name)
|
||||
ras.Deleted = append(ras.Deleted, &o.ObjectMeta)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.ObjectMeta.Namespace, o.ObjectMeta.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -999,7 +999,7 @@ func applyTimeTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
// filter
|
||||
objs := make([]fv1.TimeTrigger, 0)
|
||||
for _, o := range allObjs {
|
||||
if hasDeploymentConfig(&o.Metadata, fr) {
|
||||
if hasDeploymentConfig(&o.ObjectMeta, fr) {
|
||||
objs = append(objs, o)
|
||||
}
|
||||
}
|
||||
@@ -1007,7 +1007,7 @@ func applyTimeTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
// index
|
||||
existent := make(map[string]fv1.TimeTrigger)
|
||||
for _, obj := range objs {
|
||||
existent[mapKey(&obj.Metadata)] = obj
|
||||
existent[mapKey(&obj.ObjectMeta)] = obj
|
||||
}
|
||||
metadataMap := make(map[string]metav1.ObjectMeta)
|
||||
|
||||
@@ -1019,28 +1019,28 @@ func applyTimeTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
// create or update desired state
|
||||
for _, o := range fr.TimeTriggers {
|
||||
// apply deploymentConfig so we can find our objects on future apply invocations
|
||||
applyDeploymentConfig(&o.Metadata, fr)
|
||||
applyDeploymentConfig(&o.ObjectMeta, fr)
|
||||
|
||||
// index desired state
|
||||
desired[mapKey(&o.Metadata)] = true
|
||||
desired[mapKey(&o.ObjectMeta)] = true
|
||||
|
||||
// exists?
|
||||
existingObj, ok := existent[mapKey(&o.Metadata)]
|
||||
existingObj, ok := existent[mapKey(&o.ObjectMeta)]
|
||||
if ok {
|
||||
// ok, a resource with the same name exists, is it the same?
|
||||
if reflect.DeepEqual(existingObj.Spec, o.Spec) {
|
||||
// nothing to do on the server
|
||||
metadataMap[mapKey(&o.Metadata)] = existingObj.Metadata
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = existingObj.ObjectMeta
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
o.ObjectMeta.ResourceVersion = existingObj.ObjectMeta.ResourceVersion
|
||||
newmeta, err := fclient.V1().TimeTrigger().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Updated = append(ras.Updated, newmeta)
|
||||
// keep track of metadata in case we need to create a reference to it
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
@@ -1049,7 +1049,7 @@ func applyTimeTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Created = append(ras.Created, newmeta)
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1057,14 +1057,14 @@ func applyTimeTriggers(fclient client.Interface, fr *FissionResources, delete bo
|
||||
if delete {
|
||||
// objs is already filtered with our UID
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
_, wanted := desired[mapKey(&o.ObjectMeta)]
|
||||
if !wanted {
|
||||
err := fclient.V1().TimeTrigger().Delete(&o.Metadata)
|
||||
err := fclient.V1().TimeTrigger().Delete(&o.ObjectMeta)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Deleted = append(ras.Deleted, &o.Metadata)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.Metadata.Namespace, o.Metadata.Name)
|
||||
ras.Deleted = append(ras.Deleted, &o.ObjectMeta)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.ObjectMeta.Namespace, o.ObjectMeta.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1082,7 +1082,7 @@ func applyMessageQueueTriggers(fclient client.Interface, fr *FissionResources, d
|
||||
// filter
|
||||
objs := make([]fv1.MessageQueueTrigger, 0)
|
||||
for _, o := range allObjs {
|
||||
if hasDeploymentConfig(&o.Metadata, fr) {
|
||||
if hasDeploymentConfig(&o.ObjectMeta, fr) {
|
||||
objs = append(objs, o)
|
||||
}
|
||||
}
|
||||
@@ -1090,7 +1090,7 @@ func applyMessageQueueTriggers(fclient client.Interface, fr *FissionResources, d
|
||||
// index
|
||||
existent := make(map[string]fv1.MessageQueueTrigger)
|
||||
for _, obj := range objs {
|
||||
existent[mapKey(&obj.Metadata)] = obj
|
||||
existent[mapKey(&obj.ObjectMeta)] = obj
|
||||
}
|
||||
metadataMap := make(map[string]metav1.ObjectMeta)
|
||||
|
||||
@@ -1102,28 +1102,28 @@ func applyMessageQueueTriggers(fclient client.Interface, fr *FissionResources, d
|
||||
// create or update desired state
|
||||
for _, o := range fr.MessageQueueTriggers {
|
||||
// apply deploymentConfig so we can find our objects on future apply invocations
|
||||
applyDeploymentConfig(&o.Metadata, fr)
|
||||
applyDeploymentConfig(&o.ObjectMeta, fr)
|
||||
|
||||
// index desired state
|
||||
desired[mapKey(&o.Metadata)] = true
|
||||
desired[mapKey(&o.ObjectMeta)] = true
|
||||
|
||||
// exists?
|
||||
existingObj, ok := existent[mapKey(&o.Metadata)]
|
||||
existingObj, ok := existent[mapKey(&o.ObjectMeta)]
|
||||
if ok {
|
||||
// ok, a resource with the same name exists, is it the same?
|
||||
if reflect.DeepEqual(existingObj.Spec, o.Spec) {
|
||||
// nothing to do on the server
|
||||
metadataMap[mapKey(&o.Metadata)] = existingObj.Metadata
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = existingObj.ObjectMeta
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
o.ObjectMeta.ResourceVersion = existingObj.ObjectMeta.ResourceVersion
|
||||
newmeta, err := fclient.V1().MessageQueueTrigger().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Updated = append(ras.Updated, newmeta)
|
||||
// keep track of metadata in case we need to create a reference to it
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
@@ -1132,7 +1132,7 @@ func applyMessageQueueTriggers(fclient client.Interface, fr *FissionResources, d
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Created = append(ras.Created, newmeta)
|
||||
metadataMap[mapKey(&o.Metadata)] = *newmeta
|
||||
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1140,14 +1140,14 @@ func applyMessageQueueTriggers(fclient client.Interface, fr *FissionResources, d
|
||||
if delete {
|
||||
// objs is already filtered with our UID
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
_, wanted := desired[mapKey(&o.ObjectMeta)]
|
||||
if !wanted {
|
||||
err := fclient.V1().MessageQueueTrigger().Delete(&o.Metadata)
|
||||
err := fclient.V1().MessageQueueTrigger().Delete(&o.ObjectMeta)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
ras.Deleted = append(ras.Deleted, &o.Metadata)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.Metadata.Namespace, o.Metadata.Name)
|
||||
ras.Deleted = append(ras.Deleted, &o.ObjectMeta)
|
||||
fmt.Printf("Deleted %v %v/%v\n", o.TypeMeta.Kind, o.ObjectMeta.Namespace, o.ObjectMeta.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (w *packageBuildWatcher) watch(ctx context.Context) {
|
||||
keepWaiting := false
|
||||
buildpkgs := make([]fv1.Package, 0)
|
||||
for _, pkg := range pkgs {
|
||||
_, ok := w.pkgMeta[mapKey(&pkg.Metadata)]
|
||||
_, ok := w.pkgMeta[mapKey(&pkg.ObjectMeta)]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
@@ -118,5 +118,5 @@ func (w *packageBuildWatcher) watch(ctx context.Context) {
|
||||
|
||||
func pkgKey(pkg *fv1.Package) string {
|
||||
// packages are mutable so we want to keep track of them by resource version
|
||||
return fmt.Sprintf("%v:%v:%v", pkg.Metadata.Name, pkg.Metadata.Namespace, pkg.Metadata.ResourceVersion)
|
||||
return fmt.Sprintf("%v:%v:%v", pkg.ObjectMeta.Name, pkg.ObjectMeta.Namespace, pkg.ObjectMeta.ResourceVersion)
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ func getAppliedFunctions(fns []fv1.Function, deployID string) []fv1.Function {
|
||||
var fnlist []fv1.Function
|
||||
if len(fns) > 0 {
|
||||
for _, f := range fns {
|
||||
if f.Metadata.Annotations["fission-uid"] == deployID {
|
||||
if f.ObjectMeta.Annotations["fission-uid"] == deployID {
|
||||
fnlist = append(fnlist, f)
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func getAppliedEnvironments(envs []fv1.Environment, deployID string) []fv1.Envir
|
||||
var envlist []fv1.Environment
|
||||
if len(envs) > 0 {
|
||||
for _, f := range envs {
|
||||
if f.Metadata.Annotations["fission-uid"] == deployID {
|
||||
if f.ObjectMeta.Annotations["fission-uid"] == deployID {
|
||||
envlist = append(envlist, f)
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func getAppliedPackages(pkgs []fv1.Package, deployID string) []fv1.Package {
|
||||
var pkglist []fv1.Package
|
||||
if len(pkgs) > 0 {
|
||||
for _, f := range pkgs {
|
||||
if f.Metadata.Annotations["fission-uid"] == deployID {
|
||||
if f.ObjectMeta.Annotations["fission-uid"] == deployID {
|
||||
pkglist = append(pkglist, f)
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ func getAppliedCanaryConfigs(canaryCfgs []fv1.CanaryConfig, deployID string) []f
|
||||
var canaryConfiglist []fv1.CanaryConfig
|
||||
if len(canaryCfgs) > 0 {
|
||||
for _, f := range canaryCfgs {
|
||||
if f.Metadata.Annotations["fission-uid"] == deployID {
|
||||
if f.ObjectMeta.Annotations["fission-uid"] == deployID {
|
||||
canaryConfiglist = append(canaryConfiglist, f)
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ func getAppliedHTTPTriggers(hts []fv1.HTTPTrigger, deployID string) []fv1.HTTPTr
|
||||
var httpTriggerlist []fv1.HTTPTrigger
|
||||
if len(hts) > 0 {
|
||||
for _, f := range hts {
|
||||
if f.Metadata.Annotations["fission-uid"] == deployID {
|
||||
if f.ObjectMeta.Annotations["fission-uid"] == deployID {
|
||||
httpTriggerlist = append(httpTriggerlist, f)
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ func getAppliedMessageQueueTriggers(mqts []fv1.MessageQueueTrigger, deployID str
|
||||
var mqTriggerlist []fv1.MessageQueueTrigger
|
||||
if len(mqts) > 0 {
|
||||
for _, f := range mqts {
|
||||
if f.Metadata.Annotations["fission-uid"] == deployID {
|
||||
if f.ObjectMeta.Annotations["fission-uid"] == deployID {
|
||||
mqTriggerlist = append(mqTriggerlist, f)
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ func getAppliedTimeTriggers(tts []fv1.TimeTrigger, deployID string) []fv1.TimeTr
|
||||
var timeTriggerlist []fv1.TimeTrigger
|
||||
if len(tts) > 0 {
|
||||
for _, f := range tts {
|
||||
if f.Metadata.Annotations["fission-uid"] == deployID {
|
||||
if f.ObjectMeta.Annotations["fission-uid"] == deployID {
|
||||
timeTriggerlist = append(timeTriggerlist, f)
|
||||
}
|
||||
}
|
||||
@@ -203,7 +203,7 @@ func getSpecKubeWatchers(ws []fv1.KubernetesWatchTrigger, deployID string) []fv1
|
||||
var kubeWatchTriggerlist []fv1.KubernetesWatchTrigger
|
||||
if len(ws) > 0 {
|
||||
for _, f := range ws {
|
||||
if f.Metadata.Annotations["fission-uid"] == deployID {
|
||||
if f.ObjectMeta.Annotations["fission-uid"] == deployID {
|
||||
kubeWatchTriggerlist = append(kubeWatchTriggerlist, f)
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ func ShowFunctions(fns []fv1.Function) {
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -255,7 +255,7 @@ func ShowEnvironments(envs []fv1.Environment) {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", "NAME", "IMAGE", "BUILDER_IMAGE", "POOLSIZE", "MINCPU", "MAXCPU", "MINMEMORY", "MAXMEMORY", "EXTNET", "GRACETIME")
|
||||
for _, env := range envs {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
env.Metadata.Name, env.Spec.Runtime.Image, env.Spec.Builder.Image, env.Spec.Poolsize,
|
||||
env.ObjectMeta.Name, env.Spec.Runtime.Image, env.Spec.Builder.Image, env.Spec.Poolsize,
|
||||
env.Spec.Resources.Requests.Cpu(), env.Spec.Resources.Limits.Cpu(),
|
||||
env.Spec.Resources.Requests.Memory(), env.Spec.Resources.Limits.Memory(),
|
||||
env.Spec.AllowAccessToExternalNetwork, env.Spec.TerminationGracePeriod)
|
||||
@@ -272,7 +272,7 @@ func ShowPackages(pkgList []fv1.Package) {
|
||||
fmt.Fprintf(w, "%v\n", "Packages:")
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", "NAME", "BUILD_STATUS", "ENV", "LASTUPDATEDAT")
|
||||
for _, pkg := range pkgList {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", pkg.Metadata.Name, pkg.Status.BuildStatus, pkg.Spec.Environment.Name, pkg.Status.LastUpdateTimestamp.Format(time.RFC822))
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\n", pkg.ObjectMeta.Name, pkg.Status.BuildStatus, pkg.Spec.Environment.Name, pkg.Status.LastUpdateTimestamp.Format(time.RFC822))
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
w.Flush()
|
||||
@@ -287,7 +287,7 @@ func ShowCanaryConfigs(canaryCfgs []fv1.CanaryConfig) {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", "NAME", "TRIGGER", "FUNCTION-N", "FUNCTION-N-1", "WEIGHT-INCREMENT", "INTERVAL", "FAILURE-THRESHOLD", "FAILURE-TYPE", "STATUS")
|
||||
for _, canaryCfg := range canaryCfgs {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
canaryCfg.Metadata.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.NewFunction, canaryCfg.Spec.OldFunction, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.ObjectMeta.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.NewFunction, canaryCfg.Spec.OldFunction, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.Spec.FailureThreshold, canaryCfg.Spec.FailureType, canaryCfg.Status.Status)
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
@@ -327,7 +327,7 @@ func ShowHTTPTriggers(hts []fv1.HTTPTrigger) {
|
||||
ann := strings.Join(msg, ", ")
|
||||
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
trigger.Metadata.Name, trigger.Spec.Method, trigger.Spec.RelativeURL, function, trigger.Spec.CreateIngress, host, path, trigger.Spec.IngressConfig.TLS, ann)
|
||||
trigger.ObjectMeta.Name, trigger.Spec.Method, trigger.Spec.RelativeURL, function, trigger.Spec.CreateIngress, host, path, trigger.Spec.IngressConfig.TLS, ann)
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
w.Flush()
|
||||
@@ -342,7 +342,7 @@ func ShowMQTriggers(mqts []fv1.MessageQueueTrigger) {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", "NAME", "FUNCTION_NAME", "MESSAGE_QUEUE_TYPE", "TOPIC", "RESPONSE_TOPIC", "ERROR_TOPIC", "MAX_RETRIES", "PUB_MSG_CONTENT_TYPE")
|
||||
for _, mqt := range mqts {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
mqt.Metadata.Name, mqt.Spec.FunctionReference.Name, mqt.Spec.MessageQueueType, mqt.Spec.Topic, mqt.Spec.ResponseTopic, mqt.Spec.ErrorTopic, mqt.Spec.MaxRetries, mqt.Spec.ContentType)
|
||||
mqt.ObjectMeta.Name, mqt.Spec.FunctionReference.Name, mqt.Spec.MessageQueueType, mqt.Spec.Topic, mqt.Spec.ResponseTopic, mqt.Spec.ErrorTopic, mqt.Spec.MaxRetries, mqt.Spec.ContentType)
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
w.Flush()
|
||||
@@ -358,7 +358,7 @@ func ShowTimeTriggers(tts []fv1.TimeTrigger) {
|
||||
for _, tt := range tts {
|
||||
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\n",
|
||||
tt.Metadata.Name, tt.Spec.Cron, tt.Spec.FunctionReference.Name)
|
||||
tt.ObjectMeta.Name, tt.Spec.Cron, tt.Spec.FunctionReference.Name)
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
w.Flush()
|
||||
@@ -374,7 +374,7 @@ func ShowAppliedKubeWatchers(ws []fv1.KubernetesWatchTrigger) {
|
||||
|
||||
for _, wa := range ws {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n",
|
||||
wa.Metadata.Name, wa.Spec.Namespace, wa.Spec.Type, wa.Spec.LabelSelector, wa.Spec.FunctionReference.Name)
|
||||
wa.ObjectMeta.Name, wa.Spec.Namespace, wa.Spec.Type, wa.Spec.LabelSelector, wa.Spec.FunctionReference.Name)
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
w.Flush()
|
||||
|
||||
@@ -182,43 +182,43 @@ func SpecSave(resource interface{}, specFile string) error {
|
||||
case fv1.Package:
|
||||
typedres.TypeMeta.APIVersion = fv1.CRD_VERSION
|
||||
typedres.TypeMeta.Kind = "Package"
|
||||
meta = typedres.Metadata
|
||||
meta = typedres.ObjectMeta
|
||||
kind = typedres.TypeMeta.Kind
|
||||
data, err = yaml.Marshal(typedres)
|
||||
case fv1.Function:
|
||||
typedres.TypeMeta.APIVersion = fv1.CRD_VERSION
|
||||
typedres.TypeMeta.Kind = "Function"
|
||||
meta = typedres.Metadata
|
||||
meta = typedres.ObjectMeta
|
||||
kind = typedres.TypeMeta.Kind
|
||||
data, err = yaml.Marshal(typedres)
|
||||
case fv1.Environment:
|
||||
typedres.TypeMeta.APIVersion = fv1.CRD_VERSION
|
||||
typedres.TypeMeta.Kind = "Environment"
|
||||
meta = typedres.Metadata
|
||||
meta = typedres.ObjectMeta
|
||||
kind = typedres.TypeMeta.Kind
|
||||
data, err = yaml.Marshal(typedres)
|
||||
case fv1.HTTPTrigger:
|
||||
typedres.TypeMeta.APIVersion = fv1.CRD_VERSION
|
||||
typedres.TypeMeta.Kind = "HTTPTrigger"
|
||||
meta = typedres.Metadata
|
||||
meta = typedres.ObjectMeta
|
||||
kind = typedres.TypeMeta.Kind
|
||||
data, err = yaml.Marshal(typedres)
|
||||
case fv1.KubernetesWatchTrigger:
|
||||
typedres.TypeMeta.APIVersion = fv1.CRD_VERSION
|
||||
typedres.TypeMeta.Kind = "KubernetesWatchTrigger"
|
||||
meta = typedres.Metadata
|
||||
meta = typedres.ObjectMeta
|
||||
kind = typedres.TypeMeta.Kind
|
||||
data, err = yaml.Marshal(typedres)
|
||||
case fv1.MessageQueueTrigger:
|
||||
typedres.TypeMeta.APIVersion = fv1.CRD_VERSION
|
||||
typedres.TypeMeta.Kind = "MessageQueueTrigger"
|
||||
meta = typedres.Metadata
|
||||
meta = typedres.ObjectMeta
|
||||
kind = typedres.TypeMeta.Kind
|
||||
data, err = yaml.Marshal(typedres)
|
||||
case fv1.TimeTrigger:
|
||||
typedres.TypeMeta.APIVersion = fv1.CRD_VERSION
|
||||
typedres.TypeMeta.Kind = "TimeTrigger"
|
||||
meta = typedres.Metadata
|
||||
meta = typedres.ObjectMeta
|
||||
kind = typedres.TypeMeta.Kind
|
||||
data, err = yaml.Marshal(typedres)
|
||||
default:
|
||||
@@ -297,7 +297,7 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
|
||||
// index packages, check outgoing refs, mark archives that are referenced
|
||||
packages := make(map[string]bool)
|
||||
for _, p := range fr.Packages {
|
||||
packages[MapKey(&p.Metadata)] = false
|
||||
packages[MapKey(&p.ObjectMeta)] = false
|
||||
|
||||
as := map[string]string{
|
||||
"source": p.Spec.Source.URL,
|
||||
@@ -311,8 +311,8 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
|
||||
if _, ok := archives[aname]; !ok {
|
||||
result = multierror.Append(result, fmt.Errorf(
|
||||
"%v: package '%v' references unknown %v archive '%v%v'",
|
||||
fr.SourceMap.Locations["Package"][p.Metadata.Namespace][p.Metadata.Name],
|
||||
p.Metadata.Name,
|
||||
fr.SourceMap.Locations["Package"][p.ObjectMeta.Namespace][p.ObjectMeta.Name],
|
||||
p.ObjectMeta.Name,
|
||||
archiveType,
|
||||
ARCHIVE_URL_PREFIX,
|
||||
aname))
|
||||
@@ -339,7 +339,7 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
|
||||
// index functions, check function package refs, mark referenced packages
|
||||
functions := make(map[string]bool)
|
||||
for _, f := range fr.Functions {
|
||||
functions[MapKey(&f.Metadata)] = false
|
||||
functions[MapKey(&f.ObjectMeta)] = false
|
||||
|
||||
pkgMeta := &metav1.ObjectMeta{
|
||||
Name: f.Spec.Package.PackageRef.Name,
|
||||
@@ -354,21 +354,21 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
|
||||
|
||||
// check that the package referenced by each function is in the same ns as the function
|
||||
packageRefInFuncNs := func(f *fv1.Function) bool {
|
||||
return f.Spec.Package.PackageRef.Namespace == f.Metadata.Namespace
|
||||
return f.Spec.Package.PackageRef.Namespace == f.ObjectMeta.Namespace
|
||||
}
|
||||
|
||||
if !packageRefInFuncNs(&f) {
|
||||
result = multierror.Append(result, fmt.Errorf(
|
||||
"%v: function '%v' references a package outside of its namespace %v/%v",
|
||||
fr.SourceMap.Locations["Function"][f.Metadata.Namespace][f.Metadata.Name],
|
||||
f.Metadata.Name,
|
||||
fr.SourceMap.Locations["Function"][f.ObjectMeta.Namespace][f.ObjectMeta.Name],
|
||||
f.ObjectMeta.Name,
|
||||
f.Spec.Package.PackageRef.Namespace,
|
||||
f.Spec.Package.PackageRef.Name))
|
||||
} else if !packageRefExists() {
|
||||
result = multierror.Append(result, fmt.Errorf(
|
||||
"%v: function '%v' references unknown package %v/%v",
|
||||
fr.SourceMap.Locations["Function"][f.Metadata.Namespace][f.Metadata.Name],
|
||||
f.Metadata.Name,
|
||||
fr.SourceMap.Locations["Function"][f.ObjectMeta.Namespace][f.ObjectMeta.Name],
|
||||
f.ObjectMeta.Name,
|
||||
pkgMeta.Namespace,
|
||||
pkgMeta.Name))
|
||||
} else {
|
||||
@@ -415,7 +415,7 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
|
||||
|
||||
// check function refs from triggers
|
||||
for _, t := range fr.HttpTriggers {
|
||||
err := fr.validateFunctionReference(functions, t.Kind, &t.Metadata, t.Spec.FunctionReference)
|
||||
err := fr.validateFunctionReference(functions, t.Kind, &t.ObjectMeta, t.Spec.FunctionReference)
|
||||
if err != nil {
|
||||
result = multierror.Append(result, err)
|
||||
}
|
||||
@@ -426,21 +426,21 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
|
||||
result = multierror.Append(result, t.Validate())
|
||||
}
|
||||
for _, t := range fr.KubernetesWatchTriggers {
|
||||
err := fr.validateFunctionReference(functions, t.Kind, &t.Metadata, t.Spec.FunctionReference)
|
||||
err := fr.validateFunctionReference(functions, t.Kind, &t.ObjectMeta, t.Spec.FunctionReference)
|
||||
if err != nil {
|
||||
result = multierror.Append(result, err)
|
||||
}
|
||||
result = multierror.Append(result, t.Validate())
|
||||
}
|
||||
for _, t := range fr.TimeTriggers {
|
||||
err := fr.validateFunctionReference(functions, t.Kind, &t.Metadata, t.Spec.FunctionReference)
|
||||
err := fr.validateFunctionReference(functions, t.Kind, &t.ObjectMeta, t.Spec.FunctionReference)
|
||||
if err != nil {
|
||||
result = multierror.Append(result, err)
|
||||
}
|
||||
result = multierror.Append(result, t.Validate())
|
||||
}
|
||||
for _, t := range fr.MessageQueueTriggers {
|
||||
err := fr.validateFunctionReference(functions, t.Kind, &t.Metadata, t.Spec.FunctionReference)
|
||||
err := fr.validateFunctionReference(functions, t.Kind, &t.ObjectMeta, t.Spec.FunctionReference)
|
||||
if err != nil {
|
||||
result = multierror.Append(result, err)
|
||||
}
|
||||
@@ -453,7 +453,7 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
|
||||
// Index envs, warn on functions referencing an environment for which spes does not exist
|
||||
environments := make(map[string]struct{})
|
||||
for _, e := range fr.Environments {
|
||||
environments[fmt.Sprintf("%s:%s", e.Metadata.Name, e.Metadata.Namespace)] = struct{}{}
|
||||
environments[fmt.Sprintf("%s:%s", e.ObjectMeta.Name, e.ObjectMeta.Namespace)] = struct{}{}
|
||||
if ((e.Spec.Runtime.Container != nil) && (e.Spec.Runtime.PodSpec != nil)) || ((e.Spec.Builder.Container != nil) && (e.Spec.Builder.PodSpec != nil)) {
|
||||
warnings = append(warnings, fmt.Sprintf("You have provided both - container spec and pod spec and while merging the pod spec will take precedence."))
|
||||
}
|
||||
@@ -466,7 +466,7 @@ func (fr *FissionResources) Validate(input cli.Input) ([]string, error) {
|
||||
|
||||
for _, f := range fr.Functions {
|
||||
if _, ok := environments[fmt.Sprintf("%s:%s", f.Spec.Environment.Name, f.Spec.Environment.Namespace)]; !ok {
|
||||
warnings = append(warnings, fmt.Sprintf("Environment %s is referenced in function %s but not declared in specs", f.Spec.Environment.Name, f.Metadata.Name))
|
||||
warnings = append(warnings, fmt.Sprintf("Environment %s is referenced in function %s but not declared in specs", f.Spec.Environment.Name, f.ObjectMeta.Name))
|
||||
}
|
||||
strategy := f.Spec.InvokeStrategy.ExecutionStrategy
|
||||
if strategy.ExecutorType == fv1.ExecutorTypeNewdeploy && strategy.SpecializationTimeout < fv1.DefaultSpecializationTimeOut {
|
||||
@@ -521,7 +521,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
}
|
||||
m = &v.Metadata
|
||||
m = &v.ObjectMeta
|
||||
fr.Packages = append(fr.Packages, v)
|
||||
case "Function":
|
||||
var v fv1.Function
|
||||
@@ -529,7 +529,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
}
|
||||
m = &v.Metadata
|
||||
m = &v.ObjectMeta
|
||||
fr.Functions = append(fr.Functions, v)
|
||||
case "Environment":
|
||||
var v fv1.Environment
|
||||
@@ -537,7 +537,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
}
|
||||
m = &v.Metadata
|
||||
m = &v.ObjectMeta
|
||||
fr.Environments = append(fr.Environments, v)
|
||||
case "HTTPTrigger":
|
||||
var v fv1.HTTPTrigger
|
||||
@@ -551,7 +551,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location) error {
|
||||
v.Spec.RelativeURL = fmt.Sprintf("/%s", v.Spec.RelativeURL)
|
||||
}
|
||||
|
||||
m = &v.Metadata
|
||||
m = &v.ObjectMeta
|
||||
fr.HttpTriggers = append(fr.HttpTriggers, v)
|
||||
case "KubernetesWatchTrigger":
|
||||
var v fv1.KubernetesWatchTrigger
|
||||
@@ -559,7 +559,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
}
|
||||
m = &v.Metadata
|
||||
m = &v.ObjectMeta
|
||||
fr.KubernetesWatchTriggers = append(fr.KubernetesWatchTriggers, v)
|
||||
case "TimeTrigger":
|
||||
var v fv1.TimeTrigger
|
||||
@@ -567,7 +567,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
}
|
||||
m = &v.Metadata
|
||||
m = &v.ObjectMeta
|
||||
fr.TimeTriggers = append(fr.TimeTriggers, v)
|
||||
case "MessageQueueTrigger":
|
||||
var v fv1.MessageQueueTrigger
|
||||
@@ -575,7 +575,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
}
|
||||
m = &v.Metadata
|
||||
m = &v.ObjectMeta
|
||||
fr.MessageQueueTriggers = append(fr.MessageQueueTriggers, v)
|
||||
|
||||
// The following are not CRDs
|
||||
@@ -637,7 +637,7 @@ func (fr *FissionResources) SpecExists(resource interface{}, compareMetadata boo
|
||||
return nil
|
||||
case *fv1.Package:
|
||||
for _, p := range fr.Packages {
|
||||
if compareMetadata && !reflect.DeepEqual(p.Metadata, typedres.Metadata) {
|
||||
if compareMetadata && !reflect.DeepEqual(p.ObjectMeta, typedres.ObjectMeta) {
|
||||
continue
|
||||
}
|
||||
if compareSpec && !reflect.DeepEqual(p.Spec, typedres.Spec) {
|
||||
@@ -663,50 +663,50 @@ func (fr *FissionResources) ExistsInSpecs(resource interface{}) (bool, error) {
|
||||
}
|
||||
case fv1.Package:
|
||||
for _, obj := range fr.Packages {
|
||||
if obj.Metadata.Name == typedres.Metadata.Name &&
|
||||
obj.Metadata.Namespace == typedres.Metadata.Namespace {
|
||||
if obj.ObjectMeta.Name == typedres.ObjectMeta.Name &&
|
||||
obj.ObjectMeta.Namespace == typedres.ObjectMeta.Namespace {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
case fv1.Function:
|
||||
for _, obj := range fr.Functions {
|
||||
if obj.Metadata.Name == typedres.Metadata.Name &&
|
||||
obj.Metadata.Namespace == typedres.Metadata.Namespace {
|
||||
if obj.ObjectMeta.Name == typedres.ObjectMeta.Name &&
|
||||
obj.ObjectMeta.Namespace == typedres.ObjectMeta.Namespace {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
case fv1.Environment:
|
||||
for _, obj := range fr.Environments {
|
||||
if obj.Metadata.Name == typedres.Metadata.Name &&
|
||||
obj.Metadata.Namespace == typedres.Metadata.Namespace {
|
||||
if obj.ObjectMeta.Name == typedres.ObjectMeta.Name &&
|
||||
obj.ObjectMeta.Namespace == typedres.ObjectMeta.Namespace {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
case fv1.HTTPTrigger:
|
||||
for _, obj := range fr.HttpTriggers {
|
||||
if obj.Metadata.Name == typedres.Metadata.Name &&
|
||||
obj.Metadata.Namespace == typedres.Metadata.Namespace {
|
||||
if obj.ObjectMeta.Name == typedres.ObjectMeta.Name &&
|
||||
obj.ObjectMeta.Namespace == typedres.ObjectMeta.Namespace {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
case fv1.KubernetesWatchTrigger:
|
||||
for _, obj := range fr.KubernetesWatchTriggers {
|
||||
if obj.Metadata.Name == typedres.Metadata.Name &&
|
||||
obj.Metadata.Namespace == typedres.Metadata.Namespace {
|
||||
if obj.ObjectMeta.Name == typedres.ObjectMeta.Name &&
|
||||
obj.ObjectMeta.Namespace == typedres.ObjectMeta.Namespace {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
case fv1.MessageQueueTrigger:
|
||||
for _, obj := range fr.MessageQueueTriggers {
|
||||
if obj.Metadata.Name == typedres.Metadata.Name &&
|
||||
obj.Metadata.Namespace == typedres.Metadata.Namespace {
|
||||
if obj.ObjectMeta.Name == typedres.ObjectMeta.Name &&
|
||||
obj.ObjectMeta.Namespace == typedres.ObjectMeta.Namespace {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
case fv1.TimeTrigger:
|
||||
for _, obj := range fr.TimeTriggers {
|
||||
if obj.Metadata.Name == typedres.Metadata.Name &&
|
||||
obj.Metadata.Namespace == typedres.Metadata.Namespace {
|
||||
if obj.ObjectMeta.Name == typedres.ObjectMeta.Name &&
|
||||
obj.ObjectMeta.Namespace == typedres.ObjectMeta.Namespace {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
f := getFileName(dumpDir, item.Metadata)
|
||||
f := getFileName(dumpDir, item.ObjectMeta)
|
||||
writeToFile(f, item)
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
f := getFileName(dumpDir, item.Metadata)
|
||||
f := getFileName(dumpDir, item.ObjectMeta)
|
||||
writeToFile(f, item)
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
|
||||
for _, item := range items {
|
||||
item = pkgClean(item)
|
||||
f := getFileName(dumpDir, item.Metadata)
|
||||
f := getFileName(dumpDir, item.ObjectMeta)
|
||||
writeToFile(f, item)
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
f := getFileName(dumpDir, item.Metadata)
|
||||
f := getFileName(dumpDir, item.ObjectMeta)
|
||||
writeToFile(f, item)
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
f := getFileName(dumpDir, item.Metadata)
|
||||
f := getFileName(dumpDir, item.ObjectMeta)
|
||||
writeToFile(f, item)
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
for _, item := range triggers {
|
||||
f := getFileName(dumpDir, item.Metadata)
|
||||
f := getFileName(dumpDir, item.ObjectMeta)
|
||||
writeToFile(f, item)
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
f := getFileName(dumpDir, item.Metadata)
|
||||
f := getFileName(dumpDir, item.ObjectMeta)
|
||||
writeToFile(f, item)
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
exists, err := fr.ExistsInSpecs(fv1.Function{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fnName,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -93,7 +93,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
opts.trigger = &fv1.TimeTrigger{
|
||||
Metadata: metav1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: fnNamespace,
|
||||
},
|
||||
@@ -112,7 +112,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
// if we're writing a spec, don't call the API
|
||||
if input.Bool(flagkey.SpecSave) {
|
||||
specFile := fmt.Sprintf("timetrigger-%v.yaml", opts.trigger.Metadata.Name)
|
||||
specFile := fmt.Sprintf("timetrigger-%v.yaml", opts.trigger.ObjectMeta.Name)
|
||||
err := spec.SpecSave(*opts.trigger, specFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating time trigger spec")
|
||||
@@ -125,7 +125,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error creating Time trigger")
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' created\n", opts.trigger.Metadata.Name)
|
||||
fmt.Printf("trigger '%v' created\n", opts.trigger.ObjectMeta.Name)
|
||||
|
||||
t, err := getAPITimeInfo(opts.Client())
|
||||
if err != nil {
|
||||
|
||||
@@ -48,7 +48,7 @@ func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\n", "NAME", "CRON", "FUNCTION_NAME")
|
||||
for _, tt := range tts {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\n",
|
||||
tt.Metadata.Name, tt.Spec.Cron, tt.Spec.FunctionReference.Name)
|
||||
tt.ObjectMeta.Name, tt.Spec.Cron, tt.Spec.FunctionReference.Name)
|
||||
}
|
||||
w.Flush()
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "error updating Time trigger")
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' updated\n", opts.trigger.Metadata.Name)
|
||||
fmt.Printf("trigger '%v' updated\n", opts.trigger.ObjectMeta.Name)
|
||||
|
||||
t, err := getAPITimeInfo(opts.Client())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user