Skip to content

Commit

Permalink
Merge pull request #583 from CircleCI-Public/CIRCLE-33115
Browse files Browse the repository at this point in the history
[CIRCLE-33115] Check if orb published/promoted is private
  • Loading branch information
skimke authored Mar 2, 2021
2 parents ec2b22a + 4baa494 commit 84d803e
Show file tree
Hide file tree
Showing 2 changed files with 349 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,21 @@ func orbToSimpleString(orb api.OrbWithData) string {
return buffer.String()
}

func orbIsOpenSource(cl *graphql.Client, namespace string, orbName string) (bool) {
// TODO: make a separate api func to query for the orb's isPrivate field
// when available in the schema
orbExists, err := api.OrbExists(cl, namespace, orbName)

// we are don't want to output errors as they've already
// published a version of the orb successfully
if err != nil {
return false
}

// orbExists will also be false if it is a private orb
return orbExists
}

func formatListOrbsResult(list api.OrbsForListing, opts orbOptions) (string, error) {
if opts.listJSON {
orbJSON, err := json.MarshalIndent(list, "", " ")
Expand Down Expand Up @@ -673,6 +688,11 @@ func publishOrb(opts orbOptions) error {
fmt.Printf("Note that your dev label `%s` can be overwritten by anyone in your organization.\n", version)
fmt.Printf("Your dev orb will expire in 90 days unless a new version is published on the label `%s`.\n", version)
}

if orbIsOpenSource(opts.cl, namespace, orb) {
fmt.Println("Please note that this is an open orb and is world-readable.")
}

return nil
}

Expand Down Expand Up @@ -743,6 +763,11 @@ func incrementOrb(opts orbOptions) error {
}

fmt.Printf("Orb `%s` has been incremented to `%s/%s@%s`.\n", ref, namespace, orb, response.HighestVersion)

if orbIsOpenSource(opts.cl, namespace, orb) {
fmt.Println("Please note that this is an open orb and is world-readable.")
}

return nil
}

Expand All @@ -769,6 +794,11 @@ func promoteOrb(opts orbOptions) error {
}

fmt.Printf("Orb `%s` was promoted to `%s/%s@%s`.\n", ref, namespace, orb, response.HighestVersion)


if orbIsOpenSource(opts.cl, namespace, orb) {
fmt.Println("Please note that this is an open orb and is world-readable.")
}
return nil
}

Expand Down
Loading

0 comments on commit 84d803e

Please sign in to comment.