...

Source file src/github.com/fluxcd/source-controller/api/v1beta1/artifact_types.go

Documentation: github.com/fluxcd/source-controller/api/v1beta1

     1  /*
     2  Copyright 2020 The Flux authors
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1beta1
    18  
    19  import (
    20  	"path"
    21  	"strings"
    22  
    23  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    24  )
    25  
    26  // Artifact represents the output of a source synchronisation.
    27  type Artifact struct {
    28  	// Path is the relative file path of this artifact.
    29  	// +required
    30  	Path string `json:"path"`
    31  
    32  	// URL is the HTTP address of this artifact.
    33  	// +required
    34  	URL string `json:"url"`
    35  
    36  	// Revision is a human readable identifier traceable in the origin source
    37  	// system. It can be a Git commit SHA, Git tag, a Helm index timestamp, a Helm
    38  	// chart version, etc.
    39  	// +optional
    40  	Revision string `json:"revision"`
    41  
    42  	// Checksum is the SHA256 checksum of the artifact.
    43  	// +optional
    44  	Checksum string `json:"checksum"`
    45  
    46  	// LastUpdateTime is the timestamp corresponding to the last update of this
    47  	// artifact.
    48  	// +required
    49  	LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
    50  }
    51  
    52  // HasRevision returns true if the given revision matches the current Revision
    53  // of the Artifact.
    54  func (in *Artifact) HasRevision(revision string) bool {
    55  	if in == nil {
    56  		return false
    57  	}
    58  	return in.Revision == revision
    59  }
    60  
    61  // ArtifactDir returns the artifact dir path in the form of
    62  // <source-kind>/<source-namespace>/<source-name>.
    63  func ArtifactDir(kind, namespace, name string) string {
    64  	kind = strings.ToLower(kind)
    65  	return path.Join(kind, namespace, name)
    66  }
    67  
    68  // ArtifactPath returns the artifact path in the form of
    69  // <source-kind>/<source-namespace>/<source-name>/<artifact-filename>.
    70  func ArtifactPath(kind, namespace, name, filename string) string {
    71  	return path.Join(ArtifactDir(kind, namespace, name), filename)
    72  }
    73  

View as plain text