Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --reproducible flag to flux push artifact #4769

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions cmd/flux/push_artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,16 @@ The command can read the credentials from '~/.docker/config.json' but they can a
}

type pushArtifactFlags struct {
path string
source string
revision string
creds string
provider flags.SourceOCIProvider
ignorePaths []string
annotations []string
output string
debug bool
path string
source string
revision string
creds string
provider flags.SourceOCIProvider
ignorePaths []string
annotations []string
output string
debug bool
reproducible bool
}

var pushArtifactArgs = newPushArtifactFlags()
Expand All @@ -135,6 +136,7 @@ func init() {
pushArtifactCmd.Flags().StringVarP(&pushArtifactArgs.output, "output", "o", "",
"the format in which the artifact digest should be printed, can be 'json' or 'yaml'")
pushArtifactCmd.Flags().BoolVarP(&pushArtifactArgs.debug, "debug", "", false, "display logs from underlying library")
pushArtifactCmd.Flags().BoolVar(&pushArtifactArgs.reproducible, "reproducible", false, "ensure reproducible image digests by setting the created timestamp to '1970-01-01T00:00:00Z'")

pushCmd.AddCommand(pushArtifactCmd)
}
Expand Down Expand Up @@ -202,6 +204,11 @@ func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
Annotations: annotations,
}

if pushArtifactArgs.reproducible {
zeroTime := time.Unix(0, 0)
meta.Created = zeroTime.Format(time.RFC3339)
}

ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
defer cancel()

Expand Down
Loading