(name string, opts ...NamespaceOption)
| 41 | } |
| 42 | |
| 43 | func NewNamespace(name string, opts ...NamespaceOption) (*Namespace, error) { |
| 44 | if name == "" { |
| 45 | name = DefaultNamespace |
| 46 | } |
| 47 | |
| 48 | if !validNamespace.MatchString(name) { |
| 49 | return nil, fmt.Errorf("%w: %q", ErrInvalidNamespace, name) |
| 50 | } |
| 51 | |
| 52 | c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) |
| 53 | if err != nil { |
| 54 | return nil, err |
| 55 | } |
| 56 | |
| 57 | ns := &Namespace{ |
| 58 | name: name, |
| 59 | client: c, |
| 60 | } |
| 61 | ns.proxy = NewProxy(ns) |
| 62 | |
| 63 | for _, opt := range opts { |
| 64 | opt(ns) |
| 65 | } |
| 66 | |
| 67 | return ns, nil |
| 68 | } |
| 69 | |
| 70 | func RestoreNamespace(ctx context.Context, name string) (*Namespace, error) { |
| 71 | ns, err := NewNamespace(name) |
searching dependent graphs…