github.com/pluralsh/plural-cli@v0.9.5/pkg/api/versions.go (about)

     1  package api
     2  
     3  import "github.com/pluralsh/gqlclient"
     4  
     5  type VersionSpec struct {
     6  	Repository string
     7  	Chart      *string
     8  	Terraform  *string
     9  	Version    string
    10  }
    11  
    12  type TagAttributes struct {
    13  	Tag string
    14  }
    15  
    16  type VersionAttributes struct {
    17  	Tags []*TagAttributes
    18  }
    19  
    20  func (client *client) UpdateVersion(spec *VersionSpec, tags []string) error {
    21  	tagAttrs := make([]*gqlclient.VersionTagAttributes, 0)
    22  	for _, tag := range tags {
    23  		tagAttrs = append(tagAttrs, &gqlclient.VersionTagAttributes{
    24  			Tag: tag,
    25  		})
    26  	}
    27  	_, err := client.pluralClient.UpdateVersion(client.ctx, &gqlclient.VersionSpec{
    28  		Chart:      spec.Chart,
    29  		Repository: &spec.Repository,
    30  		Terraform:  spec.Terraform,
    31  		Version:    &spec.Version,
    32  	}, gqlclient.VersionAttributes{
    33  		Tags: tagAttrs,
    34  	})
    35  	if err != nil {
    36  		return err
    37  	}
    38  	return nil
    39  }