// Copyright The gittuf Authors // SPDX-License-Identifier: Apache-2.0 package sign import ( "github.com/gittuf/gittuf/experimental/gittuf" trustpolicyopts "github.com/gittuf/gittuf/experimental/gittuf/options/trustpolicy" "github.com/gittuf/gittuf/internal/cmd/trust/persistent" "github.com/spf13/cobra" ) type options struct { p *persistent.Options } func (o *options) AddFlags(_ *cobra.Command) {} func (o *options) Run(cmd *cobra.Command, _ []string) error { repo, err := gittuf.LoadRepository(".") if err != nil { return err } signer, err := gittuf.LoadSigner(repo, o.p.SigningKey) if err != nil { return err } opts := []trustpolicyopts.Option{} if o.p.WithRSLEntry { opts = append(opts, trustpolicyopts.WithRSLEntry()) } return repo.SignRoot(cmd.Context(), signer, true, opts...) } func New(persistent *persistent.Options) *cobra.Command { o := &options{p: persistent} cmd := &cobra.Command{ Use: "sign", Short: "Sign root of trust", Long: "This command allows users to add their signature to the root of trust file.", RunE: o.Run, DisableAutoGenTag: true, } o.AddFlags(cmd) return cmd }