You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

downstream.go 1.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Copyright 2021 The KubeEdge Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package dataset
  14. import (
  15. "fmt"
  16. "k8s.io/apimachinery/pkg/watch"
  17. sednav1 "github.com/kubeedge/sedna/pkg/apis/sedna/v1alpha1"
  18. "github.com/kubeedge/sedna/pkg/globalmanager/runtime"
  19. )
  20. // syncToEdge syncs the dataset resources
  21. func (c *Controller) syncToEdge(eventType watch.EventType, obj interface{}) error {
  22. dataset, ok := obj.(*sednav1.Dataset)
  23. if !ok {
  24. return nil
  25. }
  26. // Since t.Kind may be empty,
  27. // we need to fix the kind here if missing.
  28. // more details at https://github.com/kubernetes/kubernetes/issues/3030
  29. dataset.Kind = KindName
  30. // Here only propagate to the nodes with non empty name
  31. nodeName := dataset.Spec.NodeName
  32. if len(nodeName) == 0 {
  33. return fmt.Errorf("empty node name")
  34. }
  35. runtime.InjectSecretAnnotations(c.kubeClient, dataset, dataset.Spec.CredentialName)
  36. return c.sendToEdgeFunc(nodeName, eventType, dataset)
  37. }
  38. func (c *Controller) SetDownstreamSendFunc(f runtime.DownstreamSendFunc) error {
  39. c.sendToEdgeFunc = f
  40. return nil
  41. }