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
8 changes: 4 additions & 4 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (c ApplyClient) ApplyObject(ctx context.Context, obj client.Object, options
gvk := obj.GetObjectKind().GroupVersionKind()
createdOrUpdated, err := c.applyObject(ctx, obj, options...)
if err != nil {
return createdOrUpdated, errors.Wrapf(err, "unable to create resource of kind: %s, version: %s", gvk.Kind, gvk.Version)
return createdOrUpdated, fmt.Errorf("unable to create resource of kind: %s, version: %s: %w", gvk.Kind, gvk.Version, err)
}
return createdOrUpdated, nil
}
Expand Down Expand Up @@ -127,7 +127,7 @@ func (c ApplyClient) applyObject(ctx context.Context, obj client.Object, options
obj.SetResourceVersion("") // reset resource version when creating to avoid error: resourceVersion should not be set on objects to be created
return true, c.createObj(ctx, obj, config.owner)
}
return false, errors.Wrapf(err, "unable to get the resource '%v'", existing)
return false, fmt.Errorf("unable to get the resource '%v': %w", existing, err)
}

// as it already exists, check using the UpdateStrategy if it should be updated
Expand Down Expand Up @@ -164,7 +164,7 @@ func (c ApplyClient) applyObject(ctx context.Context, obj client.Object, options
return false, err
}
if err := c.Update(ctx, obj); err != nil {
return false, errors.Wrapf(err, "unable to update the resource '%v'", obj)
return false, fmt.Errorf("unable to update the resource '%v': %w", obj, err)
}

// check if it was changed or not
Expand Down Expand Up @@ -251,7 +251,7 @@ func (c ApplyClient) Apply(ctx context.Context, toolchainObjects []client.Object

result, err := c.ApplyObject(ctx, toolchainObject, ForceUpdate(true))
if err != nil {
return false, errors.Wrapf(err, "unable to create resource of kind: %s, version: %s", toolchainObject.GetObjectKind().GroupVersionKind().Kind, toolchainObject.GetObjectKind().GroupVersionKind().Version)
return false, fmt.Errorf("unable to create resource of kind: %s, version: %s: %w", toolchainObject.GetObjectKind().GroupVersionKind().Kind, toolchainObject.GetObjectKind().GroupVersionKind().Version, err)
}
createdOrUpdated = createdOrUpdated || result
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func NewClusterConfig(cl client.Client, toolchainCluster *toolchainv1alpha1.Tool
}
err := cl.Get(context.TODO(), name, secret)
if err != nil {
return nil, errors.Wrapf(err, "unable to get secret %s for cluster %s", name, toolchainCluster.Name)
return nil, fmt.Errorf("unable to get secret %s for cluster %s: %w", name, toolchainCluster.Name, err)
}

return loadConfigFromKubeConfig(toolchainCluster, secret, timeout)
Expand Down
10 changes: 5 additions & 5 deletions pkg/template/nstemplatetiers/nstemplatetier_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func loadTemplatesByTiers(metadata map[string]string, files map[string][]byte) (
case filename == "based_on_tier.yaml":
basedOnTier := &BasedOnTier{}
if err := yaml.Unmarshal(content, basedOnTier); err != nil {
return nil, errors.Wrapf(err, "unable to unmarshal '%s'", name)
return nil, fmt.Errorf("unable to unmarshal '%s': %w", name, err)
}
results[tier].rawTemplates.basedOnTier = &tmpl
results[tier].basedOnTier = basedOnTier
Expand Down Expand Up @@ -276,7 +276,7 @@ func (t *TierGenerator) createTierTemplates() error {
for _, tierTmpl := range tierTmpls.tierTemplates {
log.Info("creating TierTemplate", "namespace", tierTmpl.Namespace, "name", tierTmpl.Name)
if err := t.ensureObject(tierTmpl, tierName); err != nil {
return errors.Wrapf(err, "unable to create the '%s' TierTemplate in namespace '%s'", tierTmpl.Name, tierTmpl.Namespace)
return fmt.Errorf("unable to create the '%s' TierTemplate in namespace '%s': %w", tierTmpl.Name, tierTmpl.Namespace, err)
}
log.Info("TierTemplate resource created", "namespace", tierTmpl.Namespace, "name", tierTmpl.Name)
}
Expand All @@ -294,7 +294,7 @@ func (t *TierGenerator) newTierTemplate(decoder runtime.Decoder, basedOnTierFile
tmplObj := &templatev1.Template{}
_, _, err := decoder.Decode(tmpl.content, nil, tmplObj)
if err != nil {
return nil, errors.Wrapf(err, "unable to generate '%s' TierTemplate manifest", name)
return nil, fmt.Errorf("unable to generate '%s' TierTemplate manifest: %w", name, err)
}
setParams(parameters, tmplObj)

Expand Down Expand Up @@ -376,7 +376,7 @@ func (t *TierGenerator) createNSTemplateTiers() error {
labels[toolchainv1alpha1.ProviderLabelKey] = toolchainv1alpha1.ProviderLabelValue
err := t.ensureObject(tier, tierName)
if err != nil {
return errors.Wrapf(err, "unable to create or update the '%s' NSTemplateTier", tierName)
return fmt.Errorf("unable to create or update the '%s' NSTemplateTier: %w", tierName, err)
}
tierLog := log.WithValues("name", tierName)
if tier.Spec.ClusterResources != nil {
Expand Down Expand Up @@ -426,7 +426,7 @@ func (t *TierGenerator) newNSTemplateTier(sourceTierName, tierName string, nsTem
tmplObj := &templatev1.Template{}
_, _, err := decoder.Decode(nsTemplateTier.content, nil, tmplObj)
if err != nil {
return nil, errors.Wrapf(err, "unable to generate '%s' NSTemplateTier manifest", tierName)
return nil, fmt.Errorf("unable to generate '%s' NSTemplateTier manifest: %w", tierName, err)
}

tmplProcessor := commonTemplate.NewProcessor(t.scheme)
Expand Down
Loading