code
stringlengths 12
335k
| docstring
stringlengths 20
20.8k
| func_name
stringlengths 1
105
| language
stringclasses 1
value | repo
stringclasses 498
values | path
stringlengths 5
172
| url
stringlengths 43
235
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
func (in *ArtifactConfigs) DeepCopy() *ArtifactConfigs {
if in == nil {
return nil
}
out := new(ArtifactConfigs)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArtifactConfigs. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *BuilderConfig) DeepCopyInto(out *BuilderConfig) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *BuilderConfig) DeepCopy() *BuilderConfig {
if in == nil {
return nil
}
out := new(BuilderConfig)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuilderConfig. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *Config) DeepCopyInto(out *Config) {
*out = *in
in.Artifacts.DeepCopyInto(&out.Artifacts)
out.Storage = in.Storage
out.Signers = in.Signers
out.Builder = in.Builder
out.Transparency = in.Transparency
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *Config) DeepCopy() *Config {
if in == nil {
return nil
}
out := new(Config)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *DocDBStorageConfig) DeepCopyInto(out *DocDBStorageConfig) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *DocDBStorageConfig) DeepCopy() *DocDBStorageConfig {
if in == nil {
return nil
}
out := new(DocDBStorageConfig)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DocDBStorageConfig. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *GCSStorageConfig) DeepCopyInto(out *GCSStorageConfig) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *GCSStorageConfig) DeepCopy() *GCSStorageConfig {
if in == nil {
return nil
}
out := new(GCSStorageConfig)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCSStorageConfig. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *KMSSigner) DeepCopyInto(out *KMSSigner) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *KMSSigner) DeepCopy() *KMSSigner {
if in == nil {
return nil
}
out := new(KMSSigner)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KMSSigner. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *OCIStorageConfig) DeepCopyInto(out *OCIStorageConfig) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *OCIStorageConfig) DeepCopy() *OCIStorageConfig {
if in == nil {
return nil
}
out := new(OCIStorageConfig)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OCIStorageConfig. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *SignerConfigs) DeepCopyInto(out *SignerConfigs) {
*out = *in
out.X509 = in.X509
out.KMS = in.KMS
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *SignerConfigs) DeepCopy() *SignerConfigs {
if in == nil {
return nil
}
out := new(SignerConfigs)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SignerConfigs. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *StorageConfigs) DeepCopyInto(out *StorageConfigs) {
*out = *in
out.GCS = in.GCS
out.OCI = in.OCI
out.Tekton = in.Tekton
out.DocDB = in.DocDB
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *StorageConfigs) DeepCopy() *StorageConfigs {
if in == nil {
return nil
}
out := new(StorageConfigs)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageConfigs. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *StorageOpts) DeepCopyInto(out *StorageOpts) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *StorageOpts) DeepCopy() *StorageOpts {
if in == nil {
return nil
}
out := new(StorageOpts)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageOpts. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *TektonStorageConfig) DeepCopyInto(out *TektonStorageConfig) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *TektonStorageConfig) DeepCopy() *TektonStorageConfig {
if in == nil {
return nil
}
out := new(TektonStorageConfig)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TektonStorageConfig. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *TransparencyConfig) DeepCopyInto(out *TransparencyConfig) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *TransparencyConfig) DeepCopy() *TransparencyConfig {
if in == nil {
return nil
}
out := new(TransparencyConfig)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TransparencyConfig. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *X509Signer) DeepCopyInto(out *X509Signer) {
*out = *in
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func (in *X509Signer) DeepCopy() *X509Signer {
if in == nil {
return nil
}
out := new(X509Signer)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new X509Signer. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/zz_generated.deepcopy.go | Apache-2.0 |
func NewConfigFromMap(data map[string]string) (*Config, error) {
cfg := defaultConfig()
if err := cm.Parse(data,
// Artifact-specific configs
// TaskRuns
asString(taskrunFormatKey, &cfg.Artifacts.TaskRuns.Format, "in-toto", "slsa/v1", "slsa/v2alpha3", "slsa/v2alpha4"),
asStringSet(taskrunStorageKey, &cfg.Artifacts.TaskRuns.StorageBackend, sets.New[string]("tekton", "oci", "gcs", "docdb", "grafeas", "kafka")),
asString(taskrunSignerKey, &cfg.Artifacts.TaskRuns.Signer, "x509", "kms"),
// PipelineRuns
asString(pipelinerunFormatKey, &cfg.Artifacts.PipelineRuns.Format, "in-toto", "slsa/v1", "slsa/v2alpha3", "slsa/v2alpha4"),
asStringSet(pipelinerunStorageKey, &cfg.Artifacts.PipelineRuns.StorageBackend, sets.New[string]("tekton", "oci", "gcs", "docdb", "grafeas")),
asString(pipelinerunSignerKey, &cfg.Artifacts.PipelineRuns.Signer, "x509", "kms"),
asBool(pipelinerunEnableDeepInspectionKey, &cfg.Artifacts.PipelineRuns.DeepInspectionEnabled),
// OCI
asString(ociFormatKey, &cfg.Artifacts.OCI.Format, "simplesigning"),
asStringSet(ociStorageKey, &cfg.Artifacts.OCI.StorageBackend, sets.New[string]("tekton", "oci", "gcs", "docdb", "grafeas", "kafka")),
asString(ociSignerKey, &cfg.Artifacts.OCI.Signer, "x509", "kms"),
// PubSub - General
asString(pubsubProvider, &cfg.Storage.PubSub.Provider, "inmemory", "kafka"),
asString(pubsubTopic, &cfg.Storage.PubSub.Topic),
// PubSub - Kafka
asString(pubsubKafkaBootstrapServer, &cfg.Storage.PubSub.Kafka.BootstrapServers),
// Storage level configs
asString(gcsBucketKey, &cfg.Storage.GCS.Bucket),
asString(ociRepositoryKey, &cfg.Storage.OCI.Repository),
asBool(ociRepositoryInsecureKey, &cfg.Storage.OCI.Insecure),
asString(docDBUrlKey, &cfg.Storage.DocDB.URL),
asString(docDBMongoServerURLKey, &cfg.Storage.DocDB.MongoServerURL),
asString(docDBMongoServerURLDirKey, &cfg.Storage.DocDB.MongoServerURLDir),
asString(docDBMongoServerURLPathKey, &cfg.Storage.DocDB.MongoServerURLPath),
asString(grafeasProjectIDKey, &cfg.Storage.Grafeas.ProjectID),
asString(grafeasNoteIDKey, &cfg.Storage.Grafeas.NoteID),
asString(grafeasNoteHint, &cfg.Storage.Grafeas.NoteHint),
oneOf(transparencyEnabledKey, &cfg.Transparency.Enabled, "true", "manual"),
oneOf(transparencyEnabledKey, &cfg.Transparency.VerifyAnnotation, "manual"),
asString(transparencyURLKey, &cfg.Transparency.URL),
asString(kmsSignerKMSRef, &cfg.Signers.KMS.KMSRef),
asString(kmsAuthAddress, &cfg.Signers.KMS.Auth.Address),
asString(kmsAuthToken, &cfg.Signers.KMS.Auth.Token),
asString(kmsAuthTokenPath, &cfg.Signers.KMS.Auth.TokenPath),
asString(kmsAuthOIDCPath, &cfg.Signers.KMS.Auth.OIDC.Path),
asString(kmsAuthOIDCRole, &cfg.Signers.KMS.Auth.OIDC.Role),
asString(kmsAuthSpireSock, &cfg.Signers.KMS.Auth.Spire.Sock),
asString(kmsAuthSpireAudience, &cfg.Signers.KMS.Auth.Spire.Audience),
// Fulcio
asBool(x509SignerFulcioEnabled, &cfg.Signers.X509.FulcioEnabled),
asString(x509SignerFulcioAddr, &cfg.Signers.X509.FulcioAddr),
asString(x509SignerFulcioOIDCIssuer, &cfg.Signers.X509.FulcioOIDCIssuer),
asString(x509SignerFulcioProvider, &cfg.Signers.X509.FulcioProvider),
asString(x509SignerIdentityTokenFile, &cfg.Signers.X509.IdentityTokenFile),
asString(x509SignerTUFMirrorURL, &cfg.Signers.X509.TUFMirrorURL),
// Build config
asString(builderIDKey, &cfg.Builder.ID),
// Build type
asString(buildTypeKey, &cfg.BuildDefinition.BuildType, "https://tekton.dev/chains/v2/slsa", "https://tekton.dev/chains/v2/slsa-tekton"),
); err != nil {
return nil, fmt.Errorf("failed to parse data: %w", err)
}
return cfg, nil
} | NewConfigFromMap creates a Config from the supplied map | NewConfigFromMap | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/config.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/config.go | Apache-2.0 |
func NewConfigFromConfigMap(configMap *corev1.ConfigMap) (*Config, error) {
return NewConfigFromMap(configMap.Data)
} | NewConfigFromConfigMap creates a Config from the supplied ConfigMap | NewConfigFromConfigMap | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/config.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/config.go | Apache-2.0 |
func oneOf(key string, target *bool, values ...string) cm.ParseFunc {
return func(data map[string]string) error {
raw, ok := data[key]
if !ok {
return nil
}
if values == nil {
return nil
}
for _, v := range values {
if v == raw {
*target = true
}
}
return nil
}
} | oneOf sets target to true if it maches any of the values | oneOf | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/config.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/config.go | Apache-2.0 |
func asBool(key string, target *bool) cm.ParseFunc {
return func(data map[string]string) error {
raw, ok := data[key]
if !ok {
return nil
}
val, err := strconv.ParseBool(raw)
if err == nil {
*target = val
return nil
}
return nil
}
} | allow additional supported values for a "true" decision
in additional to the usual ones provided by strconv.ParseBool | asBool | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/config.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/config.go | Apache-2.0 |
func asString(key string, target *string, values ...string) cm.ParseFunc {
return func(data map[string]string) error {
raw, ok := data[key]
if !ok {
return nil
}
if len(values) > 0 {
vals := sets.New[string](values...)
if !vals.Has(raw) {
return fmt.Errorf("invalid value %q wanted one of %v", raw, sets.List[string](vals))
}
}
*target = raw
return nil
}
} | asString passes the value at key through into the target, if it exists.
TODO(mattmoor): This might be a nice variation on cm.AsString to upstream. | asString | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/config.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/config.go | Apache-2.0 |
func asStringSet(key string, target *sets.Set[string], allowed sets.Set[string]) cm.ParseFunc {
return func(data map[string]string) error {
if raw, ok := data[key]; ok {
if raw == "" {
*target = sets.New[string]("")
return nil
}
splitted := strings.Split(raw, ",")
if allowed.Len() > 0 {
for i, v := range splitted {
splitted[i] = strings.TrimSpace(v)
if !allowed.Has(splitted[i]) {
return fmt.Errorf("invalid value %q wanted one of %v", splitted[i], sets.List[string](allowed))
}
}
}
*target = sets.New[string](splitted...)
}
return nil
}
} | asStringSet parses the value at key as a sets.Set[string] (split by ',') into the target, if it exists. | asStringSet | go | tektoncd/cli | vendor/github.com/tektoncd/chains/pkg/config/config.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/chains/pkg/config/config.go | Apache-2.0 |
func SetupFakeContext(t *testing.T) (context.Context, []controller.Informer) {
t.Helper()
ctx, _, informer := setupFakeContextWithLabelKey(t)
return WithLogger(ctx, t), informer
} | SetupFakeContext sets up the Context and the fake filtered informers for the tests. | SetupFakeContext | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | Apache-2.0 |
func SetupFakeCloudClientContext(ctx context.Context, expectedEventCount int) context.Context {
cloudEventClientBehaviour := cloudevent.FakeClientBehaviour{
SendSuccessfully: true,
}
return cloudevent.WithFakeClient(ctx, &cloudEventClientBehaviour, expectedEventCount)
} | SetupFakeCloudClientContext sets up the fakeclient to context | SetupFakeCloudClientContext | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | Apache-2.0 |
func SetupDefaultContext(t *testing.T) (context.Context, []controller.Informer) {
t.Helper()
ctx, _, informer := setupDefaultContextWithLabelKey(t)
return WithLogger(ctx, t), informer
} | SetupDefaultContext sets up the Context and the default filtered informers for the tests. | SetupDefaultContext | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | Apache-2.0 |
func WithLogger(ctx context.Context, t *testing.T) context.Context {
t.Helper()
return logging.WithLogger(ctx, TestLogger(t))
} | WithLogger returns the Logger | WithLogger | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | Apache-2.0 |
func setupFakeContextWithLabelKey(t zaptest.TestingT) (context.Context, context.CancelFunc, []controller.Informer) {
ctx, c := context.WithCancel(logtesting.TestContextWithLogger(t))
ctx = controller.WithEventRecorder(ctx, record.NewFakeRecorder(1000))
ctx = filteredinformerfactory.WithSelectors(ctx, v1.ManagedByLabelKey)
ctx, is := injection.Fake.SetupInformers(ctx, &rest.Config{})
return ctx, c, is
} | setupFakeContextWithLabelKey sets up the Context and the fake informers for the tests
The provided context includes the FilteredInformerFactory LabelKey. | setupFakeContextWithLabelKey | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | Apache-2.0 |
func setupDefaultContextWithLabelKey(t zaptest.TestingT) (context.Context, context.CancelFunc, []controller.Informer) {
ctx, c := context.WithCancel(logtesting.TestContextWithLogger(t))
ctx = filteredinformerfactory.WithSelectors(ctx, v1.ManagedByLabelKey)
ctx, is := injection.Default.SetupInformers(ctx, &rest.Config{})
return ctx, c, is
} | setupDefaultContextWithLabelKey sets up the Context and the default informers for the tests
The provided context includes the FilteredInformerFactory LabelKey. | setupDefaultContextWithLabelKey | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/logger.go | Apache-2.0 |
func ConfigMapFromTestFile(t *testing.T, name string) *corev1.ConfigMap {
t.Helper()
b, err := os.ReadFile(fmt.Sprintf("testdata/%s.yaml", name))
if err != nil {
t.Fatalf("ReadFile() = %v", err)
}
var cm corev1.ConfigMap
// Use "sigs.k8s.io/yaml" since it reads json struct
// tags so things unmarshal properly
if err := yaml.Unmarshal(b, &cm); err != nil {
t.Fatalf("yaml.Unmarshal() = %v", err)
}
return &cm
} | ConfigMapFromTestFile creates a v1.ConfigMap from a YAML file
It loads the YAML file from the testdata folder. | ConfigMapFromTestFile | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/configmap.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/configmap.go | Apache-2.0 |
func EnableFeatureFlagField(ctx context.Context, t *testing.T, flagName string) context.Context {
t.Helper()
featureFlags, err := config.NewFeatureFlagsFromMap(map[string]string{
flagName: "true",
})
if err != nil {
t.Fatalf("Fail to create a feature config: %v", err)
}
cfg := &config.Config{
FeatureFlags: featureFlags,
}
return config.ToContext(ctx, cfg)
} | EnableFeatureFlagField enables a boolean feature flag in an existing context (for use in testing). | EnableFeatureFlagField | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/configmap.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/testing/configmap.go | Apache-2.0 |
func EmitCloudEvents(ctx context.Context, object runtime.Object) {
logger := logging.FromContext(ctx)
if sink := cloudEventsSink(ctx); sink != "" {
ctx = cloudevents.ContextWithTarget(ctx, sink)
err := SendCloudEventWithRetries(ctx, object)
if err != nil {
logger.Warnf("Failed to emit cloud events %v", err.Error())
}
}
} | EmitCloudEvents emits CloudEvents (only) for object | EmitCloudEvents | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloud_event_controller.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloud_event_controller.go | Apache-2.0 |
func EmitCloudEventsWhenConditionChange(ctx context.Context, beforeCondition *apis.Condition, afterCondition *apis.Condition, object runtime.Object) {
logger := logging.FromContext(ctx)
if sink := cloudEventsSink(ctx); sink != "" {
ctx = cloudevents.ContextWithTarget(ctx, sink)
// Only send events if the new condition represents a change
if !equality.Semantic.DeepEqual(beforeCondition, afterCondition) {
err := SendCloudEventWithRetries(ctx, object)
if err != nil {
logger.Warnf("Failed to emit cloud events %v", err.Error())
}
}
}
} | EmitCloudEventsWhenConditionChange emits CloudEvents when there is a change in condition | EmitCloudEventsWhenConditionChange | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloud_event_controller.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloud_event_controller.go | Apache-2.0 |
func SendCloudEventWithRetries(ctx context.Context, object runtime.Object) error {
var (
o objectWithCondition
ok bool
cacheClient *lru.Cache
)
if o, ok = object.(objectWithCondition); !ok {
return errors.New("input object does not satisfy objectWithCondition")
}
logger := logging.FromContext(ctx)
ceClient := Get(ctx)
if ceClient == nil {
return errors.New("no cloud events client found in the context")
}
event, err := EventForObjectWithCondition(ctx, o)
if err != nil {
return err
}
// Events for CustomRuns require a cache of events that have been sent
_, isCustomRun := object.(*v1beta1.CustomRun)
if isCustomRun {
cacheClient = cache.Get(ctx)
}
wasIn := make(chan error)
ceClient.addCount()
go func() {
defer ceClient.decreaseCount()
wasIn <- nil
logger.Debugf("Sending cloudevent of type %q", event.Type())
// In case of Run event, check cache if cloudevent is already sent
if isCustomRun {
cloudEventSent, err := cache.ContainsOrAddCloudEvent(cacheClient, event)
if err != nil {
logger.Errorf("Error while checking cache: %s", err)
}
if cloudEventSent {
logger.Infof("cloudevent %v already sent", event)
return
}
}
if result := ceClient.Send(cloudevents.ContextWithRetriesExponentialBackoff(ctx, 10*time.Millisecond, 10), *event); !cloudevents.IsACK(result) {
logger.Warnf("Failed to send cloudevent: %s", result.Error())
recorder := controller.GetEventRecorder(ctx)
if recorder == nil {
logger.Warnf("No recorder in context, cannot emit error event")
return
}
recorder.Event(object, corev1.EventTypeWarning, "Cloud Event Failure", result.Error())
}
}()
return <-wasIn
} | SendCloudEventWithRetries sends a cloud event for the specified resource.
It does not block and it perform retries with backoff using the cloudevents
sdk-go capabilities.
It accepts a runtime.Object to avoid making objectWithCondition public since
it's only used within the events/cloudevents packages. | SendCloudEventWithRetries | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloud_event_controller.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloud_event_controller.go | Apache-2.0 |
func (c CloudClient) addCount() {
} | AddCount does nothing | addCount | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | Apache-2.0 |
func (c CloudClient) decreaseCount() {
} | DecreaseCount does nothing | decreaseCount | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | Apache-2.0 |
func (c CloudClient) Send(ctx context.Context, event cloudevents.Event) protocol.Result {
return c.client.Send(ctx, event)
} | Send invokes call client.Send | Send | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | Apache-2.0 |
func (c CloudClient) Request(ctx context.Context, event event.Event) (*cloudevents.Event, protocol.Result) {
return c.client.Request(ctx, event)
} | Request invokes client.Request | Request | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | Apache-2.0 |
func (c CloudClient) StartReceiver(ctx context.Context, fn interface{}) error {
return c.client.StartReceiver(ctx, fn)
} | StartReceiver invokes client.StartReceiver | StartReceiver | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | Apache-2.0 |
func Get(ctx context.Context) CEClient {
untyped := ctx.Value(ceKey{})
if untyped == nil {
logging.FromContext(ctx).Errorf(
"Unable to fetch client from context.")
return nil
}
return untyped.(CEClient)
} | Get extracts the cloudEventClient client from the context. | Get | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | Apache-2.0 |
func ToContext(ctx context.Context, cec CEClient) context.Context {
return context.WithValue(ctx, ceKey{}, cec)
} | ToContext adds the cloud events client to the context | ToContext | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventclient.go | Apache-2.0 |
func newTektonCloudEventData(ctx context.Context, runObject objectWithCondition) (TektonCloudEventData, error) {
tektonCloudEventData := TektonCloudEventData{}
switch v := runObject.(type) {
case *v1beta1.TaskRun:
tektonCloudEventData.TaskRun = v
case *v1beta1.PipelineRun:
tektonCloudEventData.PipelineRun = v
case *v1.TaskRun:
v1beta1TaskRun := &v1beta1.TaskRun{}
if err := v1beta1TaskRun.ConvertFrom(ctx, v); err != nil {
return TektonCloudEventData{}, err
}
tektonCloudEventData.TaskRun = v1beta1TaskRun
case *v1.PipelineRun:
v1beta1PipelineRun := &v1beta1.PipelineRun{}
if err := v1beta1PipelineRun.ConvertFrom(ctx, v); err != nil {
return TektonCloudEventData{}, err
}
tektonCloudEventData.PipelineRun = v1beta1PipelineRun
case *v1beta1.CustomRun:
tektonCloudEventData.CustomRun = v
} | newTektonCloudEventData returns a new instance of TektonCloudEventData | newTektonCloudEventData | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudevent.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudevent.go | Apache-2.0 |
func EventForObjectWithCondition(ctx context.Context, runObject objectWithCondition) (*cloudevents.Event, error) {
event := cloudevents.NewEvent()
event.SetID(uuid.New().String())
event.SetSubject(runObject.GetObjectMeta().GetName())
// TODO: SelfLink is deprecated https://github.com/tektoncd/pipeline/issues/2676
source := runObject.GetObjectMeta().GetSelfLink()
if source == "" {
gvk := runObject.GetObjectKind().GroupVersionKind()
source = fmt.Sprintf("/apis/%s/%s/namespaces/%s/%s/%s",
gvk.Group,
gvk.Version,
runObject.GetObjectMeta().GetNamespace(),
gvk.Kind,
runObject.GetObjectMeta().GetName())
}
event.SetSource(source)
eventType, err := getEventType(runObject)
if err != nil {
return nil, err
}
if eventType == nil {
return nil, errors.New("no matching event type found")
}
event.SetType(eventType.String())
tektonCloudEventData, err := newTektonCloudEventData(ctx, runObject)
if err != nil {
return nil, err
}
if err := event.SetData(cloudevents.ApplicationJSON, tektonCloudEventData); err != nil {
return nil, err
}
return &event, nil
} | EventForObjectWithCondition creates a new event based for an objectWithCondition,
or returns an error if not possible. | EventForObjectWithCondition | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudevent.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudevent.go | Apache-2.0 |
func GetCloudEventDeliveryCompareOptions() []cmp.Option {
// Setup cmp options
cloudDeliveryStateCompare := func(x, y v1beta1.CloudEventDeliveryState) bool {
return cmp.Equal(x.Condition, y.Condition) && cmp.Equal(x.RetryCount, y.RetryCount)
}
less := func(x, y v1beta1.CloudEventDelivery) bool {
return strings.Compare(x.Target, y.Target) < 0 || (strings.Compare(x.Target, y.Target) == 0 && x.Status.SentAt.Before(y.Status.SentAt))
}
return []cmp.Option{
cmpopts.SortSlices(less),
cmp.Comparer(func(x, y v1beta1.CloudEventDelivery) bool {
return (strings.Compare(x.Target, y.Target) == 0) && cloudDeliveryStateCompare(x.Status, y.Status)
}),
}
} | GetCloudEventDeliveryCompareOptions returns compare options to sort
and compare a list of CloudEventDelivery | GetCloudEventDeliveryCompareOptions | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudevent.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudevent.go | Apache-2.0 |
func newFakeClient(behaviour *FakeClientBehaviour, expectedEventCount int) CEClient {
return FakeClient{
behaviour: behaviour,
// set buffersize to length of want events to make sure no extra events are sent
events: make(chan string, expectedEventCount),
waitGroup: &sync.WaitGroup{},
}
} | newFakeClient is a FakeClient factory, it returns a client for the target | newFakeClient | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | Apache-2.0 |
func (c FakeClient) Send(ctx context.Context, event cloudevents.Event) protocol.Result {
if c.behaviour.SendSuccessfully {
// This is to prevent extra events are sent. We don't read events from channel before we call CheckCloudEventsUnordered
if len(c.events) < cap(c.events) {
c.events <- event.String()
return nil
}
return fmt.Errorf("channel is full of size:%v, but extra event wants to be sent:%v", cap(c.events), event)
}
return fmt.Errorf("had to fail. Event ID: %s", event.ID())
} | Send fakes the Send method from cloudevents.Client | Send | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | Apache-2.0 |
func (c FakeClient) Request(ctx context.Context, event cloudevents.Event) (*cloudevents.Event, protocol.Result) {
if c.behaviour.SendSuccessfully {
if len(c.events) < cap(c.events) {
c.events <- event.String()
return &event, nil
}
return nil, fmt.Errorf("channel is full of size:%v, but extra event wants to be sent:%v", cap(c.events), event)
}
return nil, fmt.Errorf("had to fail. Event ID: %s", event.ID())
} | Request fakes the Request method from cloudevents.Client | Request | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | Apache-2.0 |
func (c FakeClient) StartReceiver(ctx context.Context, fn interface{}) error {
return nil
} | StartReceiver fakes StartReceiver method from cloudevents.Client | StartReceiver | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | Apache-2.0 |
func (c FakeClient) addCount() {
c.waitGroup.Add(1)
} | addCount can be used to add the count when each event is going to be sent | addCount | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | Apache-2.0 |
func (c FakeClient) decreaseCount() {
c.waitGroup.Done()
} | decreaseCount can be used to the decrease the count when each event is sent | decreaseCount | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | Apache-2.0 |
func WithFakeClient(ctx context.Context, behaviour *FakeClientBehaviour, expectedEventCount int) context.Context {
return context.WithValue(ctx, ceKey{}, newFakeClient(behaviour, expectedEventCount))
} | WithFakeClient adds to the context a fake client with the desired behaviour and expectedEventCount | WithFakeClient | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | Apache-2.0 |
func (c *FakeClient) CheckCloudEventsUnordered(t *testing.T, testName string, wantEvents []string) {
t.Helper()
c.waitGroup.Wait()
expected := append([]string{}, wantEvents...)
channelEvents := len(c.events)
// extra events are prevented in FakeClient's Send function.
// fewer events are detected because we collect all events from channel and compare with wantEvents
for range channelEvents {
event := <-c.events
if len(expected) == 0 {
t.Errorf("extra event received: %q", event)
}
found := false
for wantIdx, want := range expected {
matching, err := regexp.MatchString(want, event)
if err != nil {
t.Errorf("something went wrong matching an event: %s", err)
}
if matching {
found = true
// Remove event from list of those we expect to receive
expected[wantIdx] = expected[len(expected)-1]
expected = expected[:len(expected)-1]
break
}
}
if !found {
t.Errorf("unexpected event received: %q", event)
}
}
if len(expected) != 0 {
t.Errorf("%d events %#v are not received", len(expected), expected)
}
} | CheckCloudEventsUnordered checks that all events in wantEvents, and no others,
were received via the given chan, in any order.
Block until all events have been sent. | CheckCloudEventsUnordered | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent/cloudeventsfakeclient.go | Apache-2.0 |
func Get(ctx context.Context) *lru.Cache {
untyped := ctx.Value(cacheKey{})
if untyped == nil {
logging.FromContext(ctx).Errorf("Unable to fetch client from context.")
return nil
}
return untyped.(*lru.Cache)
} | Get extracts the cloudEventClient client from the context. | Get | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cache/cacheclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cache/cacheclient.go | Apache-2.0 |
func ToContext(ctx context.Context, c *lru.Cache) context.Context {
return context.WithValue(ctx, cacheKey{}, c)
} | ToContext adds the cloud events client to the context | ToContext | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cache/cacheclient.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cache/cacheclient.go | Apache-2.0 |
func ContainsOrAddCloudEvent(cacheClient *lru.Cache, event *cloudevents.Event) (bool, error) {
if cacheClient == nil {
return false, errors.New("cache client is nil")
}
eventKey, err := EventKey(event)
if err != nil {
return false, err
}
isPresent, _ := cacheClient.ContainsOrAdd(eventKey, nil)
return isPresent, nil
} | ContainsOrAddCloudEvent checks if the event exists in the cache | ContainsOrAddCloudEvent | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cache/cache.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cache/cache.go | Apache-2.0 |
func EventKey(event *cloudevents.Event) (string, error) {
var (
data eventData
resourceName string
resourceNamespace string
resourceKind string
)
err := json.Unmarshal(event.Data(), &data)
if err != nil {
return "", err
}
if data.CustomRun == nil {
return "", fmt.Errorf("invalid CustomRun data in %v", event)
}
resourceName = data.CustomRun.Name
resourceNamespace = data.CustomRun.Namespace
resourceKind = "customrun"
eventType := event.Type()
return fmt.Sprintf("%s/%s/%s/%s", eventType, resourceKind, resourceNamespace, resourceName), nil
} | EventKey defines whether an event is considered different from another
in future we might want to let specific event types override this | EventKey | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cache/cache.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/events/cache/cache.go | Apache-2.0 |
func newGraph() *Graph {
return &Graph{Nodes: map[string]*Node{}}
} | Returns an empty Pipeline Graph | newGraph | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go | Apache-2.0 |
func Build(tasks Tasks, deps map[string][]string) (*Graph, error) {
d := newGraph()
// Add all Tasks mentioned in the `PipelineSpec`
for _, pt := range tasks.Items() {
if _, err := d.addPipelineTask(pt); err != nil {
return nil, fmt.Errorf("task %s is already present in Graph, can't add it again: %w", pt.HashKey(), err)
}
}
// Ensure no cycles in the graph
if err := findCyclesInDependencies(deps); err != nil {
return nil, fmt.Errorf("cycle detected; %w", err)
}
// Process all from and runAfter constraints to add task dependency
for pt, taskDeps := range deps {
for _, previousTask := range taskDeps {
if err := addLink(pt, previousTask, d.Nodes); err != nil {
return nil, fmt.Errorf("couldn't add link between %s and %s: %w", pt, previousTask, err)
}
}
}
return d, nil
} | Build returns a valid pipeline Graph. Returns error if the pipeline is invalid | Build | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go | Apache-2.0 |
func GetCandidateTasks(g *Graph, doneTasks ...string) (sets.String, error) {
roots := getRoots(g)
tm := sets.NewString(doneTasks...)
d := sets.NewString()
visited := sets.NewString()
for _, root := range roots {
schedulable := findSchedulable(root, visited, tm)
for _, taskName := range schedulable {
d.Insert(taskName)
}
}
var visitedNames []string
for v := range visited {
visitedNames = append(visitedNames, v)
}
notVisited := list.DiffLeft(doneTasks, visitedNames)
if len(notVisited) > 0 {
return nil, fmt.Errorf("invalid list of done tasks; some tasks were indicated completed without ancestors being done: %v", notVisited)
}
return d, nil
} | GetCandidateTasks returns a set of names of PipelineTasks whose ancestors are all completed,
given a list of finished doneTasks. If the specified
doneTasks are invalid (i.e. if it is indicated that a Task is done, but the
previous Tasks are not done), an error is returned. | GetCandidateTasks | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go | Apache-2.0 |
func findCyclesInDependencies(deps map[string][]string) error {
independentTasks := sets.NewString()
dag := make(map[string]sets.String, len(deps))
childMap := make(map[string]sets.String, len(deps))
for task, taskDeps := range deps {
if len(taskDeps) == 0 {
continue
}
dag[task] = sets.NewString(taskDeps...)
for _, dep := range taskDeps {
if len(deps[dep]) == 0 {
independentTasks.Insert(dep)
}
if children, ok := childMap[dep]; ok {
children.Insert(task)
} else {
childMap[dep] = sets.NewString(task)
}
}
}
for {
parent, ok := independentTasks.PopAny()
if !ok {
break
}
children := childMap[parent]
for {
child, ok := children.PopAny()
if !ok {
break
}
dag[child].Delete(parent)
if dag[child].Len() == 0 {
independentTasks.Insert(child)
delete(dag, child)
}
}
}
return getInterdependencyError(dag)
} | use Kahn's algorithm to find cycles in dependencies | findCyclesInDependencies | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag/dag.go | Apache-2.0 |
func NewResolver(ref string, keychain authn.Keychain) remote.Resolver {
return &Resolver{imageReference: ref, keychain: keychain, timeout: time.Second * 60}
} | NewResolver is a convenience function to return a new OCI resolver instance as a remote.Resolver with a short, 1m
timeout for resolving an individual image. | NewResolver | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | Apache-2.0 |
func (o *Resolver) List(ctx context.Context) ([]remote.ResolvedObject, error) {
timeoutCtx, cancel := context.WithTimeout(ctx, o.timeout)
defer cancel()
img, err := o.retrieveImage(timeoutCtx)
if err != nil {
return nil, err
}
manifest, err := img.Manifest()
if err != nil {
return nil, fmt.Errorf("Could not parse image manifest: %w", err)
}
if err := o.checkImageCompliance(manifest); err != nil {
return nil, err
}
contents := make([]remote.ResolvedObject, 0, len(manifest.Layers))
for _, l := range manifest.Layers {
contents = append(contents, remote.ResolvedObject{
Kind: l.Annotations[KindAnnotation],
APIVersion: l.Annotations[APIVersionAnnotation],
Name: l.Annotations[TitleAnnotation],
})
}
return contents, nil
} | List retrieves a flat set of Tekton objects | List | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | Apache-2.0 |
func (o *Resolver) Get(ctx context.Context, kind, name string) (runtime.Object, *pipelinev1.RefSource, error) {
timeoutCtx, cancel := context.WithTimeout(ctx, o.timeout)
defer cancel()
img, err := o.retrieveImage(timeoutCtx)
if err != nil {
return nil, nil, err
}
manifest, err := img.Manifest()
if err != nil {
return nil, nil, fmt.Errorf("could not parse image manifest: %w", err)
}
if err := o.checkImageCompliance(manifest); err != nil {
return nil, nil, err
}
layers, err := img.Layers()
if err != nil {
return nil, nil, fmt.Errorf("could not read image layers: %w", err)
}
layerMap := map[string]v1.Layer{}
for _, l := range layers {
digest, err := l.Digest()
if err != nil {
return nil, nil, fmt.Errorf("failed to find digest for layer: %w", err)
}
layerMap[digest.String()] = l
}
for idx, l := range manifest.Layers {
lKind := l.Annotations[KindAnnotation]
lName := l.Annotations[TitleAnnotation]
if kind == lKind && name == lName {
obj, err := readTarLayer(layerMap[l.Digest.String()])
if err != nil {
// This could still be a raw layer so try to read it as that instead.
obj, err := readRawLayer(layers[idx])
return obj, nil, err
}
return obj, nil, nil
}
}
return nil, nil, fmt.Errorf("could not find object in image with kind: %s and name: %s", kind, name)
} | Get retrieves a specific object with the given Kind and name | Get | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | Apache-2.0 |
func (o *Resolver) retrieveImage(ctx context.Context) (v1.Image, error) {
imgRef, err := imgname.ParseReference(o.imageReference)
if err != nil {
return nil, fmt.Errorf("%s is an unparseable image reference: %w", o.imageReference, err)
}
return ociremote.Image(imgRef, ociremote.WithAuthFromKeychain(o.keychain), ociremote.WithContext(ctx))
} | retrieveImage will fetch the image's contents and manifest. | retrieveImage | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | Apache-2.0 |
func (o *Resolver) checkImageCompliance(manifest *v1.Manifest) error {
// Check the manifest's layers to ensure there are a maximum of 10.
if len(manifest.Layers) > MaximumBundleObjects {
return fmt.Errorf("bundle %s contained more than the maximum %d allow objects", o.imageReference, MaximumBundleObjects)
}
// Ensure each layer complies to the spec.
for _, l := range manifest.Layers {
refDigest := fmt.Sprintf("%s:%s", o.imageReference, l.Digest.String())
if _, ok := l.Annotations[APIVersionAnnotation]; !ok {
return fmt.Errorf("invalid tekton bundle: %s does not contain a %s annotation", refDigest, APIVersionAnnotation)
}
if _, ok := l.Annotations[TitleAnnotation]; !ok {
return fmt.Errorf("invalid tekton bundle: %s does not contain a %s annotation", refDigest, TitleAnnotation)
}
kind, ok := l.Annotations[KindAnnotation]
if !ok {
return fmt.Errorf("invalid tekton bundle: %s does not contain a %s annotation", refDigest, KindAnnotation)
}
if strings.TrimSuffix(strings.ToLower(kind), "s") != kind {
return fmt.Errorf("invalid tekton bundle: %s annotation for %s must be lowercased and singular, found %s", KindAnnotation, refDigest, kind)
}
}
return nil
} | checkImageCompliance will perform common checks to ensure the Tekton Bundle is compliant to our spec. | checkImageCompliance | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | Apache-2.0 |
func readTarLayer(layer v1.Layer) (runtime.Object, error) {
rc, err := layer.Uncompressed()
if err != nil {
return nil, fmt.Errorf("Failed to read image layer: %w", err)
}
defer rc.Close()
// If the user bundled this up as a tar file then we need to untar it.
treader := tar.NewReader(rc)
header, err := treader.Next()
if err != nil {
return nil, errors.New("layer is not a tarball")
}
contents := make([]byte, header.Size)
if _, err := treader.Read(contents); err != nil && !errors.Is(err, io.EOF) {
// We only allow 1 resource per layer so this tar bundle should have one and only one file.
return nil, fmt.Errorf("failed to read tar bundle: %w", err)
}
obj, _, err := scheme.Codecs.UniversalDeserializer().Decode(contents, nil, nil)
return obj, err
} | Utility function to read out the contents of an image layer, assumed to be a tarball, as a parsed Tekton resource. | readTarLayer | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | Apache-2.0 |
func readRawLayer(layer v1.Layer) (runtime.Object, error) {
rc, err := layer.Uncompressed()
if err != nil {
return nil, fmt.Errorf("failed to read image layer: %w", err)
}
defer rc.Close()
contents, err := io.ReadAll(rc)
if err != nil {
return nil, fmt.Errorf("could not read contents of image layer: %w", err)
}
obj, _, err := scheme.Codecs.UniversalDeserializer().Decode(contents, nil, nil)
return obj, err
} | Utility function to read out the contents of an image layer, assumed to be raw bytes, as a parsed Tekton resource. | readRawLayer | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/remote/oci/resolver.go | Apache-2.0 |
func SerializeToMetadata(meta *metav1.ObjectMeta, field interface{}, key string) error {
bytes, err := json.Marshal(field)
if err != nil {
return fmt.Errorf("error serializing field: %w", err)
}
if meta.Annotations == nil {
meta.Annotations = make(map[string]string)
}
meta.Annotations[key] = string(bytes)
return nil
} | SerializeToMetadata serializes the input field and adds it as an annotation to
the metadata under the input key. | SerializeToMetadata | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/version/conversion.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/version/conversion.go | Apache-2.0 |
func DeserializeFromMetadata(meta *metav1.ObjectMeta, to interface{}, key string) error {
if meta == nil || meta.Annotations == nil {
return nil
}
if str, ok := meta.Annotations[key]; ok {
if err := json.Unmarshal([]byte(str), to); err != nil {
return fmt.Errorf("error deserializing key %s from metadata: %w", key, err)
}
delete(meta.Annotations, key)
if len(meta.Annotations) == 0 {
meta.Annotations = nil
}
}
return nil
} | DeserializeFromMetadata takes the value of the input key from the metadata's annotations,
deserializes it into "to", and removes the key from the metadata's annotations.
Returns nil if the key is not present in the annotations. | DeserializeFromMetadata | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/version/conversion.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/version/conversion.go | Apache-2.0 |
func ObjectMetadata(meta metav1.Object) *apis.FieldError {
name := meta.GetName()
if err := validation.IsDNS1123Subdomain(name); len(err) > 0 {
return &apis.FieldError{
Message: fmt.Sprintf("invalid resource name %q: must be a valid DNS label", name),
Paths: []string{"name"},
}
}
if len(name) > MaxLength {
return &apis.FieldError{
Message: "Invalid resource name: length must be no more than 63 characters",
Paths: []string{"name"},
}
}
return nil
} | ObjectMetadata validates that the given object's name is a valid DNS name and isn't longer than the max length | ObjectMetadata | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/validate/metadata.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/validate/metadata.go | Apache-2.0 |
func (r *CustomRunStatus) GetCondition(t apis.ConditionType) *apis.Condition {
return customRunCondSet.Manage(r).GetCondition(t)
} | GetCondition returns the Condition matching the given type. | GetCondition | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | Apache-2.0 |
func (r *CustomRunStatus) InitializeConditions() {
started := false
if r.StartTime.IsZero() {
r.StartTime = &metav1.Time{Time: time.Now()}
started = true
}
conditionManager := customRunCondSet.Manage(r)
conditionManager.InitializeConditions()
// Ensure the started reason is set for the "Succeeded" condition
if started {
initialCondition := conditionManager.GetCondition(apis.ConditionSucceeded)
initialCondition.Reason = "Started"
conditionManager.SetCondition(*initialCondition)
}
} | InitializeConditions will set all conditions in customRunCondSet to unknown
and set the started time to the current time | InitializeConditions | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | Apache-2.0 |
func (r *CustomRunStatus) SetCondition(newCond *apis.Condition) {
if newCond != nil {
customRunCondSet.Manage(r).SetCondition(*newCond)
}
} | SetCondition sets the condition, unsetting previous conditions with the same
type as necessary. | SetCondition | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | Apache-2.0 |
func (r *CustomRunStatus) MarkCustomRunSucceeded(reason, messageFormat string, messageA ...interface{}) {
customRunCondSet.Manage(r).MarkTrueWithReason(apis.ConditionSucceeded, reason, messageFormat, messageA...)
succeeded := r.GetCondition(apis.ConditionSucceeded)
r.CompletionTime = &succeeded.LastTransitionTime.Inner
} | MarkCustomRunSucceeded changes the Succeeded condition to True with the provided reason and message. | MarkCustomRunSucceeded | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | Apache-2.0 |
func (r *CustomRunStatus) MarkCustomRunFailed(reason, messageFormat string, messageA ...interface{}) {
customRunCondSet.Manage(r).MarkFalse(apis.ConditionSucceeded, reason, messageFormat, messageA...)
succeeded := r.GetCondition(apis.ConditionSucceeded)
r.CompletionTime = &succeeded.LastTransitionTime.Inner
} | MarkCustomRunFailed changes the Succeeded condition to False with the provided reason and message. | MarkCustomRunFailed | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | Apache-2.0 |
func (r *CustomRunStatus) MarkCustomRunRunning(reason, messageFormat string, messageA ...interface{}) {
customRunCondSet.Manage(r).MarkUnknown(apis.ConditionSucceeded, reason, messageFormat, messageA...)
} | MarkCustomRunRunning changes the Succeeded condition to Unknown with the provided reason and message. | MarkCustomRunRunning | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | Apache-2.0 |
func (r *CustomRunStatus) DecodeExtraFields(into interface{}) error {
if len(r.ExtraFields.Raw) == 0 {
return nil
}
return json.Unmarshal(r.ExtraFields.Raw, into)
} | DecodeExtraFields deserializes the extra fields in the CustomRun status. | DecodeExtraFields | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | Apache-2.0 |
func (r *CustomRunStatus) EncodeExtraFields(from interface{}) error {
data, err := json.Marshal(from)
if err != nil {
return err
}
r.ExtraFields = runtime.RawExtension{
Raw: data,
}
return nil
} | EncodeExtraFields serializes the extra fields in the CustomRun status. | EncodeExtraFields | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | Apache-2.0 |
func FromRunStatus(orig v1alpha1.RunStatus) CustomRunStatus {
crs := CustomRunStatus{
Status: orig.Status,
CustomRunStatusFields: CustomRunStatusFields{
StartTime: orig.StartTime,
CompletionTime: orig.CompletionTime,
ExtraFields: orig.ExtraFields,
},
}
for _, origRes := range orig.Results {
crs.Results = append(crs.Results, CustomRunResult{
Name: origRes.Name,
Value: origRes.Value,
})
}
for _, origRetryStatus := range orig.RetriesStatus {
crs.RetriesStatus = append(crs.RetriesStatus, FromRunStatus(origRetryStatus))
}
return crs
} | FromRunStatus converts a v1alpha1.RunStatus into a corresponding v1beta1.CustomRunStatus | FromRunStatus | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/customrunstatus_types.go | Apache-2.0 |
func (in *CustomRunStatus) DeepCopyInto(out *CustomRunStatus) {
*out = *in
in.Status.DeepCopyInto(&out.Status)
in.CustomRunStatusFields.DeepCopyInto(&out.CustomRunStatusFields)
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *CustomRunStatus) DeepCopy() *CustomRunStatus {
if in == nil {
return nil
}
out := new(CustomRunStatus)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomRunStatus. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *CustomRunStatusFields) DeepCopyInto(out *CustomRunStatusFields) {
*out = *in
if in.StartTime != nil {
in, out := &in.StartTime, &out.StartTime
*out = (*in).DeepCopy()
}
if in.CompletionTime != nil {
in, out := &in.CompletionTime, &out.CompletionTime
*out = (*in).DeepCopy()
}
if in.Results != nil {
in, out := &in.Results, &out.Results
*out = make([]CustomRunResult, len(*in))
copy(*out, *in)
}
in.ExtraFields.DeepCopyInto(&out.ExtraFields)
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (in *CustomRunStatusFields) DeepCopy() *CustomRunStatusFields {
if in == nil {
return nil
}
out := new(CustomRunStatusFields)
in.DeepCopyInto(out)
return out
} | DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunStatusFields. | DeepCopy | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1beta1/zz_generated.deepcopy.go | Apache-2.0 |
func (r *RunStatus) GetCondition(t apis.ConditionType) *apis.Condition {
return runCondSet.Manage(r).GetCondition(t)
} | GetCondition returns the Condition matching the given type. | GetCondition | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | Apache-2.0 |
func (r *RunStatus) InitializeConditions() {
started := false
if r.StartTime.IsZero() {
r.StartTime = &metav1.Time{Time: time.Now()}
started = true
}
conditionManager := runCondSet.Manage(r)
conditionManager.InitializeConditions()
// Ensure the started reason is set for the "Succeeded" condition
if started {
initialCondition := conditionManager.GetCondition(apis.ConditionSucceeded)
initialCondition.Reason = "Started"
conditionManager.SetCondition(*initialCondition)
}
} | InitializeConditions will set all conditions in runCondSet to unknown for the PipelineRun
and set the started time to the current time | InitializeConditions | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | Apache-2.0 |
func (r *RunStatus) SetCondition(newCond *apis.Condition) {
if newCond != nil {
runCondSet.Manage(r).SetCondition(*newCond)
}
} | SetCondition sets the condition, unsetting previous conditions with the same
type as necessary. | SetCondition | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | Apache-2.0 |
func (r *RunStatus) MarkRunSucceeded(reason, messageFormat string, messageA ...interface{}) {
runCondSet.Manage(r).MarkTrueWithReason(apis.ConditionSucceeded, reason, messageFormat, messageA...)
succeeded := r.GetCondition(apis.ConditionSucceeded)
r.CompletionTime = &succeeded.LastTransitionTime.Inner
} | MarkRunSucceeded changes the Succeeded condition to True with the provided reason and message. | MarkRunSucceeded | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | Apache-2.0 |
func (r *RunStatus) MarkRunFailed(reason, messageFormat string, messageA ...interface{}) {
runCondSet.Manage(r).MarkFalse(apis.ConditionSucceeded, reason, messageFormat, messageA...)
succeeded := r.GetCondition(apis.ConditionSucceeded)
r.CompletionTime = &succeeded.LastTransitionTime.Inner
} | MarkRunFailed changes the Succeeded condition to False with the provided reason and message. | MarkRunFailed | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | Apache-2.0 |
func (r *RunStatus) MarkRunRunning(reason, messageFormat string, messageA ...interface{}) {
runCondSet.Manage(r).MarkUnknown(apis.ConditionSucceeded, reason, messageFormat, messageA...)
} | MarkRunRunning changes the Succeeded condition to Unknown with the provided reason and message. | MarkRunRunning | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | Apache-2.0 |
func (r *RunStatus) DecodeExtraFields(into interface{}) error {
if len(r.ExtraFields.Raw) == 0 {
return nil
}
return json.Unmarshal(r.ExtraFields.Raw, into)
} | DecodeExtraFields deserializes the extra fields in the Run status. | DecodeExtraFields | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | Apache-2.0 |
func (r *RunStatus) EncodeExtraFields(from interface{}) error {
data, err := json.Marshal(from)
if err != nil {
return err
}
r.ExtraFields = runtime.RawExtension{
Raw: data,
}
return nil
} | EncodeExtraFields serializes the extra fields in the Run status. | EncodeExtraFields | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/runstatus_types.go | Apache-2.0 |
func (in *RunStatus) DeepCopyInto(out *RunStatus) {
*out = *in
in.Status.DeepCopyInto(&out.Status)
in.RunStatusFields.DeepCopyInto(&out.RunStatusFields)
return
} | DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | DeepCopyInto | go | tektoncd/cli | vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/zz_generated.deepcopy.go | https://github.com/tektoncd/cli/blob/master/vendor/github.com/tektoncd/pipeline/pkg/apis/run/v1alpha1/zz_generated.deepcopy.go | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.