Skip to content

Instantly share code, notes, and snippets.

@tzununbekov
Created February 17, 2019 12:44
Show Gist options
  • Save tzununbekov/df2530be4db511d6bf05e711a6b80877 to your computer and use it in GitHub Desktop.
Save tzununbekov/df2530be4db511d6bf05e711a6b80877 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"time"
"github.com/ghodss/yaml"
"github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func main() {
tr := v1alpha1.TaskRun{
TypeMeta: metav1.TypeMeta{
Kind: "TaskRun",
APIVersion: "pipeline.knative.dev/v1beta1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "taskname",
Namespace: "default",
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: v1alpha1.TaskRunSpec{
TaskRef: &v1alpha1.TaskRef{
Name: "taskrefname",
},
Trigger: v1alpha1.TaskTrigger{
Type: v1alpha1.TaskTriggerTypePipelineRun,
Name: "testtriggername",
},
},
}
out, err := yaml.Marshal(tr)
if err != nil {
log.Fatal(err)
return
}
fmt.Printf("%s", out)
}
@cab105
Copy link

cab105 commented Feb 20, 2019

When I attempted to do something similar with the same block, I ran into:

cab@ptolamaios:/nfs-scratch/cab/clients/triggermesh/github-actions/foo$ go build
# _/nfs-scratch/cab/clients/triggermesh/github-actions/foo
./main.go:15:3: cannot use "k8s.io/apimachinery/pkg/apis/meta/v1".TypeMeta literal (type "k8s.io/apimachinery/pkg/apis/meta/v1".TypeMeta) as type "github.com/knative/build-pipeline/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".TypeMeta in field value
./main.go:19:3: cannot use "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta literal (type "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta) as type "github.com/knative/build-pipeline/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta in field value

Granted I just ran go get && go build however from what I've seen floating around this seems to be more of how the build-pipeline repo is handling their versioning.

@anatoliyfedorenko
Copy link

When I attempted to do something similar with the same block, I ran into:

cab@ptolamaios:/nfs-scratch/cab/clients/triggermesh/github-actions/foo$ go build
# _/nfs-scratch/cab/clients/triggermesh/github-actions/foo
./main.go:15:3: cannot use "k8s.io/apimachinery/pkg/apis/meta/v1".TypeMeta literal (type "k8s.io/apimachinery/pkg/apis/meta/v1".TypeMeta) as type "github.com/knative/build-pipeline/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".TypeMeta in field value
./main.go:19:3: cannot use "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta literal (type "k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta) as type "github.com/knative/build-pipeline/vendor/k8s.io/apimachinery/pkg/apis/meta/v1".ObjectMeta in field value

Granted I just ran go get && go build however from what I've seen floating around this seems to be more of how the build-pipeline repo is handling their versioning.

Seems like it is just a vendoring problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment