Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clients/dynamic/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ func (c *ResourceClient) Create(ctx context.Context, obj *unstructured.Unstructu

if needsCleanup(obj) {
c.ts.RegisterCleanupFunc(func() error {
err := c.Delete(context.TODO(), unstructuredObj.GetName(), metav1.DeleteOptions{}, subresources...)
// Using this policy avoids a flood of useless warnings on test logs.
orphanPolicy := metav1.DeletePropagationOrphan
err := c.Delete(context.TODO(), unstructuredObj.GetName(), metav1.DeleteOptions{PropagationPolicy: &orphanPolicy}, subresources...)
if errors.IsNotFound(err) {
return nil
}
Expand Down
12 changes: 2 additions & 10 deletions clients/rancher/v1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ func (c *Client) ProxyDownstream(clusterID string) (*Client, error) {
updatedOpts.URL = proxyHost

baseClient, err := clientbase.NewAPIClient(&updatedOpts)
if err != nil {
return nil, err
}

if err != nil {
return nil, fmt.Errorf("failed creating Proxy Client. Backoff error: %v", err)
}
Expand Down Expand Up @@ -231,9 +227,7 @@ func (c *SteveClient) ListAll(params url.Values) (*SteveCollection, error) {
resp = next
resp.Data = data
}
if err != nil {
return resp, err
}

return resp, err
}

Expand Down Expand Up @@ -387,9 +381,7 @@ func (c *NamespacedSteveClient) ListAll(params url.Values) (*SteveCollection, er
resp = next
resp.Data = data
}
if err != nil {
return resp, err
}

return resp, err
}

Expand Down
10 changes: 10 additions & 0 deletions extensions/kubeapi/secrets/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@ func CreateSecretWithTemplate(client *rancher.Client, clusterID string, secretTe

return createdSecret, nil
}

func UpdateSecretWithTemplate(client *rancher.Client, clusterID string, secretTemplate *corev1.Secret) error {
clusterContext, err := extclusterapi.GetClusterWranglerContext(client, clusterID)
if err != nil {
return fmt.Errorf("failed to get cluster context: %w", err)
}

_, err = clusterContext.Core.Secret().Update(secretTemplate)
return err
}
7 changes: 6 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"

"github.com/creasty/defaults"
"github.com/sirupsen/logrus"
"sigs.k8s.io/yaml"
)

Expand All @@ -18,6 +19,7 @@ func LoadConfig(key string, config interface{}) {
configPath := os.Getenv(ConfigEnvironmentKey)

if configPath == "" {
logrus.Infof("No config file path provided via %s env var", ConfigEnvironmentKey)
yaml.Unmarshal([]byte("{}"), config)
return
}
Expand All @@ -33,7 +35,10 @@ func LoadConfig(key string, config interface{}) {
panic(err)
}

scoped := all[key]
scoped, ok := all[key]
if !ok {
logrus.Infof("Key %s not present in provided config", key)
}
scopedString, err := yaml.Marshal(scoped)
if err != nil {
panic(err)
Expand Down
10 changes: 7 additions & 3 deletions pkg/config/operations/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package operations

import (
"encoding/json"
"errors"
"fmt"

"github.com/sirupsen/logrus"
"sigs.k8s.io/yaml"
)

Expand Down Expand Up @@ -42,7 +42,7 @@ func GetValue(keyPath []string, searchMap map[string]any) (any, error) {
if len(keyPath) == 1 {
keypathvalues, ok := searchMap[keyPath[0]]
if !ok {
err = errors.New(fmt.Sprintf("expected key does not exist: %s", keyPath[0]))
err = fmt.Errorf("expected key does not exist: %s", keyPath[0])
}
return keypathvalues, err
} else {
Expand All @@ -66,7 +66,11 @@ func GetValue(keyPath []string, searchMap map[string]any) (any, error) {

// LoadObjectFromMap unmarshals a specific key's value into an object
func LoadObjectFromMap(key string, config map[string]any, object any) {
keyConfig := config[key]
keyConfig, ok := config[key]
if !ok {
logrus.Infof("Key %s not present in provided config", key)
}

scopedString, err := yaml.Marshal(keyConfig)
if err != nil {
panic(err)
Expand Down
Loading