mchirico / osdk

0 stars 0 forks source link

namespace #1

Open mchirico opened 3 years ago

mchirico commented 3 years ago
func (r *MemcachedReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
    log := r.Log.WithValues("memcached", req.NamespacedName)

    // Fetch the Memcached instance
    memcached := &cachev1alpha1.Memcached{}
    err := r.Get(ctx, req.NamespacedName, memcached)
    fmt.Printf("namespace: %s\n", req.Namespace)

    // Can we do this?
    ns := &corev1.Namespace{}
    ns.Name = memcached.Name
    if err = r.Client.Get(context.TODO(), types.NamespacedName{Name: memcached.Name}, ns); err != nil {
        fmt.Printf("Return: %s, err: %s\n", ns.Name, err)

        if strings.Contains(err.Error(), "Namespace \"memcached-sample\" not found") {
            fmt.Printf("We create\n")
            err = r.Client.Create(context.TODO(), ns)
            if err != nil {
                fmt.Printf("E")
            }
        }
    }

...
tacomonkautobot[bot] commented 3 years ago

mchirico, Thanks for opening this issue!