<p>I'm trying to work with Istio from Go, and are using Kubernetes and Istio go-client code.</p>

<p>The problem I'm having is that I can't specify <code>ObjectMeta</code> or <code>TypeMeta</code> in my Istio-<code>ServiceRole</code> object. I can only specify <code>rules</code>, which are inside the <code>spec</code>.</p>

<p>Below you can see what I got working: </p>

<pre class="lang-golang prettyprint-override"><code>import (
    v1alpha1 "istio.io/api/rbac/v1alpha1"
)


func getDefaultServiceRole(app nais.Application) *v1alpha1.ServiceRole {
    return &amp;v1alpha1.ServiceRole{
        Rules: []*v1alpha1.AccessRule{
            {
                Ports: []int32{2},
            },
        },
    }
}
</code></pre>

<p>What I would like to do is have this code work:</p>

<pre class="lang-golang prettyprint-override"><code>func getDefaultServiceRole(app *nais.Application) *v1alpha1.ServiceRole {
    return &amp;v1alpha1.ServiceRole{
        TypeMeta: metav1.TypeMeta{
            Kind:       "ServiceRole",
            APIVersion: "v1alpha1",
        },
        ObjectMeta: metav1.ObjectMeta{
            Name:      app.Name,
            Namespace: app.Namespace,
        },
        Spec: v1alpha1.ServiceRole{
            Rules: []*v1alpha1.AccessRule{
                {
                    Ports: []int32{2},
                },
            },
        },
    },
}
</code></pre>

<p>Can anyone point me in the right direction?</p>

Kyrremann
<p>Istio now supports:</p>
<pre><code>import (
    istiov1alpha3 &quot;istio.io/api/networking/v1alpha3&quot;
    istiogov1alpha3 &quot;istio.io/client-go/pkg/apis/networking/v1alpha3&quot;
)

VirtualService := istiogov1alpha3.VirtualService{
        TypeMeta:   metav1.TypeMeta{
            Kind: &quot;VirtualService&quot;,
            APIVersion: &quot;networking.istio.io/v1alpha3&quot;,
        },
        ObjectMeta: metav1.ObjectMeta{
            Name: &quot;my-name&quot;,
        },
        Spec:       istiov1alpha3.VirtualService{},
}
</code></pre>
<p>Where <code>istiov1alpha3.VirtualService{}</code> is an istio object.</p>
