You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: create.go
    path of file: ./repos/porter/internal/kubernetes/environment_groups
    
    the code of the file until where you have to start completion: package environment_groups

import (
	"context"
	"fmt"
	"strconv"

	"github.com/porter-dev/porter/internal/kubernetes"
	"github.com/porter-dev/porter/internal/telemetry"
	v1 "k8s.io/api/core/v1"
	k8serror "k8s.io/apimachinery/pkg/api/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1
    
func createVersionedEnvironmentGroupInNamespace(ctx context.Context, a *kubernetes.Agent, environmentGroup EnvironmentGroup, targetNamespace string, additionalLabels map[string]string) error {
	ctx, span := telemetry.NewSpan(ctx, "create-environment-group-on-cluster")
	defer span.End()

	configMap := v1.ConfigMap{
		ObjectMeta: metav1.ObjectMeta{
			Name:      fmt.Sprintf("%s.%d", environmentGroup.Name, environmentGroup.Version),
			Namespace: targetNamespace,
			Labels: map[string]string{
				LabelKey_EnvironmentGroupName:    environmentGroup.Name,
				LabelKey_EnvironmentGroupVersion: strconv.Itoa(environmentGroup.Version),
				LabelKey_PorterManaged:           "true",
			},
		},
		Data: environmentGroup.Variables,
	}
	for k, v := range additionalLabels {
		configMap.Labels[k] = v
	}

	err := createConfigMapWithVersion(ctx, a, configMap, environmentGroup.Version)
	if err != nil {
		return telemetry.Error(ctx, span, err, "unable to create new environment group variables version")
	}

	secretData := make(map[string][]byte)
	for k, v := range environmentGroup.SecretVariables {
		secretData[k] = []byte(v)
	}

	secret := v1.Secret{
		ObjectMeta: metav1.ObjectMeta{
			Name:      fmt.Sprintf("%s.%d", environmentGroup.Name, environmentGroup.Version),
			Namespace: targetNamespace,
			Labels: map[string]string{
				LabelKey_EnvironmentGroupName:    environmentGroup.Name,
				LabelKey_EnvironmentGroupVersion: strconv.Itoa(environmentGroup.Version),
				LabelKey_PorterManaged:           "true",
			},
		},
		Data: secretData,
	}
	for k, v := range additionalLabels {
		secret.Labels[k] = v
	}

	err = createSecretWithVersion(ctx, a, secret, environmentGroup.Version)
	if err != nil {
		return telemetry.Error(ctx, span, err, "unable to create new environment group secret variables version")
	}

	return nil
}