<p>Helm 3 does not provide any way to create an action.Configuration structure if the code is running from within the cluster.</p>

<p>I have tried by building my own generic flags:</p>

<pre><code>config, err := rest.InClusterConfig()
if err != nil {
    panic(err)
}
insecure := false

genericConfigFlag := &amp;genericclioptions.ConfigFlags{
    Timeout: stringptr("0"),
    Insecure: &amp;insecure,
    APIServer: stringptr(config.Host),
    CAFile: stringptr(config.CAFile),
    BearerToken: stringptr(config.BearerToken),
    ImpersonateGroup: &amp;[]string{},
    Namespace: stringptr(namespace),
}

actionConfig := &amp;action.Configuration{
    RESTClientGetter: genericConfigFlag,
    KubeClient: kube.New(genericConfigFlag),
    Log: log.Infof,
}
</code></pre>

<p>Unfortunately, this result in a SIGSEGV error later when running <code>action.NewList(actionConfig).Run()</code>.</p>

<p>Is it the right way to define an action config for Helm 3 from within a Kubernetes cluster?</p>

Arkon
<p>This is what I did, and works fine for me (using helm 3.2.0 level sdk code):
<strong>imports</strong></p>

<pre class="lang-golang prettyprint-override"><code>import (
    "log"

    "helm.sh/helm/v3/pkg/action"

    "k8s.io/cli-runtime/pkg/genericclioptions"
    "k8s.io/client-go/rest"
)
</code></pre>

<p><strong>ActionConfig</strong></p>

<pre class="lang-golang prettyprint-override"><code>func getActionConfig(namespace string) (*action.Configuration, error) {
    actionConfig := new(action.Configuration)
    var kubeConfig *genericclioptions.ConfigFlags
    // Create the rest config instance with ServiceAccount values loaded in them
    config, err := rest.InClusterConfig()
    if err != nil {
        return nil, err
    }
    // Create the ConfigFlags struct instance with initialized values from ServiceAccount
    kubeConfig = genericclioptions.NewConfigFlags(false)
    kubeConfig.APIServer = &amp;config.Host
    kubeConfig.BearerToken = &amp;config.BearerToken
    kubeConfig.CAFile = &amp;config.CAFile
    kubeConfig.Namespace = &amp;namespace
    if err := actionConfig.Init(kubeConfig, namespace, os.Getenv("HELM_DRIVER"), log.Printf); err != nil {
        return nil, err
    }
    return actionConfig, nil
}
</code></pre>

<p><strong>Usage</strong></p>

<pre class="lang-golang prettyprint-override"><code>actionConfig, kubeConfigFileFullPath, err := getActionConfig(namespace)
listAction := action.NewList(actionConfig)
releases, err := listAction.Run()
if err != nil {
    log.Println(err)
}
for _, release := range releases {
    log.Println("Release: " + release.Name + " Status: " + release.Info.Status.String())
}
</code></pre>

<p>It is not much different from what what you originally did, except the initialization of the actionConfig. It could also be that newer version fixed some issues. Let me know if this works for you.</p>
